mirror of
https://github.com/airbnb/javascript.git
synced 2026-04-25 03:00:19 -04:00
[guide] Use HTTPS for links to ESLint documentation
The result of a `s_http://eslint\.org_https://eslint\.org_g`. Avoids the HTTP 302s of the non-HTTPs URLs.
This commit is contained in:
126
README.md
126
README.md
@@ -102,7 +102,7 @@ Other Style Guides
|
||||
## References
|
||||
|
||||
<a name="references--prefer-const"></a><a name="2.1"></a>
|
||||
- [2.1](#references--prefer-const) 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)
|
||||
- [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](https://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](https://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.
|
||||
|
||||
@@ -117,7 +117,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="references--disallow-var"></a><a name="2.2"></a>
|
||||
- [2.2](#references--disallow-var) 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)
|
||||
- [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://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`.
|
||||
|
||||
@@ -153,7 +153,7 @@ Other Style Guides
|
||||
## Objects
|
||||
|
||||
<a name="objects--no-new"></a><a name="3.1"></a>
|
||||
- [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](http://eslint.org/docs/rules/no-new-object.html)
|
||||
- [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](https://eslint.org/docs/rules/no-new-object.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -190,7 +190,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-object-shorthand"></a><a name="3.5"></a>
|
||||
- [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
- [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -213,7 +213,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-object-concise"></a><a name="3.6"></a>
|
||||
- [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
- [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals)
|
||||
|
||||
> Why? It is shorter to write and descriptive.
|
||||
|
||||
@@ -262,7 +262,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="objects--quoted-props"></a><a name="3.8"></a>
|
||||
- [3.6](#objects--quoted-props) 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)
|
||||
- [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://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.
|
||||
|
||||
@@ -327,7 +327,7 @@ Other Style Guides
|
||||
## Arrays
|
||||
|
||||
<a name="arrays--literals"></a><a name="4.1"></a>
|
||||
- [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor.html)
|
||||
- [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -392,7 +392,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="arrays--callback-return"></a><a name="4.5"></a>
|
||||
- [4.6](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return)
|
||||
- [4.6](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return)
|
||||
|
||||
```javascript
|
||||
// good
|
||||
@@ -549,7 +549,7 @@ Other Style Guides
|
||||
## Strings
|
||||
|
||||
<a name="strings--quotes"></a><a name="6.1"></a>
|
||||
- [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](http://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks)
|
||||
- [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -584,7 +584,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-template-literals"></a><a name="6.4"></a>
|
||||
- [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
|
||||
- [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings)
|
||||
|
||||
> Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features.
|
||||
|
||||
@@ -611,10 +611,10 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="strings--eval"></a><a name="6.5"></a>
|
||||
- [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](http://eslint.org/docs/rules/no-eval)
|
||||
- [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](https://eslint.org/docs/rules/no-eval)
|
||||
|
||||
<a name="strings--escaping"></a>
|
||||
- [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape)
|
||||
- [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](https://eslint.org/docs/rules/no-useless-escape)
|
||||
|
||||
> Why? Backslashes harm readability, thus they should only be present when necessary.
|
||||
|
||||
@@ -632,7 +632,7 @@ Other Style Guides
|
||||
## Functions
|
||||
|
||||
<a name="functions--declarations"></a><a name="7.1"></a>
|
||||
- [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations)
|
||||
- [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations)
|
||||
|
||||
> Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794))
|
||||
|
||||
@@ -655,7 +655,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--iife"></a><a name="7.2"></a>
|
||||
- [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](http://eslint.org/docs/rules/wrap-iife.html) jscs: [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE)
|
||||
- [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://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.
|
||||
|
||||
@@ -667,7 +667,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--in-blocks"></a><a name="7.3"></a>
|
||||
- [7.3](#functions--in-blocks) 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.3](#functions--in-blocks) 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`](https://eslint.org/docs/rules/no-loop-func.html)
|
||||
|
||||
<a name="functions--note-on-blocks"></a><a name="7.4"></a>
|
||||
- [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement.
|
||||
@@ -705,7 +705,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="es6-rest"></a><a name="7.6"></a>
|
||||
- [7.6](#es6-rest) Never use `arguments`, opt to use rest syntax `...` instead. eslint: [`prefer-rest-params`](http://eslint.org/docs/rules/prefer-rest-params)
|
||||
- [7.6](#es6-rest) Never use `arguments`, opt to use rest syntax `...` instead. eslint: [`prefer-rest-params`](https://eslint.org/docs/rules/prefer-rest-params)
|
||||
|
||||
> Why? `...` is explicit about which arguments you want pulled. Plus, rest arguments are a real Array, and not merely Array-like like `arguments`.
|
||||
|
||||
@@ -782,7 +782,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--constructor"></a><a name="7.10"></a>
|
||||
- [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](http://eslint.org/docs/rules/no-new-func)
|
||||
- [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](https://eslint.org/docs/rules/no-new-func)
|
||||
|
||||
> Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.
|
||||
|
||||
@@ -795,7 +795,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--signature-spacing"></a><a name="7.11"></a>
|
||||
- [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](http://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks)
|
||||
- [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks)
|
||||
|
||||
> Why? Consistency is good, and you shouldn’t have to add or remove a space when adding or removing a name.
|
||||
|
||||
@@ -811,7 +811,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--mutate-params"></a><a name="7.12"></a>
|
||||
- [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
- [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](https://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.
|
||||
|
||||
@@ -828,7 +828,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--reassign-params"></a><a name="7.13"></a>
|
||||
- [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html)
|
||||
- [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](https://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.
|
||||
|
||||
@@ -856,7 +856,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="functions--spread-vs-apply"></a><a name="7.14"></a>
|
||||
- [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread)
|
||||
- [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread)
|
||||
|
||||
> Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`.
|
||||
|
||||
@@ -914,7 +914,7 @@ Other Style Guides
|
||||
## Arrow Functions
|
||||
|
||||
<a name="arrows--use-them"></a><a name="8.1"></a>
|
||||
- [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), 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)
|
||||
- [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://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.
|
||||
|
||||
@@ -935,7 +935,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="arrows--implicit-return"></a><a name="8.2"></a>
|
||||
- [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, 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)
|
||||
- [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://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.
|
||||
|
||||
@@ -1002,7 +1002,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="arrows--one-arg-parens"></a><a name="8.4"></a>
|
||||
- [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam)
|
||||
- [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](https://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam)
|
||||
|
||||
> Why? Less visual clutter.
|
||||
|
||||
@@ -1032,7 +1032,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="arrows--confusing"></a><a name="8.5"></a>
|
||||
- [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](http://eslint.org/docs/rules/no-confusing-arrow)
|
||||
- [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](https://eslint.org/docs/rules/no-confusing-arrow)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1165,7 +1165,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="constructors--no-useless"></a><a name="9.5"></a>
|
||||
- [9.5](#constructors--no-useless) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. eslint: [`no-useless-constructor`](http://eslint.org/docs/rules/no-useless-constructor)
|
||||
- [9.5](#constructors--no-useless) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. eslint: [`no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1194,7 +1194,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="classes--no-duplicate-members"></a>
|
||||
- [9.6](#classes--no-duplicate-members) Avoid duplicate class members. eslint: [`no-dupe-class-members`](http://eslint.org/docs/rules/no-dupe-class-members)
|
||||
- [9.6](#classes--no-duplicate-members) Avoid duplicate class members. eslint: [`no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members)
|
||||
|
||||
> Why? Duplicate class member declarations will silently prefer the last one - having duplicates is almost certainly a bug.
|
||||
|
||||
@@ -1270,7 +1270,7 @@ Other Style Guides
|
||||
|
||||
<a name="modules--no-duplicate-imports"></a>
|
||||
- [10.4](#modules--no-duplicate-imports) Only import from a path in one place.
|
||||
eslint: [`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports)
|
||||
eslint: [`no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports)
|
||||
> Why? Having multiple lines that import from the same path can make code harder to maintain.
|
||||
|
||||
```javascript
|
||||
@@ -1375,7 +1375,7 @@ Other Style Guides
|
||||
## Iterators and Generators
|
||||
|
||||
<a name="iterators--nope"></a><a name="11.1"></a>
|
||||
- [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax)
|
||||
- [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](https://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax)
|
||||
|
||||
> Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects.
|
||||
|
||||
@@ -1424,7 +1424,7 @@ Other Style Guides
|
||||
> Why? They don’t transpile well to ES5.
|
||||
|
||||
<a name="generators--spacing"></a>
|
||||
- [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing)
|
||||
- [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](https://eslint.org/docs/rules/generator-star-spacing)
|
||||
|
||||
> Why? `function` and `*` are part of the same conceptual keyword - `*` is not a modifier for `function`, `function*` is a unique construct, different from `function`.
|
||||
|
||||
@@ -1489,7 +1489,7 @@ Other Style Guides
|
||||
## Properties
|
||||
|
||||
<a name="properties--dot"></a><a name="12.1"></a>
|
||||
- [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](http://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation)
|
||||
- [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation)
|
||||
|
||||
```javascript
|
||||
const luke = {
|
||||
@@ -1520,7 +1520,7 @@ Other Style Guides
|
||||
const isJedi = getProp('jedi');
|
||||
```
|
||||
<a name="es2016-properties--exponentiation-operator"></a>
|
||||
- [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](http://eslint.org/docs/rules/no-restricted-properties).
|
||||
- [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties).
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1535,7 +1535,7 @@ Other Style Guides
|
||||
## Variables
|
||||
|
||||
<a name="variables--const"></a><a name="13.1"></a>
|
||||
- [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)
|
||||
- [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`](https://eslint.org/docs/rules/no-undef) [`prefer-const`](https://eslint.org/docs/rules/prefer-const)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1546,7 +1546,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="variables--one-const"></a><a name="13.2"></a>
|
||||
- [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)
|
||||
- [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](https://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.
|
||||
|
||||
@@ -1666,7 +1666,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>
|
||||
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](http://eslint.org/docs/rules/no-plusplus)
|
||||
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus)
|
||||
|
||||
> Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num++` or `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs.
|
||||
|
||||
@@ -1803,7 +1803,7 @@ Other Style Guides
|
||||
## Comparison Operators & Equality
|
||||
|
||||
<a name="comparison--eqeqeq"></a><a name="15.1"></a>
|
||||
- [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](http://eslint.org/docs/rules/eqeqeq.html)
|
||||
- [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq.html)
|
||||
|
||||
<a name="comparison--if"></a><a name="15.2"></a>
|
||||
- [15.2](#comparison--if) Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules:
|
||||
@@ -1861,7 +1861,7 @@ Other Style Guides
|
||||
- [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll.
|
||||
|
||||
<a name="comparison--switch-blocks"></a><a name="15.5"></a>
|
||||
- [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html)
|
||||
- [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](https://eslint.org/docs/rules/no-case-declarations.html)
|
||||
|
||||
> Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing.
|
||||
|
||||
@@ -1909,7 +1909,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="comparison--nested-ternaries"></a><a name="15.6"></a>
|
||||
- [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](http://eslint.org/docs/rules/no-nested-ternary.html)
|
||||
- [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1930,7 +1930,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="comparison--unneeded-ternary"></a><a name="15.7"></a>
|
||||
- [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary.html)
|
||||
- [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](https://eslint.org/docs/rules/no-unneeded-ternary.html)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1945,7 +1945,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="comparison--no-mixed-operators"></a>
|
||||
- [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](http://eslint.org/docs/rules/no-mixed-operators.html)
|
||||
- [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html)
|
||||
|
||||
> Why? This improves readability and clarifies the developer’s intention.
|
||||
|
||||
@@ -2006,7 +2006,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="blocks--cuddled-elses"></a><a name="16.2"></a>
|
||||
- [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements)
|
||||
- [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2224,7 +2224,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="comments--spaces"></a>
|
||||
- [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](http://eslint.org/docs/rules/spaced-comment)
|
||||
- [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](https://eslint.org/docs/rules/spaced-comment)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2296,7 +2296,7 @@ Other Style Guides
|
||||
## Whitespace
|
||||
|
||||
<a name="whitespace--spaces"></a><a name="18.1"></a>
|
||||
- [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](http://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation)
|
||||
- [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2316,7 +2316,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--before-blocks"></a><a name="18.2"></a>
|
||||
- [19.2](#whitespace--before-blocks) 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)
|
||||
- [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2343,7 +2343,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--around-keywords"></a><a name="18.3"></a>
|
||||
- [19.3](#whitespace--around-keywords) 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: [`keyword-spacing`](http://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords)
|
||||
- [19.3](#whitespace--around-keywords) 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: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2368,7 +2368,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--infix-ops"></a><a name="18.4"></a>
|
||||
- [19.4](#whitespace--infix-ops) 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)
|
||||
- [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2405,7 +2405,7 @@ Other Style Guides
|
||||
|
||||
<a name="whitespace--chains"></a><a name="18.6"></a>
|
||||
- [19.6](#whitespace--chains) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which
|
||||
emphasizes that the line is a method call, not a new statement. eslint: [`newline-per-chained-call`](http://eslint.org/docs/rules/newline-per-chained-call) [`no-whitespace-before-property`](http://eslint.org/docs/rules/no-whitespace-before-property)
|
||||
emphasizes that the line is a method call, not a new statement. eslint: [`newline-per-chained-call`](https://eslint.org/docs/rules/newline-per-chained-call) [`no-whitespace-before-property`](https://eslint.org/docs/rules/no-whitespace-before-property)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2506,7 +2506,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--padded-blocks"></a><a name="18.8"></a>
|
||||
- [19.8](#whitespace--padded-blocks) 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)
|
||||
- [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2547,7 +2547,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--in-parens"></a><a name="18.9"></a>
|
||||
- [19.9](#whitespace--in-parens) 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)
|
||||
- [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2572,7 +2572,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--in-brackets"></a><a name="18.10"></a>
|
||||
- [19.10](#whitespace--in-brackets) 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)
|
||||
- [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2585,7 +2585,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--in-braces"></a><a name="18.11"></a>
|
||||
- [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets)
|
||||
- [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2596,7 +2596,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="whitespace--max-len"></a><a name="18.12"></a>
|
||||
- [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
|
||||
- [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
|
||||
|
||||
> Why? This ensures readability and maintainability.
|
||||
|
||||
@@ -2630,7 +2630,7 @@ Other Style Guides
|
||||
## Commas
|
||||
|
||||
<a name="commas--leading-trailing"></a><a name="19.1"></a>
|
||||
- [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak)
|
||||
- [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2665,7 +2665,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="commas--dangling"></a><a name="19.2"></a>
|
||||
- [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma)
|
||||
- [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://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](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers.
|
||||
|
||||
@@ -2765,7 +2765,7 @@ Other Style Guides
|
||||
## Semicolons
|
||||
|
||||
<a name="semicolons--required"></a><a name="20.1"></a>
|
||||
- [21.1](#semicolons--required) **Yup.** eslint: [`semi`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons)
|
||||
- [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2816,7 +2816,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="coercion--numbers"></a><a name="21.3"></a>
|
||||
- [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](http://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers)
|
||||
- [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](https://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers)
|
||||
|
||||
```javascript
|
||||
const inputValue = '4';
|
||||
@@ -2883,7 +2883,7 @@ Other Style Guides
|
||||
## Naming Conventions
|
||||
|
||||
<a name="naming--descriptive"></a><a name="22.1"></a>
|
||||
- [23.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming. eslint: [`id-length`](http://eslint.org/docs/rules/id-length)
|
||||
- [23.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming. eslint: [`id-length`](https://eslint.org/docs/rules/id-length)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2898,7 +2898,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="naming--camelCase"></a><a name="22.2"></a>
|
||||
- [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](http://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers)
|
||||
- [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2912,7 +2912,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="naming--PascalCase"></a><a name="22.3"></a>
|
||||
- [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](http://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors)
|
||||
- [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -2937,7 +2937,7 @@ Other Style Guides
|
||||
```
|
||||
|
||||
<a name="naming--leading-underscore"></a><a name="22.4"></a>
|
||||
- [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores)
|
||||
- [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores)
|
||||
|
||||
> Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won’t count as breaking, or that tests aren’t needed. tl;dr: if you want something to be “private”, it must not be observably present.
|
||||
|
||||
@@ -3287,7 +3287,7 @@ Other Style Guides
|
||||
|
||||
<a name="standard-library--isnan"></a>
|
||||
- [29.1](#standard-library--isnan) Use `Number.isNaN` instead of global `isNaN`.
|
||||
eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals)
|
||||
eslint: [`no-restricted-globals`](https://eslint.org/docs/rules/no-restricted-globals)
|
||||
|
||||
> Why? The global `isNaN` coerces non-numbers to numbers, returning true for anything that coerces to NaN.
|
||||
> If this behavior is desired, make it explicit.
|
||||
@@ -3304,7 +3304,7 @@ Other Style Guides
|
||||
|
||||
<a name="standard-library--isfinite"></a>
|
||||
- [29.2](#standard-library--isfinite) Use `Number.isFinite` instead of global `isFinite`.
|
||||
eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals)
|
||||
eslint: [`no-restricted-globals`](https://eslint.org/docs/rules/no-restricted-globals)
|
||||
|
||||
> Why? The global `isFinite` coerces non-numbers to numbers, returning true for anything that coerces to a finite number.
|
||||
> If this behavior is desired, make it explicit.
|
||||
@@ -3372,7 +3372,7 @@ Other Style Guides
|
||||
**Tools**
|
||||
|
||||
- Code Style Linters
|
||||
- [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc)
|
||||
- [ESlint](https://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc)
|
||||
- [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc)
|
||||
- [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base))
|
||||
- Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/)
|
||||
|
||||
@@ -75,7 +75,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
|
||||
|
||||
2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
|
||||
|
||||
See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
|
||||
See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
|
||||
|
||||
## Improving this config
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
'accessor-pairs': 'off',
|
||||
|
||||
// enforces return statements in callbacks of array's methods
|
||||
// http://eslint.org/docs/rules/array-callback-return
|
||||
// https://eslint.org/docs/rules/array-callback-return
|
||||
'array-callback-return': 'error',
|
||||
|
||||
// treat var statements as if they were block scoped
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
complexity: ['off', 11],
|
||||
|
||||
// enforce that class methods use "this"
|
||||
// http://eslint.org/docs/rules/class-methods-use-this
|
||||
// https://eslint.org/docs/rules/class-methods-use-this
|
||||
'class-methods-use-this': ['error', {
|
||||
exceptMethods: [],
|
||||
}],
|
||||
@@ -32,11 +32,11 @@ module.exports = {
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
|
||||
// enforces consistent newlines before or after dots
|
||||
// http://eslint.org/docs/rules/dot-location
|
||||
// https://eslint.org/docs/rules/dot-location
|
||||
'dot-location': ['error', 'property'],
|
||||
|
||||
// require the use of === and !==
|
||||
// http://eslint.org/docs/rules/eqeqeq
|
||||
// https://eslint.org/docs/rules/eqeqeq
|
||||
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
||||
|
||||
// make sure for-in loops have an if statement
|
||||
@@ -49,11 +49,11 @@ module.exports = {
|
||||
'no-caller': 'error',
|
||||
|
||||
// disallow lexical declarations in case/default clauses
|
||||
// http://eslint.org/docs/rules/no-case-declarations.html
|
||||
// https://eslint.org/docs/rules/no-case-declarations.html
|
||||
'no-case-declarations': 'error',
|
||||
|
||||
// disallow division operators explicitly at beginning of regular expression
|
||||
// http://eslint.org/docs/rules/no-div-regex
|
||||
// https://eslint.org/docs/rules/no-div-regex
|
||||
'no-div-regex': 'off',
|
||||
|
||||
// disallow else after a return in an if
|
||||
@@ -61,7 +61,7 @@ module.exports = {
|
||||
'no-else-return': ['error', { allowElseIf: false }],
|
||||
|
||||
// disallow empty functions, except for standalone funcs/arrows
|
||||
// http://eslint.org/docs/rules/no-empty-function
|
||||
// https://eslint.org/docs/rules/no-empty-function
|
||||
'no-empty-function': ['error', {
|
||||
allow: [
|
||||
'arrowFunctions',
|
||||
@@ -71,7 +71,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow empty destructuring patterns
|
||||
// http://eslint.org/docs/rules/no-empty-pattern
|
||||
// https://eslint.org/docs/rules/no-empty-pattern
|
||||
'no-empty-pattern': 'error',
|
||||
|
||||
// disallow comparisons to null without a type-checking operator
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
'no-extra-bind': 'error',
|
||||
|
||||
// disallow Unnecessary Labels
|
||||
// http://eslint.org/docs/rules/no-extra-label
|
||||
// https://eslint.org/docs/rules/no-extra-label
|
||||
'no-extra-label': 'error',
|
||||
|
||||
// disallow fallthrough of case statements
|
||||
@@ -97,13 +97,13 @@ module.exports = {
|
||||
'no-floating-decimal': 'error',
|
||||
|
||||
// disallow reassignments of native objects or read-only globals
|
||||
// http://eslint.org/docs/rules/no-global-assign
|
||||
// https://eslint.org/docs/rules/no-global-assign
|
||||
'no-global-assign': ['error', { exceptions: [] }],
|
||||
// deprecated in favor of no-global-assign
|
||||
'no-native-reassign': 'off',
|
||||
|
||||
// disallow implicit type conversions
|
||||
// http://eslint.org/docs/rules/no-implicit-coercion
|
||||
// https://eslint.org/docs/rules/no-implicit-coercion
|
||||
'no-implicit-coercion': ['off', {
|
||||
boolean: false,
|
||||
number: true,
|
||||
@@ -112,7 +112,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow var and named functions in global scope
|
||||
// http://eslint.org/docs/rules/no-implicit-globals
|
||||
// https://eslint.org/docs/rules/no-implicit-globals
|
||||
'no-implicit-globals': 'off',
|
||||
|
||||
// disallow use of eval()-like methods
|
||||
@@ -134,7 +134,7 @@ module.exports = {
|
||||
'no-loop-func': 'error',
|
||||
|
||||
// disallow magic numbers
|
||||
// http://eslint.org/docs/rules/no-magic-numbers
|
||||
// https://eslint.org/docs/rules/no-magic-numbers
|
||||
'no-magic-numbers': ['off', {
|
||||
ignore: [],
|
||||
ignoreArrayIndexes: true,
|
||||
@@ -168,7 +168,7 @@ module.exports = {
|
||||
|
||||
// disallow reassignment of function parameters
|
||||
// disallow parameter object manipulation except for specific exclusions
|
||||
// rule: http://eslint.org/docs/rules/no-param-reassign.html
|
||||
// rule: https://eslint.org/docs/rules/no-param-reassign.html
|
||||
'no-param-reassign': ['error', {
|
||||
props: true,
|
||||
ignorePropertyModificationsFor: [
|
||||
@@ -190,7 +190,7 @@ module.exports = {
|
||||
'no-redeclare': 'error',
|
||||
|
||||
// disallow certain object properties
|
||||
// http://eslint.org/docs/rules/no-restricted-properties
|
||||
// https://eslint.org/docs/rules/no-restricted-properties
|
||||
'no-restricted-properties': ['error', {
|
||||
object: 'arguments',
|
||||
property: 'callee',
|
||||
@@ -241,7 +241,7 @@ module.exports = {
|
||||
'no-script-url': 'error',
|
||||
|
||||
// disallow self assignment
|
||||
// http://eslint.org/docs/rules/no-self-assign
|
||||
// https://eslint.org/docs/rules/no-self-assign
|
||||
'no-self-assign': 'error',
|
||||
|
||||
// disallow comparisons where both sides are exactly the same
|
||||
@@ -254,7 +254,7 @@ module.exports = {
|
||||
'no-throw-literal': 'error',
|
||||
|
||||
// disallow unmodified conditions of loops
|
||||
// http://eslint.org/docs/rules/no-unmodified-loop-condition
|
||||
// https://eslint.org/docs/rules/no-unmodified-loop-condition
|
||||
'no-unmodified-loop-condition': 'off',
|
||||
|
||||
// disallow usage of expressions in statement position
|
||||
@@ -265,26 +265,26 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow unused labels
|
||||
// http://eslint.org/docs/rules/no-unused-labels
|
||||
// https://eslint.org/docs/rules/no-unused-labels
|
||||
'no-unused-labels': 'error',
|
||||
|
||||
// disallow unnecessary .call() and .apply()
|
||||
'no-useless-call': 'off',
|
||||
|
||||
// disallow useless string concatenation
|
||||
// http://eslint.org/docs/rules/no-useless-concat
|
||||
// https://eslint.org/docs/rules/no-useless-concat
|
||||
'no-useless-concat': 'error',
|
||||
|
||||
// disallow unnecessary string escaping
|
||||
// http://eslint.org/docs/rules/no-useless-escape
|
||||
// https://eslint.org/docs/rules/no-useless-escape
|
||||
'no-useless-escape': 'error',
|
||||
|
||||
// disallow redundant return; keywords
|
||||
// http://eslint.org/docs/rules/no-useless-return
|
||||
// https://eslint.org/docs/rules/no-useless-return
|
||||
'no-useless-return': 'error',
|
||||
|
||||
// disallow use of void operator
|
||||
// http://eslint.org/docs/rules/no-void
|
||||
// https://eslint.org/docs/rules/no-void
|
||||
'no-void': 'error',
|
||||
|
||||
// disallow usage of configurable warning terms in comments: e.g. todo
|
||||
@@ -294,21 +294,21 @@ module.exports = {
|
||||
'no-with': 'error',
|
||||
|
||||
// require using Error objects as Promise rejection reasons
|
||||
// http://eslint.org/docs/rules/prefer-promise-reject-errors
|
||||
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
||||
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
|
||||
|
||||
// require use of the second argument for parseInt()
|
||||
radix: 'error',
|
||||
|
||||
// require `await` in `async function` (note: this is a horrible rule that should never be used)
|
||||
// http://eslint.org/docs/rules/require-await
|
||||
// https://eslint.org/docs/rules/require-await
|
||||
'require-await': 'off',
|
||||
|
||||
// requires to declare all vars on top of their containing scope
|
||||
'vars-on-top': 'error',
|
||||
|
||||
// require immediate function invocation to be wrapped in parentheses
|
||||
// http://eslint.org/docs/rules/wrap-iife.html
|
||||
// https://eslint.org/docs/rules/wrap-iife.html
|
||||
'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
|
||||
|
||||
// require or disallow Yoda conditions
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
// Enforce “for” loop update clause moving the counter in the right direction
|
||||
// http://eslint.org/docs/rules/for-direction
|
||||
// https://eslint.org/docs/rules/for-direction
|
||||
'for-direction': 'error',
|
||||
|
||||
// Enforces that a return statement is present in property getters
|
||||
// http://eslint.org/docs/rules/getter-return
|
||||
// https://eslint.org/docs/rules/getter-return
|
||||
'getter-return': ['error', { allowImplicit: true }],
|
||||
|
||||
// Disallow await inside of loops
|
||||
// http://eslint.org/docs/rules/no-await-in-loop
|
||||
// https://eslint.org/docs/rules/no-await-in-loop
|
||||
'no-await-in-loop': 'error',
|
||||
|
||||
// Disallow comparisons to negative zero
|
||||
// http://eslint.org/docs/rules/no-compare-neg-zero
|
||||
// https://eslint.org/docs/rules/no-compare-neg-zero
|
||||
'no-compare-neg-zero': 'error',
|
||||
|
||||
// disallow assignment in conditional expressions
|
||||
@@ -50,11 +50,11 @@ module.exports = {
|
||||
'no-ex-assign': 'error',
|
||||
|
||||
// disallow double-negation boolean casts in a boolean context
|
||||
// http://eslint.org/docs/rules/no-extra-boolean-cast
|
||||
// https://eslint.org/docs/rules/no-extra-boolean-cast
|
||||
'no-extra-boolean-cast': 'error',
|
||||
|
||||
// disallow unnecessary parentheses
|
||||
// http://eslint.org/docs/rules/no-extra-parens
|
||||
// https://eslint.org/docs/rules/no-extra-parens
|
||||
'no-extra-parens': ['off', 'all', {
|
||||
conditionalAssign: true,
|
||||
nestedBinaryExpressions: false,
|
||||
@@ -82,7 +82,7 @@ module.exports = {
|
||||
'no-obj-calls': 'error',
|
||||
|
||||
// disallow use of Object.prototypes builtins directly
|
||||
// http://eslint.org/docs/rules/no-prototype-builtins
|
||||
// https://eslint.org/docs/rules/no-prototype-builtins
|
||||
'no-prototype-builtins': 'error',
|
||||
|
||||
// disallow multiple spaces in a regular expression literal
|
||||
@@ -92,22 +92,22 @@ module.exports = {
|
||||
'no-sparse-arrays': 'error',
|
||||
|
||||
// Disallow template literal placeholder syntax in regular strings
|
||||
// http://eslint.org/docs/rules/no-template-curly-in-string
|
||||
// https://eslint.org/docs/rules/no-template-curly-in-string
|
||||
'no-template-curly-in-string': 'error',
|
||||
|
||||
// Avoid code that looks like two expressions but is actually one
|
||||
// http://eslint.org/docs/rules/no-unexpected-multiline
|
||||
// https://eslint.org/docs/rules/no-unexpected-multiline
|
||||
'no-unexpected-multiline': 'error',
|
||||
|
||||
// disallow unreachable statements after a return, throw, continue, or break statement
|
||||
'no-unreachable': 'error',
|
||||
|
||||
// disallow return/throw/break/continue inside finally blocks
|
||||
// http://eslint.org/docs/rules/no-unsafe-finally
|
||||
// https://eslint.org/docs/rules/no-unsafe-finally
|
||||
'no-unsafe-finally': 'error',
|
||||
|
||||
// disallow negating the left operand of relational operators
|
||||
// http://eslint.org/docs/rules/no-unsafe-negation
|
||||
// https://eslint.org/docs/rules/no-unsafe-negation
|
||||
'no-unsafe-negation': 'error',
|
||||
// disallow negation of the left operand of an in expression
|
||||
// deprecated in favor of no-unsafe-negation
|
||||
@@ -117,11 +117,11 @@ module.exports = {
|
||||
'use-isnan': 'error',
|
||||
|
||||
// ensure JSDoc comments are valid
|
||||
// http://eslint.org/docs/rules/valid-jsdoc
|
||||
// https://eslint.org/docs/rules/valid-jsdoc
|
||||
'valid-jsdoc': 'off',
|
||||
|
||||
// ensure that the results of typeof are compared against a valid string
|
||||
// http://eslint.org/docs/rules/valid-typeof
|
||||
// https://eslint.org/docs/rules/valid-typeof
|
||||
'valid-typeof': ['error', { requireStringLiterals: true }],
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,35 +13,35 @@ module.exports = {
|
||||
|
||||
rules: {
|
||||
// enforces no braces where they can be omitted
|
||||
// http://eslint.org/docs/rules/arrow-body-style
|
||||
// https://eslint.org/docs/rules/arrow-body-style
|
||||
// TODO: enable requireReturnForObjectLiteral?
|
||||
'arrow-body-style': ['error', 'as-needed', {
|
||||
requireReturnForObjectLiteral: false,
|
||||
}],
|
||||
|
||||
// require parens in arrow function arguments
|
||||
// http://eslint.org/docs/rules/arrow-parens
|
||||
// https://eslint.org/docs/rules/arrow-parens
|
||||
'arrow-parens': ['error', 'as-needed', {
|
||||
requireForBlockBody: true,
|
||||
}],
|
||||
|
||||
// require space before/after arrow function's arrow
|
||||
// http://eslint.org/docs/rules/arrow-spacing
|
||||
// https://eslint.org/docs/rules/arrow-spacing
|
||||
'arrow-spacing': ['error', { before: true, after: true }],
|
||||
|
||||
// verify super() callings in constructors
|
||||
'constructor-super': 'error',
|
||||
|
||||
// enforce the spacing around the * in generator functions
|
||||
// http://eslint.org/docs/rules/generator-star-spacing
|
||||
// https://eslint.org/docs/rules/generator-star-spacing
|
||||
'generator-star-spacing': ['error', { before: false, after: true }],
|
||||
|
||||
// disallow modifying variables of class declarations
|
||||
// http://eslint.org/docs/rules/no-class-assign
|
||||
// https://eslint.org/docs/rules/no-class-assign
|
||||
'no-class-assign': 'error',
|
||||
|
||||
// disallow arrow functions where they could be confused with comparisons
|
||||
// http://eslint.org/docs/rules/no-confusing-arrow
|
||||
// https://eslint.org/docs/rules/no-confusing-arrow
|
||||
'no-confusing-arrow': ['error', {
|
||||
allowParens: true,
|
||||
}],
|
||||
@@ -50,36 +50,36 @@ module.exports = {
|
||||
'no-const-assign': 'error',
|
||||
|
||||
// disallow duplicate class members
|
||||
// http://eslint.org/docs/rules/no-dupe-class-members
|
||||
// https://eslint.org/docs/rules/no-dupe-class-members
|
||||
'no-dupe-class-members': 'error',
|
||||
|
||||
// disallow importing from the same path more than once
|
||||
// http://eslint.org/docs/rules/no-duplicate-imports
|
||||
// https://eslint.org/docs/rules/no-duplicate-imports
|
||||
// replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
||||
'no-duplicate-imports': 'off',
|
||||
|
||||
// disallow symbol constructor
|
||||
// http://eslint.org/docs/rules/no-new-symbol
|
||||
// https://eslint.org/docs/rules/no-new-symbol
|
||||
'no-new-symbol': 'error',
|
||||
|
||||
// disallow specific imports
|
||||
// http://eslint.org/docs/rules/no-restricted-imports
|
||||
// https://eslint.org/docs/rules/no-restricted-imports
|
||||
'no-restricted-imports': 'off',
|
||||
|
||||
// disallow to use this/super before super() calling in constructors.
|
||||
// http://eslint.org/docs/rules/no-this-before-super
|
||||
// https://eslint.org/docs/rules/no-this-before-super
|
||||
'no-this-before-super': 'error',
|
||||
|
||||
// disallow useless computed property keys
|
||||
// http://eslint.org/docs/rules/no-useless-computed-key
|
||||
// https://eslint.org/docs/rules/no-useless-computed-key
|
||||
'no-useless-computed-key': 'error',
|
||||
|
||||
// disallow unnecessary constructor
|
||||
// http://eslint.org/docs/rules/no-useless-constructor
|
||||
// https://eslint.org/docs/rules/no-useless-constructor
|
||||
'no-useless-constructor': 'error',
|
||||
|
||||
// disallow renaming import, export, and destructured assignments to the same name
|
||||
// http://eslint.org/docs/rules/no-useless-rename
|
||||
// https://eslint.org/docs/rules/no-useless-rename
|
||||
'no-useless-rename': ['error', {
|
||||
ignoreDestructuring: false,
|
||||
ignoreImport: false,
|
||||
@@ -90,7 +90,7 @@ module.exports = {
|
||||
'no-var': 'error',
|
||||
|
||||
// require method and property shorthand syntax for object literals
|
||||
// http://eslint.org/docs/rules/object-shorthand
|
||||
// https://eslint.org/docs/rules/object-shorthand
|
||||
'object-shorthand': ['error', 'always', {
|
||||
ignoreConstructors: false,
|
||||
avoidQuotes: true,
|
||||
@@ -109,7 +109,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// Prefer destructuring from arrays and objects
|
||||
// http://eslint.org/docs/rules/prefer-destructuring
|
||||
// https://eslint.org/docs/rules/prefer-destructuring
|
||||
'prefer-destructuring': ['error', {
|
||||
VariableDeclarator: {
|
||||
array: false,
|
||||
@@ -124,35 +124,35 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
||||
// http://eslint.org/docs/rules/prefer-numeric-literals
|
||||
// https://eslint.org/docs/rules/prefer-numeric-literals
|
||||
'prefer-numeric-literals': 'error',
|
||||
|
||||
// suggest using Reflect methods where applicable
|
||||
// http://eslint.org/docs/rules/prefer-reflect
|
||||
// https://eslint.org/docs/rules/prefer-reflect
|
||||
'prefer-reflect': 'off',
|
||||
|
||||
// use rest parameters instead of arguments
|
||||
// http://eslint.org/docs/rules/prefer-rest-params
|
||||
// https://eslint.org/docs/rules/prefer-rest-params
|
||||
'prefer-rest-params': 'error',
|
||||
|
||||
// suggest using the spread operator instead of .apply()
|
||||
// http://eslint.org/docs/rules/prefer-spread
|
||||
// https://eslint.org/docs/rules/prefer-spread
|
||||
'prefer-spread': 'error',
|
||||
|
||||
// suggest using template literals instead of string concatenation
|
||||
// http://eslint.org/docs/rules/prefer-template
|
||||
// https://eslint.org/docs/rules/prefer-template
|
||||
'prefer-template': 'error',
|
||||
|
||||
// disallow generator functions that do not have yield
|
||||
// http://eslint.org/docs/rules/require-yield
|
||||
// https://eslint.org/docs/rules/require-yield
|
||||
'require-yield': 'error',
|
||||
|
||||
// enforce spacing between object rest-spread
|
||||
// http://eslint.org/docs/rules/rest-spread-spacing
|
||||
// https://eslint.org/docs/rules/rest-spread-spacing
|
||||
'rest-spread-spacing': ['error', 'never'],
|
||||
|
||||
// import sorting
|
||||
// http://eslint.org/docs/rules/sort-imports
|
||||
// https://eslint.org/docs/rules/sort-imports
|
||||
'sort-imports': ['off', {
|
||||
ignoreCase: false,
|
||||
ignoreMemberSort: false,
|
||||
@@ -160,15 +160,15 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// require a Symbol description
|
||||
// http://eslint.org/docs/rules/symbol-description
|
||||
// https://eslint.org/docs/rules/symbol-description
|
||||
'symbol-description': 'error',
|
||||
|
||||
// enforce usage of spacing in template strings
|
||||
// http://eslint.org/docs/rules/template-curly-spacing
|
||||
// https://eslint.org/docs/rules/template-curly-spacing
|
||||
'template-curly-spacing': 'error',
|
||||
|
||||
// enforce spacing around the * in yield* expressions
|
||||
// http://eslint.org/docs/rules/yield-star-spacing
|
||||
// https://eslint.org/docs/rules/yield-star-spacing
|
||||
'yield-star-spacing': ['error', 'after']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,14 +8,14 @@ module.exports = {
|
||||
'callback-return': 'off',
|
||||
|
||||
// require all requires be top-level
|
||||
// http://eslint.org/docs/rules/global-require
|
||||
// https://eslint.org/docs/rules/global-require
|
||||
'global-require': 'error',
|
||||
|
||||
// enforces error handling in callbacks (node environment)
|
||||
'handle-callback-err': 'off',
|
||||
|
||||
// disallow use of the Buffer() constructor
|
||||
// http://eslint.org/docs/rules/no-buffer-constructor
|
||||
// https://eslint.org/docs/rules/no-buffer-constructor
|
||||
'no-buffer-constructor': 'error',
|
||||
|
||||
// disallow mixing regular variable and require declarations
|
||||
@@ -25,7 +25,7 @@ module.exports = {
|
||||
'no-new-require': 'error',
|
||||
|
||||
// disallow string concatenation with __dirname and __filename
|
||||
// http://eslint.org/docs/rules/no-path-concat
|
||||
// https://eslint.org/docs/rules/no-path-concat
|
||||
'no-path-concat': 'error',
|
||||
|
||||
// disallow use of process.env
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
// enforce line breaks after opening and before closing array brackets
|
||||
// http://eslint.org/docs/rules/array-bracket-newline
|
||||
// https://eslint.org/docs/rules/array-bracket-newline
|
||||
// TODO: enable? semver-major
|
||||
'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 }
|
||||
|
||||
// enforce line breaks between array elements
|
||||
// http://eslint.org/docs/rules/array-element-newline
|
||||
// https://eslint.org/docs/rules/array-element-newline
|
||||
// TODO: enable? semver-major
|
||||
'array-element-newline': ['off', { multiline: true, minItems: 3 }],
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
|
||||
// enforce spacing inside single-line blocks
|
||||
// http://eslint.org/docs/rules/block-spacing
|
||||
// https://eslint.org/docs/rules/block-spacing
|
||||
'block-spacing': ['error', 'always'],
|
||||
|
||||
// enforce one true brace style
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
camelcase: ['error', { properties: 'never' }],
|
||||
|
||||
// enforce or disallow capitalization of the first letter of a comment
|
||||
// http://eslint.org/docs/rules/capitalized-comments
|
||||
// https://eslint.org/docs/rules/capitalized-comments
|
||||
'capitalized-comments': ['off', 'never', {
|
||||
line: {
|
||||
ignorePattern: '.*',
|
||||
@@ -63,22 +63,22 @@ module.exports = {
|
||||
'eol-last': ['error', 'always'],
|
||||
|
||||
// enforce spacing between functions and their invocations
|
||||
// http://eslint.org/docs/rules/func-call-spacing
|
||||
// https://eslint.org/docs/rules/func-call-spacing
|
||||
'func-call-spacing': ['error', 'never'],
|
||||
|
||||
// requires function names to match the name of the variable or property to which they are
|
||||
// assigned
|
||||
// http://eslint.org/docs/rules/func-name-matching
|
||||
// https://eslint.org/docs/rules/func-name-matching
|
||||
'func-name-matching': ['off', 'always', {
|
||||
includeCommonJSModuleExports: false
|
||||
}],
|
||||
|
||||
// require function expressions to have a name
|
||||
// http://eslint.org/docs/rules/func-names
|
||||
// https://eslint.org/docs/rules/func-names
|
||||
'func-names': 'warn',
|
||||
|
||||
// enforces use of function declarations or expressions
|
||||
// http://eslint.org/docs/rules/func-style
|
||||
// https://eslint.org/docs/rules/func-style
|
||||
// TODO: enable
|
||||
'func-style': ['off', 'expression'],
|
||||
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
'function-paren-newline': ['error', 'multiline'],
|
||||
|
||||
// Blacklist certain identifiers to prevent them being used
|
||||
// http://eslint.org/docs/rules/id-blacklist
|
||||
// https://eslint.org/docs/rules/id-blacklist
|
||||
'id-blacklist': 'off',
|
||||
|
||||
// this option enforces minimum and maximum identifier lengths
|
||||
@@ -98,7 +98,7 @@ module.exports = {
|
||||
'id-match': 'off',
|
||||
|
||||
// this option sets a specific tab width for your code
|
||||
// http://eslint.org/docs/rules/indent
|
||||
// https://eslint.org/docs/rules/indent
|
||||
indent: ['error', 2, {
|
||||
SwitchCase: 1,
|
||||
VariableDeclarator: 1,
|
||||
@@ -123,7 +123,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// specify whether double or single quotes should be used in JSX attributes
|
||||
// http://eslint.org/docs/rules/jsx-quotes
|
||||
// https://eslint.org/docs/rules/jsx-quotes
|
||||
'jsx-quotes': ['off', 'prefer-double'],
|
||||
|
||||
// enforces spacing between keys and values in object literal properties
|
||||
@@ -141,7 +141,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// enforce position of line comments
|
||||
// http://eslint.org/docs/rules/line-comment-position
|
||||
// https://eslint.org/docs/rules/line-comment-position
|
||||
// TODO: enable?
|
||||
'line-comment-position': ['off', {
|
||||
position: 'above',
|
||||
@@ -150,7 +150,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow mixed 'LF' and 'CRLF' as linebreaks
|
||||
// http://eslint.org/docs/rules/linebreak-style
|
||||
// https://eslint.org/docs/rules/linebreak-style
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
|
||||
// require or disallow an empty line between class members
|
||||
@@ -161,7 +161,7 @@ module.exports = {
|
||||
'lines-around-comment': 'off',
|
||||
|
||||
// require or disallow newlines around directives
|
||||
// http://eslint.org/docs/rules/lines-around-directive
|
||||
// https://eslint.org/docs/rules/lines-around-directive
|
||||
'lines-around-directive': ['error', {
|
||||
before: 'always',
|
||||
after: 'always',
|
||||
@@ -171,7 +171,7 @@ module.exports = {
|
||||
'max-depth': ['off', 4],
|
||||
|
||||
// specify the maximum length of a line in your program
|
||||
// http://eslint.org/docs/rules/max-len
|
||||
// https://eslint.org/docs/rules/max-len
|
||||
'max-len': ['error', 100, 2, {
|
||||
ignoreUrls: true,
|
||||
ignoreComments: false,
|
||||
@@ -181,7 +181,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// specify the max number of lines in a file
|
||||
// http://eslint.org/docs/rules/max-lines
|
||||
// https://eslint.org/docs/rules/max-lines
|
||||
'max-lines': ['off', {
|
||||
max: 300,
|
||||
skipBlankLines: true,
|
||||
@@ -198,7 +198,7 @@ module.exports = {
|
||||
'max-statements': ['off', 10],
|
||||
|
||||
// restrict the number of statements per line
|
||||
// http://eslint.org/docs/rules/max-statements-per-line
|
||||
// https://eslint.org/docs/rules/max-statements-per-line
|
||||
'max-statements-per-line': ['off', { max: 1 }],
|
||||
|
||||
// enforce a particular style for multiline comments
|
||||
@@ -206,7 +206,7 @@ module.exports = {
|
||||
'multiline-comment-style': ['off', 'starred-block'],
|
||||
|
||||
// require multiline ternary
|
||||
// http://eslint.org/docs/rules/multiline-ternary
|
||||
// https://eslint.org/docs/rules/multiline-ternary
|
||||
// TODO: enable?
|
||||
'multiline-ternary': ['off', 'never'],
|
||||
|
||||
@@ -219,40 +219,40 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow the omission of parentheses when invoking a constructor with no arguments
|
||||
// http://eslint.org/docs/rules/new-parens
|
||||
// https://eslint.org/docs/rules/new-parens
|
||||
'new-parens': 'error',
|
||||
|
||||
// allow/disallow an empty newline after var statement
|
||||
'newline-after-var': 'off',
|
||||
|
||||
// http://eslint.org/docs/rules/newline-before-return
|
||||
// https://eslint.org/docs/rules/newline-before-return
|
||||
'newline-before-return': 'off',
|
||||
|
||||
// enforces new line after each method call in the chain to make it
|
||||
// more readable and easy to maintain
|
||||
// http://eslint.org/docs/rules/newline-per-chained-call
|
||||
// https://eslint.org/docs/rules/newline-per-chained-call
|
||||
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
|
||||
|
||||
// disallow use of the Array constructor
|
||||
'no-array-constructor': 'error',
|
||||
|
||||
// disallow use of bitwise operators
|
||||
// http://eslint.org/docs/rules/no-bitwise
|
||||
// https://eslint.org/docs/rules/no-bitwise
|
||||
'no-bitwise': 'error',
|
||||
|
||||
// disallow use of the continue statement
|
||||
// http://eslint.org/docs/rules/no-continue
|
||||
// https://eslint.org/docs/rules/no-continue
|
||||
'no-continue': 'error',
|
||||
|
||||
// disallow comments inline after code
|
||||
'no-inline-comments': 'off',
|
||||
|
||||
// disallow if as the only statement in an else block
|
||||
// http://eslint.org/docs/rules/no-lonely-if
|
||||
// https://eslint.org/docs/rules/no-lonely-if
|
||||
'no-lonely-if': 'error',
|
||||
|
||||
// disallow un-paren'd mixes of different operators
|
||||
// http://eslint.org/docs/rules/no-mixed-operators
|
||||
// https://eslint.org/docs/rules/no-mixed-operators
|
||||
'no-mixed-operators': ['error', {
|
||||
// the list of arthmetic groups disallows mixing `%` and `**`
|
||||
// with other arithmetic operators.
|
||||
@@ -278,14 +278,14 @@ module.exports = {
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
|
||||
// disallow use of chained assignment expressions
|
||||
// http://eslint.org/docs/rules/no-multi-assign
|
||||
// https://eslint.org/docs/rules/no-multi-assign
|
||||
'no-multi-assign': ['error'],
|
||||
|
||||
// disallow multiple empty lines and only one newline at the end
|
||||
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
|
||||
|
||||
// disallow negated conditions
|
||||
// http://eslint.org/docs/rules/no-negated-condition
|
||||
// https://eslint.org/docs/rules/no-negated-condition
|
||||
'no-negated-condition': 'off',
|
||||
|
||||
// disallow nested ternary expressions
|
||||
@@ -295,11 +295,11 @@ module.exports = {
|
||||
'no-new-object': 'error',
|
||||
|
||||
// disallow use of unary operators, ++ and --
|
||||
// http://eslint.org/docs/rules/no-plusplus
|
||||
// https://eslint.org/docs/rules/no-plusplus
|
||||
'no-plusplus': 'error',
|
||||
|
||||
// disallow certain syntax forms
|
||||
// http://eslint.org/docs/rules/no-restricted-syntax
|
||||
// https://eslint.org/docs/rules/no-restricted-syntax
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
{
|
||||
@@ -345,29 +345,29 @@ module.exports = {
|
||||
|
||||
// disallow the use of Boolean literals in conditional expressions
|
||||
// also, prefer `a || b` over `a ? a : b`
|
||||
// http://eslint.org/docs/rules/no-unneeded-ternary
|
||||
// https://eslint.org/docs/rules/no-unneeded-ternary
|
||||
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
||||
|
||||
// disallow whitespace before properties
|
||||
// http://eslint.org/docs/rules/no-whitespace-before-property
|
||||
// https://eslint.org/docs/rules/no-whitespace-before-property
|
||||
'no-whitespace-before-property': 'error',
|
||||
|
||||
// enforce the location of single-line statements
|
||||
// http://eslint.org/docs/rules/nonblock-statement-body-position
|
||||
// https://eslint.org/docs/rules/nonblock-statement-body-position
|
||||
'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
|
||||
|
||||
// require padding inside curly braces
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
|
||||
// enforce line breaks between braces
|
||||
// http://eslint.org/docs/rules/object-curly-newline
|
||||
// https://eslint.org/docs/rules/object-curly-newline
|
||||
'object-curly-newline': ['error', {
|
||||
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
|
||||
ObjectPattern: { minProperties: 4, multiline: true, consistent: true }
|
||||
}],
|
||||
|
||||
// enforce "same line" or "multiple line" on object properties.
|
||||
// http://eslint.org/docs/rules/object-property-newline
|
||||
// https://eslint.org/docs/rules/object-property-newline
|
||||
'object-property-newline': ['error', {
|
||||
allowMultiplePropertiesPerLine: true,
|
||||
}],
|
||||
@@ -376,11 +376,11 @@ module.exports = {
|
||||
'one-var': ['error', 'never'],
|
||||
|
||||
// require a newline around variable declaration
|
||||
// http://eslint.org/docs/rules/one-var-declaration-per-line
|
||||
// https://eslint.org/docs/rules/one-var-declaration-per-line
|
||||
'one-var-declaration-per-line': ['error', 'always'],
|
||||
|
||||
// require assignment operator shorthand where possible or prohibit it entirely
|
||||
// http://eslint.org/docs/rules/operator-assignment
|
||||
// https://eslint.org/docs/rules/operator-assignment
|
||||
'operator-assignment': ['error', 'always'],
|
||||
|
||||
// Requires operator at the beginning of the line in multiline statements
|
||||
@@ -391,18 +391,18 @@ module.exports = {
|
||||
'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }],
|
||||
|
||||
// Require or disallow padding lines between statements
|
||||
// http://eslint.org/docs/rules/padding-line-between-statements
|
||||
// https://eslint.org/docs/rules/padding-line-between-statements
|
||||
'padding-line-between-statements': 'off',
|
||||
|
||||
// require quotes around object literal property names
|
||||
// http://eslint.org/docs/rules/quote-props.html
|
||||
// https://eslint.org/docs/rules/quote-props.html
|
||||
'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
|
||||
|
||||
// specify whether double or single quotes should be used
|
||||
quotes: ['error', 'single', { avoidEscape: true }],
|
||||
|
||||
// do not require jsdoc
|
||||
// http://eslint.org/docs/rules/require-jsdoc
|
||||
// https://eslint.org/docs/rules/require-jsdoc
|
||||
'require-jsdoc': 'off',
|
||||
|
||||
// require or disallow use of semicolons instead of ASI
|
||||
@@ -412,7 +412,7 @@ module.exports = {
|
||||
'semi-spacing': ['error', { before: false, after: true }],
|
||||
|
||||
// Enforce location of semicolons
|
||||
// http://eslint.org/docs/rules/semi-style
|
||||
// https://eslint.org/docs/rules/semi-style
|
||||
'semi-style': ['error', 'last'],
|
||||
|
||||
// requires object keys to be sorted
|
||||
@@ -425,7 +425,7 @@ module.exports = {
|
||||
'space-before-blocks': 'error',
|
||||
|
||||
// require or disallow space before function opening parenthesis
|
||||
// http://eslint.org/docs/rules/space-before-function-paren
|
||||
// https://eslint.org/docs/rules/space-before-function-paren
|
||||
'space-before-function-paren': ['error', {
|
||||
anonymous: 'always',
|
||||
named: 'never',
|
||||
@@ -439,7 +439,7 @@ module.exports = {
|
||||
'space-infix-ops': 'error',
|
||||
|
||||
// Require or disallow spaces before/after unary operators
|
||||
// http://eslint.org/docs/rules/space-unary-ops
|
||||
// https://eslint.org/docs/rules/space-unary-ops
|
||||
'space-unary-ops': ['error', {
|
||||
words: true,
|
||||
nonwords: false,
|
||||
@@ -448,7 +448,7 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// require or disallow a space immediately following the // or /* in a comment
|
||||
// http://eslint.org/docs/rules/spaced-comment
|
||||
// https://eslint.org/docs/rules/spaced-comment
|
||||
'spaced-comment': ['error', 'always', {
|
||||
line: {
|
||||
exceptions: ['-', '+'],
|
||||
@@ -462,15 +462,15 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// Enforce spacing around colons of switch statements
|
||||
// http://eslint.org/docs/rules/switch-colon-spacing
|
||||
// https://eslint.org/docs/rules/switch-colon-spacing
|
||||
'switch-colon-spacing': ['error', { after: true, before: false }],
|
||||
|
||||
// Require or disallow spacing between template tags and their literals
|
||||
// http://eslint.org/docs/rules/template-tag-spacing
|
||||
// https://eslint.org/docs/rules/template-tag-spacing
|
||||
'template-tag-spacing': ['error', 'never'],
|
||||
|
||||
// require or disallow the Unicode Byte Order Mark
|
||||
// http://eslint.org/docs/rules/unicode-bom
|
||||
// https://eslint.org/docs/rules/unicode-bom
|
||||
'unicode-bom': ['error', 'never'],
|
||||
|
||||
// require regex literals to be wrapped in parentheses
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = {
|
||||
'no-delete-var': 'error',
|
||||
|
||||
// disallow labels that share a name with a variable
|
||||
// http://eslint.org/docs/rules/no-label-var
|
||||
// https://eslint.org/docs/rules/no-label-var
|
||||
'no-label-var': 'error',
|
||||
|
||||
// disallow specific globals
|
||||
@@ -31,7 +31,7 @@ module.exports = {
|
||||
'no-undef-init': 'error',
|
||||
|
||||
// disallow use of undefined variable
|
||||
// http://eslint.org/docs/rules/no-undefined
|
||||
// https://eslint.org/docs/rules/no-undefined
|
||||
// TODO: enable?
|
||||
'no-undefined': 'off',
|
||||
|
||||
|
||||
@@ -308,36 +308,36 @@
|
||||
[pr-modular]: https://github.com/airbnb/javascript/pull/526
|
||||
[pr-legacy]: https://github.com/airbnb/javascript/pull/527
|
||||
|
||||
[array-bracket-spacing]: http://eslint.org/docs/rules/array-bracket-spacing
|
||||
[array-callback-return]: http://eslint.org/docs/rules/array-callback-return
|
||||
[arrow-body-style]: http://eslint.org/docs/rules/arrow-body-style
|
||||
[arrow-spacing]: http://eslint.org/docs/rules/arrow-spacing
|
||||
[computed-property-spacing]: http://eslint.org/docs/rules/computed-property-spacing
|
||||
[id-length]: http://eslint.org/docs/rules/id-length
|
||||
[indent]: http://eslint.org/docs/rules/indent
|
||||
[max-len]: http://eslint.org/docs/rules/max-len
|
||||
[newline-per-chained-call]: http://eslint.org/docs/rules/newline-per-chained-call
|
||||
[no-confusing-arrow]: http://eslint.org/docs/rules/no-confusing-arrow
|
||||
[no-const-assign]: http://eslint.org/docs/rules/no-const-assign
|
||||
[no-mixed-spaces-and-tabs]: http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
|
||||
[no-multiple-empty-lines]: http://eslint.org/docs/rules/no-multiple-empty-lines
|
||||
[no-new-symbol]: http://eslint.org/docs/rules/no-new-symbol
|
||||
[no-restricted-imports]: http://eslint.org/docs/rules/no-restricted-imports
|
||||
[no-self-assign]: http://eslint.org/docs/rules/no-self-assign
|
||||
[no-undef]: http://eslint.org/docs/rules/no-undef
|
||||
[no-useless-constructor]: http://eslint.org/docs/rules/no-useless-constructor
|
||||
[no-whitespace-before-property]: http://eslint.org/docs/rules/no-whitespace-before-property
|
||||
[object-curly-spacing]: http://eslint.org/docs/rules/object-curly-spacing
|
||||
[object-shorthand]: http://eslint.org/docs/rules/object-shorthand
|
||||
[one-var-declaration-per-line]: http://eslint.org/docs/rules/one-var-declaration-per-line
|
||||
[prefer-arrow-callback]: http://eslint.org/docs/rules/prefer-arrow-callback
|
||||
[prefer-rest-params]: http://eslint.org/docs/rules/prefer-rest-params
|
||||
[prefer-template]: http://eslint.org/docs/rules/prefer-template
|
||||
[quote-props]: http://eslint.org/docs/rules/quote-props
|
||||
[space-before-function-paren]: http://eslint.org/docs/rules/space-before-function-paren
|
||||
[space-before-keywords]: http://eslint.org/docs/rules/space-before-keywords
|
||||
[space-in-parens]: http://eslint.org/docs/rules/space-in-parens
|
||||
[template-curly-spacing]: http://eslint.org/docs/rules/template-curly-spacing
|
||||
[array-bracket-spacing]: https://eslint.org/docs/rules/array-bracket-spacing
|
||||
[array-callback-return]: https://eslint.org/docs/rules/array-callback-return
|
||||
[arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
|
||||
[arrow-spacing]: https://eslint.org/docs/rules/arrow-spacing
|
||||
[computed-property-spacing]: https://eslint.org/docs/rules/computed-property-spacing
|
||||
[id-length]: https://eslint.org/docs/rules/id-length
|
||||
[indent]: https://eslint.org/docs/rules/indent
|
||||
[max-len]: https://eslint.org/docs/rules/max-len
|
||||
[newline-per-chained-call]: https://eslint.org/docs/rules/newline-per-chained-call
|
||||
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
|
||||
[no-const-assign]: https://eslint.org/docs/rules/no-const-assign
|
||||
[no-mixed-spaces-and-tabs]: https://eslint.org/docs/rules/no-mixed-spaces-and-tabs
|
||||
[no-multiple-empty-lines]: https://eslint.org/docs/rules/no-multiple-empty-lines
|
||||
[no-new-symbol]: https://eslint.org/docs/rules/no-new-symbol
|
||||
[no-restricted-imports]: https://eslint.org/docs/rules/no-restricted-imports
|
||||
[no-self-assign]: https://eslint.org/docs/rules/no-self-assign
|
||||
[no-undef]: https://eslint.org/docs/rules/no-undef
|
||||
[no-useless-constructor]: https://eslint.org/docs/rules/no-useless-constructor
|
||||
[no-whitespace-before-property]: https://eslint.org/docs/rules/no-whitespace-before-property
|
||||
[object-curly-spacing]: https://eslint.org/docs/rules/object-curly-spacing
|
||||
[object-shorthand]: https://eslint.org/docs/rules/object-shorthand
|
||||
[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
|
||||
[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
|
||||
[prefer-rest-params]: https://eslint.org/docs/rules/prefer-rest-params
|
||||
[prefer-template]: https://eslint.org/docs/rules/prefer-template
|
||||
[quote-props]: https://eslint.org/docs/rules/quote-props
|
||||
[space-before-function-paren]: https://eslint.org/docs/rules/space-before-function-paren
|
||||
[space-before-keywords]: https://eslint.org/docs/rules/space-before-keywords
|
||||
[space-in-parens]: https://eslint.org/docs/rules/space-in-parens
|
||||
[template-curly-spacing]: https://eslint.org/docs/rules/template-curly-spacing
|
||||
|
||||
[react/jsx-space-before-closing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
|
||||
[react/sort-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
||||
|
||||
@@ -59,7 +59,7 @@ This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.co
|
||||
This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).
|
||||
|
||||
See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and
|
||||
the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files)
|
||||
the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files)
|
||||
for more information.
|
||||
|
||||
## Improving this config
|
||||
|
||||
2
packages/eslint-config-airbnb/rules/react.js
vendored
2
packages/eslint-config-airbnb/rules/react.js
vendored
@@ -13,7 +13,7 @@ module.exports = {
|
||||
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
|
||||
rules: {
|
||||
// Specify whether double or single quotes should be used in JSX attributes
|
||||
// http://eslint.org/docs/rules/jsx-quotes
|
||||
// https://eslint.org/docs/rules/jsx-quotes
|
||||
'jsx-quotes': ['error', 'prefer-double'],
|
||||
|
||||
'class-methods-use-this': ['error', {
|
||||
|
||||
@@ -17,8 +17,8 @@ const cli = new CLIEngine({
|
||||
});
|
||||
|
||||
function lint(text) {
|
||||
// @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles
|
||||
// @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeontext
|
||||
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles
|
||||
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext
|
||||
const linter = cli.executeOnText(text);
|
||||
return linter.results[0];
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
|
||||
## Quotes
|
||||
|
||||
- Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes)
|
||||
- Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](https://eslint.org/docs/rules/jsx-quotes)
|
||||
|
||||
> Why? Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
|
||||
## Spacing
|
||||
|
||||
- Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](http://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md)
|
||||
- Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md)
|
||||
|
||||
```jsx
|
||||
// bad
|
||||
|
||||
Reference in New Issue
Block a user