mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-15 03:28:01 -05:00
[guide] Added 'let' to rule defs regarding variables
This commit is contained in:
committed by
Jordan Harband
parent
93e91d3eb9
commit
c9490c698e
@@ -1450,7 +1450,7 @@ Other Style Guides
|
||||
## Variables
|
||||
|
||||
<a name="variables--const"></a><a name="13.1"></a>
|
||||
- [13.1](#variables--const) Always use `const` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](http://eslint.org/docs/rules/no-undef) [`prefer-const`](http://eslint.org/docs/rules/prefer-const)
|
||||
- [13.1](#variables--const) Always use `const` or `let` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](http://eslint.org/docs/rules/no-undef) [`prefer-const`](http://eslint.org/docs/rules/prefer-const)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1461,7 +1461,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="variables--one-const"></a><a name="13.2"></a>
|
||||
- [13.2](#variables--one-const) Use one `const` declaration per variable. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl)
|
||||
- [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl)
|
||||
|
||||
> Why? It's easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user