mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 06:18:00 -05:00
[rule links] add labels back
This commit is contained in:
90
README.md
90
README.md
@@ -87,7 +87,7 @@ Other Style Guides
|
||||
|
||||
## References
|
||||
|
||||
- [2.1](#2.1) <a name='2.1'></a> Use `const` for all of your references; avoid using `var`. [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html)
|
||||
- [2.1](#2.1) <a name='2.1'></a> Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html)
|
||||
|
||||
> Why? This ensures that you can't reassign your references, which can lead to bugs and difficult to comprehend code.
|
||||
|
||||
@@ -101,7 +101,7 @@ Other Style Guides
|
||||
const b = 2;
|
||||
```
|
||||
|
||||
- [2.2](#2.2) <a name='2.2'></a> If you must reassign references, use `let` instead of `var`. [`no-var`](http://eslint.org/docs/rules/no-var.html), [`disallowVar`](http://jscs.info/rule/disallowVar)
|
||||
- [2.2](#2.2) <a name='2.2'></a> If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](http://eslint.org/docs/rules/no-var.html) jscs: [`disallowVar`](http://jscs.info/rule/disallowVar)
|
||||
|
||||
> Why? `let` is block-scoped rather than function-scoped like `var`.
|
||||
|
||||
@@ -135,7 +135,7 @@ Other Style Guides
|
||||
|
||||
## Objects
|
||||
|
||||
- [3.1](#3.1) <a name='3.1'></a> Use the literal syntax for object creation. [`no-new-object`](http://eslint.org/docs/rules/no-new-object.html)
|
||||
- [3.1](#3.1) <a name='3.1'></a> Use the literal syntax for object creation. eslint: [`no-new-object`](http://eslint.org/docs/rules/no-new-object.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -145,7 +145,7 @@ Other Style Guides
|
||||
const item = {};
|
||||
```
|
||||
|
||||
- [3.2](#3.2) <a name='3.2'></a> If your code will be executed in browsers in script context, don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61). It’s OK to use them in ES6 modules and server-side code. [`disallowIdentiferNames`](http://jscs.info/rule/disallowIdentifierNames)
|
||||
- [3.2](#3.2) <a name='3.2'></a> If your code will be executed in browsers in script context, don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61). It’s OK to use them in ES6 modules and server-side code. jscs: [`disallowIdentiferNames`](http://jscs.info/rule/disallowIdentifierNames)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -161,7 +161,7 @@ Other Style Guides
|
||||
};
|
||||
```
|
||||
|
||||
- [3.3](#3.3) <a name='3.3'></a> Use readable synonyms in place of reserved words. [`disallowIdentiferNames`](http://jscs.info/rule/disallowIdentifierNames)
|
||||
- [3.3](#3.3) <a name='3.3'></a> Use readable synonyms in place of reserved words. jscs: [`disallowIdentiferNames`](http://jscs.info/rule/disallowIdentifierNames)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -207,7 +207,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-object-shorthand"></a>
|
||||
- [3.5](#3.5) <a name='3.5'></a> Use object method shorthand. [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html), [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
- [3.5](#3.5) <a name='3.5'></a> Use object method shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -230,7 +230,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-object-concise"></a>
|
||||
- [3.6](#3.6) <a name='3.6'></a> Use property value shorthand. [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html), [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
- [3.6](#3.6) <a name='3.6'></a> Use property value shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
|
||||
> Why? It is shorter to write and descriptive.
|
||||
|
||||
@@ -277,7 +277,7 @@ Other Style Guides
|
||||
};
|
||||
```
|
||||
|
||||
- [3.8](#3.8) <a name="3.8"></a> Only quote properties that are invalid identifiers. [`quote-props`](http://eslint.org/docs/rules/quote-props.html), [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects)
|
||||
- [3.8](#3.8) <a name="3.8"></a> Only quote properties that are invalid identifiers. eslint: [`quote-props`](http://eslint.org/docs/rules/quote-props.html) jscs: [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects)
|
||||
|
||||
> Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines.
|
||||
|
||||
@@ -301,7 +301,7 @@ Other Style Guides
|
||||
|
||||
## Arrays
|
||||
|
||||
- [4.1](#4.1) <a name='4.1'></a> Use the literal syntax for array creation. [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor.html)
|
||||
- [4.1](#4.1) <a name='4.1'></a> Use the literal syntax for array creation. eslint: [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -350,7 +350,7 @@ Other Style Guides
|
||||
|
||||
## Destructuring
|
||||
|
||||
- [5.1](#5.1) <a name='5.1'></a> Use object destructuring when accessing and using multiple properties of an object. [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring)
|
||||
- [5.1](#5.1) <a name='5.1'></a> Use object destructuring when accessing and using multiple properties of an object. jscs: [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring)
|
||||
|
||||
> Why? Destructuring saves you from creating temporary references for those properties.
|
||||
|
||||
@@ -375,7 +375,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [5.2](#5.2) <a name='5.2'></a> Use array destructuring. [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring)
|
||||
- [5.2](#5.2) <a name='5.2'></a> Use array destructuring. jscs: [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring)
|
||||
|
||||
```javascript
|
||||
const arr = [1, 2, 3, 4];
|
||||
@@ -417,7 +417,7 @@ Other Style Guides
|
||||
|
||||
## Strings
|
||||
|
||||
- [6.1](#6.1) <a name='6.1'></a> Use single quotes `''` for strings. [`quotes`](http://eslint.org/docs/rules/quotes.html), [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks)
|
||||
- [6.1](#6.1) <a name='6.1'></a> Use single quotes `''` for strings. eslint: [`quotes`](http://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -447,7 +447,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-template-literals"></a>
|
||||
- [6.4](#6.4) <a name='6.4'></a> When programmatically building up strings, use template strings instead of concatenation. [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html), [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
|
||||
- [6.4](#6.4) <a name='6.4'></a> When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
|
||||
|
||||
> Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features.
|
||||
|
||||
@@ -474,7 +474,7 @@ Other Style Guides
|
||||
|
||||
## Functions
|
||||
|
||||
- [7.1](#7.1) <a name='7.1'></a> Use function declarations instead of function expressions. [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations)
|
||||
- [7.1](#7.1) <a name='7.1'></a> Use function declarations instead of function expressions. jscs: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations)
|
||||
|
||||
> Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions.
|
||||
|
||||
@@ -488,7 +488,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [7.2](#7.2) <a name='7.2'></a> Immediately invoked function expressions: [`wrap-iife`](http://eslint.org/docs/rules/wrap-iife.html), [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE)
|
||||
- [7.2](#7.2) <a name='7.2'></a> Immediately invoked function expressions: eslint: [`wrap-iife`](http://eslint.org/docs/rules/wrap-iife.html) jscs: [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE)
|
||||
|
||||
> Why? An immediately invoked function expression is a single unit - wrapping both it, and its invocation parens, in parens, cleanly expresses this. Note that in a world with modules everywhere, you almost never need an IIFE.
|
||||
|
||||
@@ -499,7 +499,7 @@ Other Style Guides
|
||||
}());
|
||||
```
|
||||
|
||||
- [7.3](#7.3) <a name='7.3'></a> Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html)
|
||||
- [7.3](#7.3) <a name='7.3'></a> Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html)
|
||||
|
||||
- [7.4](#7.4) <a name='7.4'></a> **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262's note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97).
|
||||
|
||||
@@ -636,7 +636,7 @@ Other Style Guides
|
||||
const y = function a() {};
|
||||
```
|
||||
|
||||
- [7.12](#7.12) <a name="7.12"></a> Never mutate parameters. [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
- [7.12](#7.12) <a name="7.12"></a> Never mutate parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
|
||||
> Why? Manipulating objects passed in as parameters can cause unwanted variable side effects in the original caller.
|
||||
|
||||
@@ -652,7 +652,7 @@ Other Style Guides
|
||||
};
|
||||
```
|
||||
|
||||
- [7.13](#7.13) <a name="7.13"></a> Never reassign parameters. [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
- [7.13](#7.13) <a name="7.13"></a> Never reassign parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
|
||||
> Why? Reassigning parameters can lead to unexpected behavior, especially when accessing the `arguments` object. It can also cause optimization issues, especially in V8.
|
||||
|
||||
@@ -679,7 +679,7 @@ Other Style Guides
|
||||
|
||||
## Arrow Functions
|
||||
|
||||
- [8.1](#8.1) <a name='8.1'></a> When you must use function expressions (as when passing an anonymous function), use arrow function notation. [`prefer-arrow-callback`](http://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](http://eslint.org/docs/rules/arrow-spacing.html), [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions)
|
||||
- [8.1](#8.1) <a name='8.1'></a> When you must use function expressions (as when passing an anonymous function), use arrow function notation. eslint: [`prefer-arrow-callback`](http://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](http://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions)
|
||||
|
||||
> Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax.
|
||||
|
||||
@@ -699,7 +699,7 @@ Other Style Guides
|
||||
});
|
||||
```
|
||||
|
||||
- [8.2](#8.2) <a name='8.2'></a> If the function body consists of a single expression, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html), [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions)
|
||||
- [8.2](#8.2) <a name='8.2'></a> If the function body consists of a single expression, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions)
|
||||
|
||||
> Why? Syntactic sugar. It reads well when multiple functions are chained together.
|
||||
|
||||
@@ -741,7 +741,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
|
||||
- [8.4](#8.4) <a name='8.4'></a> If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments. [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam)
|
||||
- [8.4](#8.4) <a name='8.4'></a> If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam)
|
||||
|
||||
> Why? Less visual clutter.
|
||||
|
||||
@@ -937,7 +937,7 @@ Other Style Guides
|
||||
|
||||
## Iterators and Generators
|
||||
|
||||
- [11.1](#11.1) <a name='11.1'></a> Don't use iterators. Prefer JavaScript's higher-order functions like `map()` and `reduce()` instead of loops like `for-of`. [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html)
|
||||
- [11.1](#11.1) <a name='11.1'></a> Don't use iterators. Prefer JavaScript's higher-order functions like `map()` and `reduce()` instead of loops like `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html)
|
||||
|
||||
> Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side-effects.
|
||||
|
||||
@@ -971,7 +971,7 @@ Other Style Guides
|
||||
|
||||
## Properties
|
||||
|
||||
- [12.1](#12.1) <a name='12.1'></a> Use dot notation when accessing properties. [`dot-notation`](http://eslint.org/docs/rules/dot-notation.html), [`requireDotNotation`](http://jscs.info/rule/requireDotNotation)
|
||||
- [12.1](#12.1) <a name='12.1'></a> Use dot notation when accessing properties. eslint: [`dot-notation`](http://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation)
|
||||
|
||||
```javascript
|
||||
const luke = {
|
||||
@@ -1016,7 +1016,7 @@ Other Style Guides
|
||||
const superPower = new SuperPower();
|
||||
```
|
||||
|
||||
- [13.2](#13.2) <a name='13.2'></a> Use one `const` declaration per variable. [`one-var`](http://eslint.org/docs/rules/one-var.html), [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl)
|
||||
- [13.2](#13.2) <a name='13.2'></a> Use one `const` 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.
|
||||
|
||||
@@ -1202,7 +1202,7 @@ Other Style Guides
|
||||
|
||||
## Comparison Operators & Equality
|
||||
|
||||
- [15.1](#15.1) <a name='15.1'></a> Use `===` and `!==` over `==` and `!=`. [`eqeqeq`](http://eslint.org/docs/rules/eqeqeq.html)
|
||||
- [15.1](#15.1) <a name='15.1'></a> Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](http://eslint.org/docs/rules/eqeqeq.html)
|
||||
|
||||
- [15.2](#15.2) <a name='15.2'></a> Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules:
|
||||
|
||||
@@ -1276,7 +1276,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
- [16.2](#16.2) <a name='16.2'></a> If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your
|
||||
`if` block's closing brace. [`brace-style`](http://eslint.org/docs/rules/brace-style.html), [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements)
|
||||
`if` block's closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1406,7 +1406,7 @@ Other Style Guides
|
||||
|
||||
## Whitespace
|
||||
|
||||
- [18.1](#18.1) <a name='18.1'></a> Use soft tabs set to 2 spaces. [`indent`](http://eslint.org/docs/rules/indent.html), [`validateIndentation`](http://jscs.info/rule/validateIndentation)
|
||||
- [18.1](#18.1) <a name='18.1'></a> Use soft tabs set to 2 spaces. eslint: [`indent`](http://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1425,7 +1425,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [18.2](#18.2) <a name='18.2'></a> Place 1 space before the leading brace. [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks.html), [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements).
|
||||
- [18.2](#18.2) <a name='18.2'></a> Place 1 space before the leading brace. eslint: [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1451,7 +1451,7 @@ Other Style Guides
|
||||
});
|
||||
```
|
||||
|
||||
- [18.3](#18.3) <a name='18.3'></a> Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. [`space-after-keywords`](http://eslint.org/docs/rules/space-after-keywords.html), [`space-before-keywords`](http://eslint.org/docs/rules/space-before-keywords.html), [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords)
|
||||
- [18.3](#18.3) <a name='18.3'></a> Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`space-after-keywords`](http://eslint.org/docs/rules/space-after-keywords.html), [`space-before-keywords`](http://eslint.org/docs/rules/space-before-keywords.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1475,7 +1475,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [18.4](#18.4) <a name='18.4'></a> Set off operators with spaces. [`space-infix-ops`](http://eslint.org/docs/rules/space-infix-ops.html), [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators)
|
||||
- [18.4](#18.4) <a name='18.4'></a> Set off operators with spaces. eslint: [`space-infix-ops`](http://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1549,7 +1549,7 @@ Other Style Guides
|
||||
.call(tron.led);
|
||||
```
|
||||
|
||||
- [18.7](#18.7) <a name='18.7'></a> Leave a blank line after blocks and before the next statement. [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks)
|
||||
- [18.7](#18.7) <a name='18.7'></a> Leave a blank line after blocks and before the next statement. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1606,7 +1606,7 @@ Other Style Guides
|
||||
return arr;
|
||||
```
|
||||
|
||||
- [18.8](#18.8) <a name='18.8'></a> Do not pad your blocks with blank lines. [`padded-blocks`](http://eslint.org/docs/rules/padded-blocks.html), [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks)
|
||||
- [18.8](#18.8) <a name='18.8'></a> Do not pad your blocks with blank lines. eslint: [`padded-blocks`](http://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1638,7 +1638,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [18.9](#18.9) <a name='18.9'></a> Do not add spaces inside parentheses. [`space-in-parens`](http://eslint.org/docs/rules/space-in-parens.html), [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses)
|
||||
- [18.9](#18.9) <a name='18.9'></a> Do not add spaces inside parentheses. eslint: [`space-in-parens`](http://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1662,7 +1662,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [18.10](#18.10) <a name='18.10'></a> Do not add spaces inside brackets. [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing.html), [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets).
|
||||
- [18.10](#18.10) <a name='18.10'></a> Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1674,7 +1674,7 @@ Other Style Guides
|
||||
console.log(foo[0]);
|
||||
```
|
||||
|
||||
- [18.11](#18.11) <a name='18.11'></a> Add spaces inside curly braces. [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing.html), [`disallowSpacesInsideObjectBrackets`](http://jscs.info/rule/disallowSpacesInsideObjectBrackets)
|
||||
- [18.11](#18.11) <a name='18.11'></a> Add spaces inside curly braces. eslint: [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`disallowSpacesInsideObjectBrackets`](http://jscs.info/rule/disallowSpacesInsideObjectBrackets)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1684,7 +1684,7 @@ Other Style Guides
|
||||
const foo = { clark: 'kent' };
|
||||
```
|
||||
|
||||
- [18.12](#18.12) <a name='18.12'></a> Avoid having lines of code that are longer than 100 characters (including whitespace). [`max-len`](http://eslint.org/docs/rules/max-len.html), [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
|
||||
- [18.12](#18.12) <a name='18.12'></a> Avoid having lines of code that are longer than 100 characters (including whitespace). eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
|
||||
|
||||
> Why? This ensures readability and maintainability.
|
||||
|
||||
@@ -1713,7 +1713,7 @@ Other Style Guides
|
||||
|
||||
## Commas
|
||||
|
||||
- [19.1](#19.1) <a name='19.1'></a> Leading commas: **Nope.** [`comma-style`](http://eslint.org/docs/rules/comma-style.html), [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak)
|
||||
- [19.1](#19.1) <a name='19.1'></a> Leading commas: **Nope.** eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1747,7 +1747,7 @@ Other Style Guides
|
||||
};
|
||||
```
|
||||
|
||||
- [19.2](#19.2) <a name='19.2'></a> Additional trailing comma: **Yup.** [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html), [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma)
|
||||
- [19.2](#19.2) <a name='19.2'></a> Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma)
|
||||
|
||||
> Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](es5/README.md#commas) in legacy browsers.
|
||||
|
||||
@@ -1795,7 +1795,7 @@ Other Style Guides
|
||||
|
||||
## Semicolons
|
||||
|
||||
- [20.1](#20.1) <a name='20.1'></a> **Yup.** [`semi`](http://eslint.org/docs/rules/semi.html), [`requireSemicolons`](http://jscs.info/rule/requireSemicolons)
|
||||
- [20.1](#20.1) <a name='20.1'></a> **Yup.** eslint: [`semi`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1837,7 +1837,7 @@ Other Style Guides
|
||||
const totalScore = String(this.reviewScore);
|
||||
```
|
||||
|
||||
- [21.3](#21.3) <a name='21.3'></a> Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. [`radix`](http://eslint.org/docs/rules/radix)
|
||||
- [21.3](#21.3) <a name='21.3'></a> Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](http://eslint.org/docs/rules/radix)
|
||||
|
||||
```javascript
|
||||
const inputValue = '4';
|
||||
@@ -1915,7 +1915,7 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [22.2](#22.2) <a name='22.2'></a> Use camelCase when naming objects, functions, and instances. [`camelcase`](http://eslint.org/docs/rules/camelcase.html), `requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers)
|
||||
- [22.2](#22.2) <a name='22.2'></a> Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](http://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1928,7 +1928,7 @@ Other Style Guides
|
||||
function thisIsMyFunction() {}
|
||||
```
|
||||
|
||||
- [22.3](#22.3) <a name='22.3'></a> Use PascalCase when naming constructors or classes. [`new-cap`](http://eslint.org/docs/rules/new-cap.html), [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors)
|
||||
- [22.3](#22.3) <a name='22.3'></a> Use PascalCase when naming constructors or classes. eslint: [`new-cap`](http://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1952,7 +1952,7 @@ Other Style Guides
|
||||
});
|
||||
```
|
||||
|
||||
- [22.4](#22.4) <a name='22.4'></a> Use a leading underscore `_` when naming private properties. [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html), [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores)
|
||||
- [22.4](#22.4) <a name='22.4'></a> Use a leading underscore `_` when naming private properties. eslint: [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1963,7 +1963,7 @@ Other Style Guides
|
||||
this._firstName = 'Panda';
|
||||
```
|
||||
|
||||
- [22.5](#22.5) <a name='22.5'></a> Don't save references to `this`. Use arrow functions or Function#bind. [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes)
|
||||
- [22.5](#22.5) <a name='22.5'></a> Don't save references to `this`. Use arrow functions or Function#bind. jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2122,7 +2122,7 @@ Other Style Guides
|
||||
|
||||
## jQuery
|
||||
|
||||
- [25.1](#25.1) <a name='25.1'></a> Prefix jQuery object variables with a `$`. [`requireDollarBeforejQueryAssignment`](http://jscs.info/rule/requireDollarBeforejQueryAssignment)
|
||||
- [25.1](#25.1) <a name='25.1'></a> Prefix jQuery object variables with a `$`. jscs: [`requireDollarBeforejQueryAssignment`](http://jscs.info/rule/requireDollarBeforejQueryAssignment)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
|
||||
Reference in New Issue
Block a user