mirror of
https://github.com/labs42io/clean-code-typescript.git
synced 2025-04-18 15:13:34 +00:00
Adding terminology for magic literals
This commit is contained in:
parent
bae1b8dec0
commit
36d14bf048
1 changed files with 3 additions and 3 deletions
|
@ -117,9 +117,9 @@ function getUser(): User;
|
|||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
### Use searchable names
|
||||
### Use searchable names / Avoid Magic Literals
|
||||
|
||||
We will read more code than we will ever write. It's important that the code we do write must be readable and searchable. By *not* naming variables that end up being meaningful for understanding our program, we hurt our readers. Make your names searchable. Tools like [ESLint](https://typescript-eslint.io/) can help identify unnamed constants.
|
||||
We will read more code than we will ever write. It's important that the code we do write must be readable and searchable. By *not* naming variables that end up being meaningful for understanding our program, we hurt our readers. Make your names searchable. Tools like [ESLint](https://typescript-eslint.io/) can help identify magic literals.
|
||||
|
||||
**Bad:**
|
||||
|
||||
|
@ -131,7 +131,7 @@ setTimeout(restart, 86400000);
|
|||
**Good:**
|
||||
|
||||
```ts
|
||||
// Declare them as capitalized named constants.
|
||||
// Declare them as capitalized symbolic constants.
|
||||
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000; // 86400000
|
||||
|
||||
setTimeout(restart, MILLISECONDS_PER_DAY);
|
||||
|
|
Loading…
Add table
Reference in a new issue