From 31d95fded451b31695d9cc09abc117edcea4969d Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 4 Apr 2018 16:23:02 -0700 Subject: [PATCH 001/372] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- packages/eslint-config-airbnb-base/rules/imports.js | 5 +++++ packages/eslint-config-airbnb/package.json | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index e9a6589bd0..2c3d49bd21 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -52,16 +52,16 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.1", - "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-find-rules": "^3.2.2", + "eslint-plugin-import": "^2.10.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.18.1", - "eslint-plugin-import": "^2.9.0" + "eslint": "^4.19.1", + "eslint-plugin-import": "^2.10.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index a34e7f2524..3c76a5aa3d 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -226,6 +226,11 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 'import/no-self-import': 'error', + // Forbid cyclical dependencies between modules + // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md + // TODO: enable, semver-major + 'import/no-cycle': ['off', { maxDepth: Infinity }], + // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 'import/no-useless-path-segments': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index df135d545a..dfaadad2ad 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -57,9 +57,9 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.1", - "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-find-rules": "^3.2.2", + "eslint-plugin-import": "^2.10.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", @@ -68,8 +68,8 @@ "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.18.1", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-plugin-import": "^2.10.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0" }, From c71e8c9231394ef9489cacf6cbf1ea9dd63b1b32 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 4 Apr 2018 16:15:27 -0700 Subject: [PATCH 002/372] [eslint config] [base] [breaking] enable `import/no-cycle`: warn on cyclical dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 3c76a5aa3d..1ea95697c9 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -228,8 +228,7 @@ module.exports = { // Forbid cyclical dependencies between modules // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md - // TODO: enable, semver-major - 'import/no-cycle': ['off', { maxDepth: Infinity }], + 'import/no-cycle': ['error', { maxDepth: Infinity }], // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 From bd97fca21b99b542d9ef9eebec78198d6bb5fde0 Mon Sep 17 00:00:00 2001 From: Pramod Garg Date: Wed, 4 Apr 2018 22:45:44 +0530 Subject: [PATCH 003/372] [guide] Minor addition of spaces --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49f554e2cf..b0093efe40 100644 --- a/README.md +++ b/README.md @@ -2106,7 +2106,7 @@ Other Style Guides } } - //good + // good function dogs(x) { if (x) { if (z) { @@ -2267,7 +2267,7 @@ Other Style Guides ```javascript // bad - //is current tab + // is current tab const active = true; // good From 8720f5f90bbe4aaf87e03d81b3b4f607f27ff6c6 Mon Sep 17 00:00:00 2001 From: "C. T. Lin" Date: Wed, 28 Mar 2018 13:05:12 +0800 Subject: [PATCH 004/372] [eslint config] [base] [patch] avoid `__mocks__` `no-extraneous-dependencies` check --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 1ea95697c9..04455c97fb 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -74,6 +74,7 @@ module.exports = { 'tests/**', // also common npm pattern 'spec/**', // mocha, rspec-like pattern '**/__tests__/**', // jest pattern + '**/__mocks__/**', // jest pattern 'test.{js,jsx}', // repos with a single test file 'test-*.{js,jsx}', // repos with multiple top-level test files '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test From 06998522e1f4935f81f732c458d2cc72dde2cac9 Mon Sep 17 00:00:00 2001 From: Hernaldo Jesus Henriquez Date: Fri, 6 Apr 2018 14:53:46 -0300 Subject: [PATCH 005/372] [guide] fix "bad" comment to be actually bad --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0093efe40..6a58c28480 100644 --- a/README.md +++ b/README.md @@ -2267,7 +2267,7 @@ Other Style Guides ```javascript // bad - // is current tab + //is current tab const active = true; // good From 8956338ee95087ab2da99b368d00ff482e77df3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=87etinay?= Date: Sun, 8 Apr 2018 22:51:19 +0300 Subject: [PATCH 006/372] [guide] Turkish Translation Link Added --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a58c28480..57ca65ed4e 100644 --- a/README.md +++ b/README.md @@ -3654,6 +3654,7 @@ Other Style Guides - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) + - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) From 6088a8f5b503c4e383552cbb6ae36d3fa4c6e7b1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Apr 2018 15:46:55 -0700 Subject: [PATCH 007/372] [guide] remove references to jscs --- README.md | 71 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 57ca65ed4e..ed54520555 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Other Style Guides ``` - - [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) + - [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) > Why? `let` is block-scoped rather than function-scoped like `var`. @@ -192,7 +192,7 @@ Other Style Guides ``` - - [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) + - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) ```javascript // bad @@ -215,7 +215,7 @@ Other Style Guides ``` - - [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) + - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) > Why? It is shorter to write and descriptive. @@ -264,7 +264,7 @@ Other Style Guides ``` - - [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) + - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html) > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. @@ -482,7 +482,7 @@ Other Style Guides ## Destructuring - - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring) + - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) > Why? Destructuring saves you from creating temporary references for those properties. @@ -508,7 +508,7 @@ Other Style Guides ``` - - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring) + - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) ```javascript const arr = [1, 2, 3, 4]; @@ -522,7 +522,7 @@ Other Style Guides ``` - - [5.3](#destructuring--object-over-array) Use object destructuring for multiple return values, not array destructuring. jscs: [`disallowArrayDestructuringReturn`](http://jscs.info/rule/disallowArrayDestructuringReturn) + - [5.3](#destructuring--object-over-array) Use object destructuring for multiple return values, not array destructuring. > Why? You can add new properties over time or change the order of things without breaking call sites. @@ -551,7 +551,7 @@ Other Style Guides ## Strings - - [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) + - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) ```javascript // bad @@ -586,7 +586,7 @@ Other Style Guides ``` - - [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) + - [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) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -634,7 +634,7 @@ Other Style Guides ## Functions - - [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) + - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style) > 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)) @@ -657,7 +657,7 @@ Other Style Guides ``` - - [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) + - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html) > 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. @@ -916,7 +916,7 @@ Other Style Guides ## Arrow Functions - - [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) + - [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) > 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. @@ -937,7 +937,7 @@ Other Style Guides ``` - - [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) + - [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) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -1004,7 +1004,7 @@ Other Style Guides ``` - - [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) + - [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. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) > Why? Less visual clutter. @@ -1491,7 +1491,7 @@ Other Style Guides ## Properties - - [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) + - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) ```javascript const luke = { @@ -1548,7 +1548,7 @@ Other Style Guides ``` - - [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) + - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html) > 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. @@ -2032,7 +2032,7 @@ Other Style Guides ``` - - [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) + - [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) ```javascript // bad @@ -2335,7 +2335,7 @@ Other Style Guides ## Whitespace - - [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) + - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) ```javascript // bad @@ -2355,7 +2355,7 @@ Other Style Guides ``` - - [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) + - [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) ```javascript // bad @@ -2382,7 +2382,7 @@ Other Style Guides ``` - - [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) + - [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) ```javascript // bad @@ -2407,7 +2407,7 @@ Other Style Guides ``` - - [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) + - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) ```javascript // bad @@ -2487,7 +2487,7 @@ Other Style Guides ``` - - [19.7](#whitespace--after-blocks) Leave a blank line after blocks and before the next statement. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks) + - [19.7](#whitespace--after-blocks) Leave a blank line after blocks and before the next statement. ```javascript // bad @@ -2545,7 +2545,7 @@ Other Style Guides ``` - - [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) + - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) ```javascript // bad @@ -2586,7 +2586,7 @@ Other Style Guides ``` - - [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) + - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) ```javascript // bad @@ -2611,7 +2611,7 @@ Other Style Guides ``` - - [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) + - [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) ```javascript // bad @@ -2624,7 +2624,7 @@ Other Style Guides ``` - - [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) + - [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) ```javascript // bad @@ -2635,7 +2635,7 @@ Other Style Guides ``` - - [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) + - [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) > Why? This ensures readability and maintainability. @@ -2669,7 +2669,7 @@ Other Style Guides ## Commas - - [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) + - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) ```javascript // bad @@ -2704,7 +2704,7 @@ Other Style Guides ``` - - [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) + - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle.html) > 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. @@ -2804,7 +2804,7 @@ Other Style Guides ## Semicolons - - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://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) > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether or not it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. @@ -2958,7 +2958,7 @@ Other Style Guides ``` - - [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) + - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) ```javascript // bad @@ -2972,7 +2972,7 @@ Other Style Guides ``` - - [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) + - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) ```javascript // bad @@ -2997,7 +2997,7 @@ Other Style Guides ``` - - [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) + - [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) > 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. @@ -3017,7 +3017,7 @@ Other Style Guides ``` - - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) + - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). ```javascript // bad @@ -3282,7 +3282,7 @@ Other Style Guides ## jQuery - - [26.1](#jquery--dollar-prefix) Prefix jQuery object variables with a `$`. jscs: [`requireDollarBeforejQueryAssignment`](http://jscs.info/rule/requireDollarBeforejQueryAssignment) + - [26.1](#jquery--dollar-prefix) Prefix jQuery object variables with a `$`. ```javascript // bad @@ -3477,7 +3477,6 @@ Other Style Guides - Code Style Linters - [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/) **Other Style Guides** From 308fb24815a62c98aa4e89aae1bad0744dab3a92 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 13 Apr 2018 13:43:43 -0700 Subject: [PATCH 008/372] [eslint config] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2c3d49bd21..7739f54005 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -54,14 +54,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.10.0" + "eslint-plugin-import": "^2.11.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index dfaadad2ad..bc80fdd060 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,7 +59,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", @@ -69,7 +69,7 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0" }, From 87f97e042ddb94d87950be7c483b4aa4e391e2c2 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Wed, 18 Apr 2018 11:28:06 -0700 Subject: [PATCH 009/372] Replace flag images with emoji We can use emoji for most of these flags, which should make them look better on higher resolution displays and improve the loading performance of the style guide a little. The only flag we have here that does not have a good emoji yet is the flag of Catalonia, which I left as-is for now. https://emojipedia.org/flag-for-catalonia-esct/ --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ed54520555..3ca74e2606 100644 --- a/README.md +++ b/README.md @@ -3640,22 +3640,22 @@ Other Style Guides This style guide is also available in other languages: - - ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) - - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) + - 🇧🇷 **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) + - 🇧🇬 **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) - - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) - - ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) - - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) - - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) + - 🇨🇳 **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) + - 🇹🇼 **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) + - 🇫🇷 **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) + - 🇩🇪 **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) + - 🇮🇹 **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) + - 🇯🇵 **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) + - 🇰🇷 **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) + - 🇷🇺 **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) + - 🇪🇸 **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) + - 🇹🇭 **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) + - 🇹🇷 **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) + - 🇺🇦 **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) + - 🇻🇳 **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) ## The JavaScript Style Guide Guide From b56875bee21eb8d87213c787dc105c288066f43e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Apr 2018 14:00:50 -0700 Subject: [PATCH 010/372] [eslint config] [base] [patch] `function-paren-newline`: change to "consistent" --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 12cd60d509..0f58957211 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -98,7 +98,7 @@ module.exports = { // enforce consistent line breaks inside function parentheses // https://eslint.org/docs/rules/function-paren-newline - 'function-paren-newline': ['error', 'multiline'], + 'function-paren-newline': ['error', 'consistent'], // Blacklist certain identifiers to prevent them being used // https://eslint.org/docs/rules/id-blacklist From fd0834764c8b991a807e6366181c1a3eddba240d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Apr 2018 15:19:14 -0700 Subject: [PATCH 011/372] [eslint config] [base] fix tests --- packages/eslint-config-airbnb-base/test/test-base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index f907581502..07d17b1027 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -11,9 +11,9 @@ fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach(( // eslint-disable-line function-paren-newline +Object.keys(files).forEach(( name, // trailing function comma is to test parsing -) => { // eslint-disable-line function-paren-newline +) => { const config = files[name]; test(`${name}: does not reference react`, (t) => { From 5705b8ae6b22305cc9dca048e0a4b14db7ce6934 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Apr 2018 14:48:50 -0700 Subject: [PATCH 012/372] Revert "Replace flag images with emoji" This reverts commit 87f97e042ddb94d87950be7c483b4aa4e391e2c2. Closes #1789. --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3ca74e2606..ed54520555 100644 --- a/README.md +++ b/README.md @@ -3640,22 +3640,22 @@ Other Style Guides This style guide is also available in other languages: - - 🇧🇷 **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) - - 🇧🇬 **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) + - ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) + - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - - 🇨🇳 **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) - - 🇹🇼 **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - 🇫🇷 **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - - 🇩🇪 **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - - 🇮🇹 **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) - - 🇯🇵 **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - - 🇰🇷 **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) - - 🇷🇺 **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - - 🇪🇸 **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - - 🇹🇭 **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) - - 🇹🇷 **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - - 🇺🇦 **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - - 🇻🇳 **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) + - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) + - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) + - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) + - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) + - ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) + - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) + - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) + - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) + - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) + - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) + - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) + - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) ## The JavaScript Style Guide Guide From 2653730fee20e46a1fc6e6c9fd512329d8719fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Ti=E1=BA=BFn=20Minh?= Date: Sat, 21 Apr 2018 13:51:56 +0700 Subject: [PATCH 013/372] [react] add vietnamese --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index b89bad0710..1af23d4d1f 100644 --- a/react/README.md +++ b/react/README.md @@ -693,5 +693,6 @@ This style guide is mostly based on the standards that are currently prevalent i - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide/tree/master/react) - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [alioguzhan/react-style-guide](https://github.com/alioguzhan/react-style-guide) - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript/tree/master/react) + - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [uetcodecamp/jsx-style-guide](https://github.com/UETCodeCamp/jsx-style-guide) **[⬆ back to top](#table-of-contents)** From 22f01558a08eed9f32ad3b6e963ac71bebd37433 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 25 Apr 2018 20:28:41 -0700 Subject: [PATCH 014/372] Add StandardJS to "Other Style Guides" list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StandardJS is one of the top style guides, though like the Google and jQuery styles, it's less popular than the airbnb style. 😀 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed54520555..855be914f9 100644 --- a/README.md +++ b/README.md @@ -3484,6 +3484,7 @@ Other Style Guides - [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml) - [jQuery Core Style Guidelines](https://contribute.jquery.org/style-guide/js/) - [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwaldron/idiomatic.js) + - [StandardJS](https://standardjs.com) **Other Styles** From 8c83d03a20d166aba0acefa1358efe6043eacc3e Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 15 Feb 2018 11:58:17 -0800 Subject: [PATCH 015/372] [eslint config] [base] [patch] Allow devDependencies for foo_spec.js naming style Some projects name test files like `foo_spec.js` instead of `foo.spec.js`. --- packages/eslint-config-airbnb-base/rules/imports.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 04455c97fb..46c6135093 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -77,7 +77,7 @@ module.exports = { '**/__mocks__/**', // jest pattern 'test.{js,jsx}', // repos with a single test file 'test-*.{js,jsx}', // repos with multiple top-level test files - '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test + '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test '**/jest.config.js', // jest config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config From 2d9779907f9760472e0318ad11b01f67a9f5dc7e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 30 Apr 2018 09:30:38 +0100 Subject: [PATCH 016/372] [eslint config] [base] [minor] only allow one newline at the end --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 0f58957211..ca8fc07ae6 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -302,7 +302,7 @@ module.exports = { 'no-multi-assign': ['error'], // disallow multiple empty lines and only one newline at the end - 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition From edf942eeb6bee3ae538e1484861ea0721fad4856 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Wed, 2 May 2018 01:01:19 -0400 Subject: [PATCH 017/372] [guide] Add descriptions of enforced rules This commit adds brief descriptions and examples of rules enforced by the guide that were not previously mentioned in the README. --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/README.md b/README.md index 855be914f9..8a2cb4b6fc 100644 --- a/README.md +++ b/README.md @@ -1053,6 +1053,24 @@ Other Style Guides }; ``` + - [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak) + + ```javascript + // bad + (foo) => + bar; + + (foo) => + (bar); + + // good + (foo) => bar; + (foo) => (bar); + (foo) => ( + bar + ) + ``` + **[⬆ back to top](#table-of-contents)** ## Classes & Constructors @@ -2664,6 +2682,90 @@ Other Style Guides .fail(() => console.log('You have failed this city.')); ``` + - [19.13](#whitespace--block-spacing) Require consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line. eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing) + + ```javascript + // bad + function foo() {return true;} + if (foo) { bar = 0;} + + // good + function foo() { return true; } + if (foo) { bar = 0; } + ``` + + - [19.14](#whitespace--comma-spacing) Avoid spaces before commas and require a space after commas. eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing) + + ```javascript + // bad + var foo = 1,bar = 2; + var arr = [1 , 2]; + + // good + var foo = 1, bar = 2; + var arr = [1, 2]; + ``` + + - [19.15](#whitespace--computed-property-spacing) Avoid spaces before commas and require a space after commas. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + + ```javascript + // bad + obj[foo ] + obj[ 'foo'] + var x = {[ b ]: a} + obj[foo[ bar ]] + + // good + obj[foo] + obj['foo'] + var x = { [b]: a } + obj[foo[bar]] + ``` + + - [19.16](#whitespace--func-call-spacing) Enforce spacing between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) + + ```javascript + // bad + func (); + + func + (); + + // good + func(); + ``` + + - [19.17](#whitespace--key-spacing) Enforce spacing between keys and values in object literal properties. eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing) + + ```javascript + // bad + var obj = { "foo" : 42 }; + var obj2 = { "foo":42 }; + + // good + var obj = { "foo": 42 }; + ``` + + - [19.18](#whitespace--no-trailing-spaces) Avoid trailing spaces at the end of lines. eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces) + + - [19.19](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines and only allow one newline at the end of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) + + + ```javascript + // bad + var x = 1; + + + + var y = 2; + + // good + var x = 1; + + var y = 2; + ``` + + **[⬆ back to top](#table-of-contents)** ## Commas From 71e54f2af8e17c6147f1e8f7baafdbcf86d1d2d9 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 4 May 2018 11:11:55 +0300 Subject: [PATCH 018/372] doc: fix some nits in README.md * Add missing anchors for section references. * Correct a rule description. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a2cb4b6fc..8ef84ade85 100644 --- a/README.md +++ b/README.md @@ -1053,6 +1053,7 @@ Other Style Guides }; ``` + - [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak) ```javascript @@ -2682,6 +2683,7 @@ Other Style Guides .fail(() => console.log('You have failed this city.')); ``` + - [19.13](#whitespace--block-spacing) Require consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line. eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing) ```javascript @@ -2694,6 +2696,7 @@ Other Style Guides if (foo) { bar = 0; } ``` + - [19.14](#whitespace--comma-spacing) Avoid spaces before commas and require a space after commas. eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing) ```javascript @@ -2706,7 +2709,8 @@ Other Style Guides var arr = [1, 2]; ``` - - [19.15](#whitespace--computed-property-spacing) Avoid spaces before commas and require a space after commas. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + + - [19.15](#whitespace--computed-property-spacing) Enforce spacing inside of computed properties. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) ```javascript // bad @@ -2722,6 +2726,7 @@ Other Style Guides obj[foo[bar]] ``` + - [19.16](#whitespace--func-call-spacing) Enforce spacing between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) ```javascript @@ -2735,6 +2740,7 @@ Other Style Guides func(); ``` + - [19.17](#whitespace--key-spacing) Enforce spacing between keys and values in object literal properties. eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing) ```javascript @@ -2746,8 +2752,10 @@ Other Style Guides var obj = { "foo": 42 }; ``` + - [19.18](#whitespace--no-trailing-spaces) Avoid trailing spaces at the end of lines. eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces) + - [19.19](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines and only allow one newline at the end of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) From 2bd77bc1e0fb6fb17f9601961cd9d5b878623c28 Mon Sep 17 00:00:00 2001 From: Jimmy Jia Date: Sat, 5 May 2018 22:34:19 -0400 Subject: [PATCH 019/372] [eslint config] [base] [patch] `label-has-for`: Remove redundant component Also make the rule configuration more explicit. --- packages/eslint-config-airbnb/rules/react-a11y.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 3e7f5c970c..f53b3d22f6 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -48,7 +48,13 @@ module.exports = { // require that JSX labels use "htmlFor" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md - 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], + 'jsx-a11y/label-has-for': ['error', { + components: [], + required: { + every: ['nesting', 'id'], + }, + allowChildren: false, + }], // require that mouseover/out come with focus/blur, for keyboard-only users // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md From 2ba36de952fcb6a931471980f4fbbdc4df468baa Mon Sep 17 00:00:00 2001 From: ParkSB Date: Sat, 5 May 2018 03:04:38 +0900 Subject: [PATCH 020/372] [guide] Add backticks --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8ef84ade85..969c65c0e4 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ Other Style Guides ``` - - [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). + - [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). ```javascript const foo = document.querySelectorAll('.foo'); @@ -786,7 +786,7 @@ Other Style Guides - [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. + > Why? Creating a function in this way evaluates a string similarly to `eval()`, which opens vulnerabilities. ```javascript // bad @@ -1167,7 +1167,7 @@ Other Style Guides ``` - - [9.4](#constructors--tostring) It’s okay to write a custom toString() method, just make sure it works successfully and causes no side effects. + - [9.4](#constructors--tostring) It’s okay to write a custom `toString()` method, just make sure it works successfully and causes no side effects. ```javascript class Jedi { @@ -1687,7 +1687,7 @@ Other Style Guides ``` - - [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](https://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. @@ -3295,7 +3295,7 @@ Other Style Guides - [24.1](#accessors--not-required) Accessor functions for properties are not required. - - [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use getVal() and setVal('hello'). + - [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use `getVal()` and `setVal('hello')`. ```javascript // bad @@ -3337,7 +3337,7 @@ Other Style Guides ``` - - [24.4](#accessors--consistent) It’s okay to create get() and set() functions, but be consistent. + - [24.4](#accessors--consistent) It’s okay to create `get()` and `set()` functions, but be consistent. ```javascript class Jedi { From c068d7cbf1bfb2f263bc928ca7fd895a6a6add7f Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 26 May 2018 13:38:45 -0700 Subject: [PATCH 021/372] Fix link for Temporal Dead Zone --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 969c65c0e4..0a3a1f88f3 100644 --- a/README.md +++ b/README.md @@ -1748,7 +1748,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn’t work (assuming there From 04ab225858b75b9fb1180075b92845700849ea5b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 27 May 2018 08:47:29 -0700 Subject: [PATCH 022/372] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint-find-rules`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb-base/rules/imports.js | 9 ++++++++- packages/eslint-config-airbnb/package.json | 10 +++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 7739f54005..a4b83cda9c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,15 +53,15 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.11.0", + "eslint-find-rules": "^3.2.3", + "eslint-plugin-import": "^2.12.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.11.0" + "eslint-plugin-import": "^2.12.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 46c6135093..a8502d554a 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -232,7 +232,14 @@ module.exports = { 'import/no-cycle': ['error', { maxDepth: Infinity }], // Ensures that there are no useless path segments - // https://github.com/benmosher/eslint-plugin-import/issues/1032 + // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md 'import/no-useless-path-segments': 'error', + + // dynamic imports require a leading comment with a webpackChunkName + // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md + 'import/dynamic-import-chunkname': ['off', { + importFunctions: [], + webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', + }], }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index bc80fdd060..d3fc6d8df1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -58,10 +58,10 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.11.0", + "eslint-find-rules": "^3.2.3", + "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.7.0", + "eslint-plugin-react": "^7.8.2", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -69,9 +69,9 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.11.0", + "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.7.0" + "eslint-plugin-react": "^7.8.2" }, "engines": { "node": ">= 4" From ae82d7678303bd08242299a4a9e2c47717bf9c6b Mon Sep 17 00:00:00 2001 From: Alexandre Syenchuk Date: Wed, 30 May 2018 09:06:14 +0200 Subject: [PATCH 023/372] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a3a1f88f3..3b00f8c274 100644 --- a/README.md +++ b/README.md @@ -3719,6 +3719,7 @@ Other Style Guides - **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript) - **OutBoxSoft**: [OutBoxSoft/javascript](https://github.com/OutBoxSoft/javascript) - **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript) + - **Qotto**: [Qotto/javascript-style-guide](https://github.com/Qotto/javascript-style-guide) - **Razorfish**: [razorfish/javascript-style-guide](https://github.com/razorfish/javascript-style-guide) - **reddit**: [reddit/styleguide/javascript](https://github.com/reddit/styleguide/tree/master/javascript) - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) From dfc9da71d9ac8669d074cbe0f918b504c8a68be8 Mon Sep 17 00:00:00 2001 From: Andrew Macpherson Date: Thu, 31 May 2018 18:34:17 +0100 Subject: [PATCH 024/372] Add Drupal to In The Wild section. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3b00f8c274..d6e1c5e0ab 100644 --- a/README.md +++ b/README.md @@ -3677,6 +3677,7 @@ Other Style Guides - **DailyMotion**: [dailymotion/javascript](https://github.com/dailymotion/javascript) - **DoSomething**: [DoSomething/eslint-config](https://github.com/DoSomething/eslint-config) - **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript) + - **Drupal**: [www.drupal.org](https://www.drupal.org/project/drupal) - **Ecosia**: [ecosia/javascript](https://github.com/ecosia/javascript) - **Evernote**: [evernote/javascript-style-guide](https://github.com/evernote/javascript-style-guide) - **Evolution Gaming**: [evolution-gaming/javascript](https://github.com/evolution-gaming/javascript) From 8a244801196924797878186d744249c78fa4ed37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Garc=C3=ADa=20Salas?= Date: Sun, 3 Jun 2018 10:48:10 -0700 Subject: [PATCH 025/372] Fix broken aria roles link in React style guide README --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 1af23d4d1f..c4fcf76d56 100644 --- a/react/README.md +++ b/react/README.md @@ -307,7 +307,7 @@ This style guide is mostly based on the standards that are currently prevalent i Me waving hello ``` - - Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions). eslint: [`jsx-a11y/aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md) + - Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/#usage_intro). eslint: [`jsx-a11y/aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md) ```jsx // bad - not an ARIA role From 5e260928b65f48c895b21d49ea0aa752df2e4d80 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 3 Jun 2018 22:19:41 -0700 Subject: [PATCH 026/372] [eslint config] [react] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d3fc6d8df1..faee46ec90 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -61,7 +61,7 @@ "eslint-find-rules": "^3.2.3", "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.8.2", + "eslint-plugin-react": "^7.9.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -71,7 +71,7 @@ "eslint": "^4.19.1", "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.8.2" + "eslint-plugin-react": "^7.9.1" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 7d8145a17a..f5a807faac 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -290,8 +290,8 @@ module.exports = { 'react/jsx-indent': ['error', 2], // Disallow target="_blank" on links - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md - 'react/jsx-no-target-blank': 'error', + // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md + 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }], // only .jsx files may have JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md @@ -436,6 +436,10 @@ module.exports = { // Validate JSX maximum depth // https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md 'react/jsx-max-depth': 'off', + + // Disallow multiple spaces between inline JSX props + // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md + 'react/jsx-props-no-multi-spaces': 'error', }, settings: { From 74fb34f08d4f1961169e9c37c9036a5b42aa7bf1 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Fri, 8 Jun 2018 01:38:03 -0400 Subject: [PATCH 027/372] Add no-unused-vars to README This documents the enforced but currently undocumented `no-unused-vars` rule with a brief description, examples, and noting the `"ignoreRestSiblings": true` option. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index d6e1c5e0ab..b807154d99 100644 --- a/README.md +++ b/README.md @@ -1743,6 +1743,45 @@ Other Style Guides const foo = 'superLongLongLongLongLongLongLongLongString'; ``` + - [13.8](#variables--no-unused-vars) Disallow unused variables. eslint: [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) + + > Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. + + ```javascript + // bad + + var some_unused_var = 42; + + // Write-only variables are not considered as used. + var y = 10; + y = 5; + + // A read for a modification of itself is not considered as used. + var z = 0; + z = z + 1; + + // Unused function arguments. + function getX(x, y) { + return x; + } + + // good + + function getXPlusY(x, y) { + return x + y; + } + + var x = 1; + var y = a + 2; + + alert(getXPlusY(x, y)); + + // 'type' is ignored even if unused because it has a rest property sibling. + // This is a form of extracting an object that omits the specified keys. + var { type, ...coords } = data; + // 'coords' is now the 'data' object without its 'type' property. + ``` + **[⬆ back to top](#table-of-contents)** ## Hoisting From 103f5e2a5901392878889ec1f1ad4e59c8d65dc3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 8 Jun 2018 19:49:37 +0300 Subject: [PATCH 028/372] doc: add missing anchor in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b807154d99..e486ae170e 100644 --- a/README.md +++ b/README.md @@ -1743,6 +1743,7 @@ Other Style Guides const foo = 'superLongLongLongLongLongLongLongLongString'; ``` + - [13.8](#variables--no-unused-vars) Disallow unused variables. eslint: [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) > Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. From d270031fc07bd26df9d53106704e04abc37d8256 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 13:28:22 -0700 Subject: [PATCH 029/372] [eslint config] [*] [dev deps] update `babel-preset-airbnb`, `tape` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a4b83cda9c..9327414f6c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.4.0", + "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", @@ -57,7 +57,7 @@ "eslint-plugin-import": "^2.12.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.9.0" + "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index faee46ec90..95cc0adcf8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "object.entries": "^1.0.4" }, "devDependencies": { - "babel-preset-airbnb": "^2.4.0", + "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", @@ -65,7 +65,7 @@ "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.9.0" + "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", From 2668495fee10b4b70f72ba623b4f319ad539700a Mon Sep 17 00:00:00 2001 From: minimooooz Date: Thu, 12 Oct 2017 11:17:22 +0700 Subject: [PATCH 030/372] add ES2015-2018 in npm package keywords --- package.json | 3 +++ packages/eslint-config-airbnb-base/package.json | 6 +++++- packages/eslint-config-airbnb/package.json | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b50dd7a121..d907751ccc 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "airbnb", "es6", "es2015", + "es2016", + "es2017", + "es2018", "react", "jsx" ], diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 9327414f6c..bd2ef922c3 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -25,7 +25,11 @@ "config", "airbnb", "javascript", - "styleguide" + "styleguide", + "es2015", + "es2016", + "es2017", + "es2018" ], "author": "Jake Teton-Landis (https://twitter.com/@jitl)", "contributors": [ diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 95cc0adcf8..97e1579393 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -25,7 +25,11 @@ "config", "airbnb", "javascript", - "styleguide" + "styleguide", + "es2015", + "es2016", + "es2017", + "es2018" ], "author": "Jake Teton-Landis (https://twitter.com/@jitl)", "contributors": [ From b3bbd1ccbc2495762ed3b2ec47e776135e532d76 Mon Sep 17 00:00:00 2001 From: Josh Wells Date: Wed, 11 Apr 2018 13:46:34 +0100 Subject: [PATCH 031/372] [eslint config] [base] [breaking] order of import statements is ignored for unassigned imports --- packages/eslint-config-airbnb-base/rules/imports.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index a8502d554a..c48959e14f 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -115,7 +115,7 @@ module.exports = { // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md - 'import/first': ['error', 'absolute-first'], + 'import/first': 'error', // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md @@ -139,13 +139,10 @@ module.exports = { jsx: 'never', }], - // Enforce a convention in module import order + // ensure absolute imports are above relative imports and that unassigned imports are ignored // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md - // TODO: enable? - 'import/order': ['off', { - groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], - 'newlines-between': 'never', - }], + // TODO: enforce a stricter convention in module import order? + 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }], // Require a newline after the last import/require in a group // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md From 068d6b69bf70c83d16eba25c9c517a4859c96ea4 Mon Sep 17 00:00:00 2001 From: Moritz Kneilmann Date: Tue, 15 May 2018 23:54:09 +0200 Subject: [PATCH 032/372] [eslint config] [base] [patch] Adjust imports for vue-cli Allows the vue-cli config file `vue.config.js` to import `devDependencies` by altering the rule `import/no-extraneous-dependencies`. --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index c48959e14f..91d82df1cb 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -79,6 +79,7 @@ module.exports = { 'test-*.{js,jsx}', // repos with multiple top-level test files '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test '**/jest.config.js', // jest config + '**/vue.config.js', // vue-cli config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From 25e711cedd78e3329e8a8508d723996080d8336f Mon Sep 17 00:00:00 2001 From: Gaurav Paliwal Date: Wed, 20 Jun 2018 17:31:00 +0530 Subject: [PATCH 033/372] [eslint config] [patch] Add new methods introduced in react@16.3 --- packages/eslint-config-airbnb/rules/react.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index f5a807faac..a2a21c141f 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -23,13 +23,17 @@ module.exports = { 'getDefaultProps', 'getChildContext', 'componentWillMount', + 'UNSAFE_componentWillMount', 'componentDidMount', 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', 'shouldComponentUpdate', 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', 'componentDidCatch', + 'getSnapshotBeforeUpdate' ], }], From 951825c6d216ef2b3017472ae66e9b3360b089ae Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:22:54 -0700 Subject: [PATCH 034/372] [eslint config] set `forbid-foreign-prop-types` to "warn" --- packages/eslint-config-airbnb/rules/react.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index a2a21c141f..20971d1622 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -375,8 +375,9 @@ module.exports = { // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - // TODO: enable? - 'react/forbid-foreign-prop-types': ['off', { allowInPropTypes: true }], + // this is intentionally set to "warn". it would be "error", but it's only critical if you're using + // a babel transform to strip propTypes in production. + 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], // Prevent void DOM elements from receiving children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md From fdb998b38adda8777022fe33b86b2f8092ac83a0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:39:07 -0700 Subject: [PATCH 035/372] [eslint config] [base] fix tests --- packages/eslint-config-airbnb-base/whitespace.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 66a05e52b9..d215d4ae6a 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,8 +1,9 @@ -const baseConfig = require('.'); const assign = require('object.assign'); const entries = require('object.entries'); const CLIEngine = require('eslint').CLIEngine; +const baseConfig = require('.'); + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); From 8be089eb1138c6e5dbdc27146248525c0633ba47 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:46:24 -0700 Subject: [PATCH 036/372] [eslint config] fix tests --- packages/eslint-config-airbnb/rules/react.js | 4 ++-- packages/eslint-config-airbnb/whitespace.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 20971d1622..62675c1cf0 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -375,8 +375,8 @@ module.exports = { // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - // this is intentionally set to "warn". it would be "error", but it's only critical if you're using - // a babel transform to strip propTypes in production. + // this is intentionally set to "warn". it would be "error", + // but it's only critical if you're stripping propTypes in production. 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], // Prevent void DOM elements from receiving children diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index ba36569a99..414f9c37a1 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,8 +1,9 @@ -const baseConfig = require('.'); const assign = require('object.assign'); const entries = require('object.entries'); const CLIEngine = require('eslint').CLIEngine; +const baseConfig = require('.'); + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); From afe340773f082b262955abf243efbd60e2d87ee4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:46:43 -0700 Subject: [PATCH 037/372] [eslint config] [base] v13.0.0 --- .../eslint-config-airbnb-base/CHANGELOG.md | 34 +++++++++++++++++++ .../eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 6dd34427fc..daff7f51a7 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,37 @@ +13.0.0 / 2018-06-21 +================== + - [breaking] order of import statements is ignored for unassigned imports (#1782) + - [breaking] enable `import/no-cycle`: warn on cyclical dependencies (#1779) + - [breaking] Change import/no-self-import from "off" to "error" (#1770) + - [breaking] Update `object-curly-newline` to match eslint 4.18.0 (#1761) + - [breaking] enable `no-useless-path-segments` (#1743) + - [breaking] Prevent line breaks before and after `=` (#1710) + - [breaking] Add .mjs extension support (#1634) + - [breaking] enable `implicit-arrow-linebreak` + - [breaking] Enables `nonblock-statement-body-position` rule and adds link to guide (#1618) + - [breaking] `no-mixed-operators`: only warn on `**` and `%` mixed with arithmetic operators; removes violation against mixing common math operators. (#1611) + - [breaking] `import/named`: enable + - [breaking] `lines-between-class-members`: set to “always” + - [breaking] `no-else-return`: disallow else-if (#1595) + - [breaking] Enables eslint rule for operator-linebreak + - [new] Adds config entry point with only whitespace rules enabled (#1749, #1751) + - [minor] only allow one newline at the end (#1794) + - [patch] Adjust imports for vue-cli (#1809) + - [patch] Allow devDependencies for `foo_spec.js` naming style (#1732) + - [patch] `function-paren-newline`: change to "consistent" + - [patch] avoid `__mocks__` `no-extraneous-dependencies` check (#1772) + - [patch] Include 'accumulator' exception for `no-param-reassign` (#1768) + - [patch] Set import/extensions to ignorePackages (#1652) + - [patch] properly ignore indentation on jsx + - [patch] `array-callback-return`: enable `allowImplicit` option (#1668) + - [deps] update `eslint`, `eslint-plugin-import` + - [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules` + - [meta] add ES2015-2018 in npm package keywords (#1587) + - [meta] Add licenses to sub packages (#1746) + - [docs] add `npx` shortcut (#1694) + - [docs] Use HTTPS for links to ESLint documentation (#1628) + - [tests] ensure all entry points parse + 12.1.0 / 2017-10-16 ================== - [deps] update `eslint` to `v4.9` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bd2ef922c3..bd072bf850 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "12.1.0", + "version": "13.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From d14ed5daa7625eab6e03fb290b0a18ed11b229fc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 15:16:52 -0700 Subject: [PATCH 038/372] [eslint config] [breaking] update `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 97e1579393..313e61a3bb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -26,7 +26,7 @@ "airbnb", "javascript", "styleguide", - "es2015", + "es2015", "es2016", "es2017", "es2018" @@ -53,7 +53,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^12.1.0", + "eslint-config-airbnb-base": "^13.0.0", "object.assign": "^4.1.0", "object.entries": "^1.0.4" }, From cae920fc308325b40f49c5e8f76bbeb5d8663fc5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 15:22:10 -0700 Subject: [PATCH 039/372] [eslint config] v17.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 19 +++++++++++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index d19acfc7f2..14f9e6748a 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,22 @@ +17.0.0 / 2018-06-21 +================== +- [breaking] update `eslint-config-airbnb-base` to v13 +- [breaking] enable `no-useless-path-segments` (#1743) +- [breaking] update `eslint-plugin-react` to `v7.6`; update rule configs (#1737) +- [breaking] bump react pragma to v16; update `class-methods-use-this`'s `exceptMethods` to include `componentDidCatch` (#1704) +- [new] Adds config entry point with only whitespace rules enabled (#1749, #1751) +- [patch] set `forbid-foreign-prop-types` to "warn" +- [patch] Add new methods introduced in react@16.3 (#1831) +- [patch] `label-has-for`: Remove redundant component (#1802) +- [patch] Add 'to' as a specialLink to the 'anchor-is-valid' a11y rule (#1648) +- [patch] disable `no-did-mount-set-state`, since it’s necessary for server-rendering. +- [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-import`, +- [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules` +- [meta] add ES2015-2018 in npm package keywords (#1587) +- [meta] Add licenses to sub packages (#1746) +- [docs] add `npx` shortcut (#1694) +- [docs] Use HTTPS for links to ESLint documentation (#1628) + 16.1.0 / 2017-10-16 ================== - [deps] update `eslint-config-airbnb-base`, `eslint` to v4.9 diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 313e61a3bb..160a44b823 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "16.1.0", + "version": "17.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2161ddf8d6b608fbb91466e741f68b6a50608d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Mon, 25 Jun 2018 02:08:15 +0800 Subject: [PATCH 040/372] Build: add node 10 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bc8324b755..0f4ecc3fb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "10" - "9" - "8" - "7" From 8de558b7500c91e8e77e4c2446e9888844bcba77 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 Jun 2018 19:41:27 -0700 Subject: [PATCH 041/372] [eslint config] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 4 ++++ packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bd072bf850..4fced65b6d 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -58,14 +58,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.3", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.12.0" + "eslint-plugin-import": "^2.13.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 91d82df1cb..fbeca8dc83 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -239,5 +239,9 @@ module.exports = { importFunctions: [], webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', }], + + // Use this rule to prevent imports to folders in relative parent paths. + // https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md + 'import/no-relative-parent-imports': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 160a44b823..f0f16ccc02 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,7 +63,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.3", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.9.1", "in-publish": "^2.0.0", @@ -73,7 +73,7 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.9.1" }, From 6a593069e1055a082d3891cc50579a6d586bf3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Mon, 25 Jun 2018 02:09:32 +0800 Subject: [PATCH 042/372] [dev deps] update `markdownlint-cli` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d907751ccc..1fdcd7be15 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint-cli": "^0.3.1" + "markdownlint-cli": "^0.10.0" } } From 363bb077658906ccc809419b1ce3cb2f75b29e90 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 Jun 2018 22:57:06 -0700 Subject: [PATCH 043/372] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f0f16ccc02..9e3deaa716 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -65,7 +65,7 @@ "eslint-find-rules": "^3.2.3", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.9.1", + "eslint-plugin-react": "^7.10.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -75,7 +75,7 @@ "eslint": "^4.19.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.9.1" + "eslint-plugin-react": "^7.10.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 62675c1cf0..dcd3ac95be 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -445,6 +445,10 @@ module.exports = { // Disallow multiple spaces between inline JSX props // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md 'react/jsx-props-no-multi-spaces': 'error', + + // Prevent usage of UNSAFE_ methods + // https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md + 'react/no-unsafe': 'off', }, settings: { From 47021150388d1cea54c529463fe20299f1de9bb5 Mon Sep 17 00:00:00 2001 From: liyuhang Date: Mon, 25 Jun 2018 16:08:50 +0800 Subject: [PATCH 044/372] Fix: Typo --- linters/.markdownlint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/.markdownlint.json b/linters/.markdownlint.json index e7a019fed8..8731243cf7 100644 --- a/linters/.markdownlint.json +++ b/linters/.markdownlint.json @@ -31,7 +31,7 @@ "comment": "MD009: Disallow trailing spaces", "no-trailing-spaces": { - "br-spaces": 0, + "br_spaces": 0, "comment": "Empty lines inside list items should not be indented", "list_item_empty_lines": false }, From d951220399c75099838fc79577033b00530b2b90 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 13:40:38 -0700 Subject: [PATCH 045/372] [eslint config] [*] [dev deps] update `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4fced65b6d..cb9efcf519 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,7 +57,7 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.3", + "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 9e3deaa716..81f50cbed4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -62,7 +62,7 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.3", + "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.10.0", From 27e5e20b70a042945a63c37ac1d9ad834fc3acd0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 14:14:01 -0700 Subject: [PATCH 046/372] [eslint config] [base] [new] update base ecmaVersion to 2018; remove deprecated experimentalObjectRestSpread option --- packages/eslint-config-airbnb-base/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index 4de657b075..16b423f35d 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -9,11 +9,8 @@ module.exports = { './rules/imports', ].map(require.resolve), parserOptions: { - ecmaVersion: 2017, + ecmaVersion: 2018, sourceType: 'module', - ecmaFeatures: { - experimentalObjectRestSpread: true, - }, }, rules: { strict: 'error', From 77fdae6a74a718d1ec32455088dbb5f964f5d271 Mon Sep 17 00:00:00 2001 From: Noah Benham Date: Mon, 2 Jul 2018 09:17:21 -0500 Subject: [PATCH 047/372] Add Cerner to In The Wild [Cerner](https://github.com/cerner/) uses Airbnb for our JS projects. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e486ae170e..7912c73cfc 100644 --- a/README.md +++ b/README.md @@ -3711,6 +3711,7 @@ Other Style Guides - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) + - **Cerner**: [Cerner](https://github.com/cerner/) - **Chartboost**: [ChartBoost/javascript-style-guide](https://github.com/ChartBoost/javascript-style-guide) - **ComparaOnline**: [comparaonline/javascript](https://github.com/comparaonline/javascript-style-guide) - **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide) From fe8de599774bf8d312b2b94e93172e873c36df8f Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Tue, 3 Jul 2018 21:18:11 +0200 Subject: [PATCH 048/372] [eslint-config] [*] [docs] :pencil2: fix typo in Readme --- packages/eslint-config-airbnb-base/README.md | 2 +- packages/eslint-config-airbnb/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index fa0152eb04..3c1a9ce914 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -86,7 +86,7 @@ See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb) ### eslint-config-airbnb-base/whitespace -This entry point that only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js). +This entry point only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js). ## Improving this config diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 2f341ec187..f679682936 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -57,7 +57,7 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t ### eslint-config-airbnb/whitespace -This entry point that only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/whitespace.js). +This entry point only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/whitespace.js). ### eslint-config-airbnb/base From 5d1f4b9a49ee7def65343f5efccfcce7723b9b4b Mon Sep 17 00:00:00 2001 From: Mauro Zenoni <25953912+maurozenoni@users.noreply.github.com> Date: Tue, 3 Jul 2018 11:51:37 +0200 Subject: [PATCH 049/372] [guide] Updated Arrays Section - corrected paragraph 4.4 (conversion from iterable to array) - added paragraph 4.5 (conversion from array-like to array) --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7912c73cfc..54cb2c0d4c 100644 --- a/README.md +++ b/README.md @@ -369,8 +369,9 @@ Other Style Guides const itemsCopy = [...items]; ``` - - - [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). + + + - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). ```javascript const foo = document.querySelectorAll('.foo'); @@ -382,8 +383,21 @@ Other Style Guides const nodes = [...foo]; ``` + + - [4.5](#arrays--from-array-like) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) for converting an array-like object to an array. + + ```javascript + const arrLike = { 0: 'foo', 1: 'bar', 2: 'baz', length: 3 }; + + // bad + const arr = Array.prototype.slice.call(arrLike); + + // good + const arr = Array.from(arrLike); + ``` + - - [4.5](#arrays--mapping) Use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array. + - [4.6](#arrays--mapping) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array. ```javascript // bad @@ -394,7 +408,7 @@ Other Style Guides ``` - - [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) + - [4.7](#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 @@ -441,7 +455,7 @@ Other Style Guides ``` - - [4.7](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines + - [4.8](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines ```javascript // bad From 7dda84a335f5903d72c9423dc17f33f2c9813d2a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 4 Jul 2018 22:33:27 -0700 Subject: [PATCH 050/372] [eslint config] [deps] [minor] update `jsx-a11y` plugin; enable `label-has-associated-control` rule This is semver-minor, because the `label-has-associated-control` rule is the same as the `label-has-for` rule, theoretically. Both remain enabled, but `label-has-for` will be disabled in the future if this rule proves out. --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 81f50cbed4..53079d4a07 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -64,7 +64,7 @@ "eslint": "^4.19.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", - "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -74,7 +74,7 @@ "peerDependencies": { "eslint": "^4.19.1", "eslint-plugin-import": "^2.13.0", - "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index f53b3d22f6..dbb073fa67 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -56,6 +56,16 @@ module.exports = { allowChildren: false, }], + // Enforce that a label tag has a text label and an associated control. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md + 'jsx-a11y/label-has-associated-control': ['error', { + labelComponents: [], + labelAttributes: [], + controlComponents: [], + assert: 'both', + depth: 25 + }], + // require that mouseover/out come with focus/blur, for keyboard-only users // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md 'jsx-a11y/mouse-events-have-key-events': 'error', From 2037fd82b9260db71758aedc513e86b7df23c01e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 15:48:07 -0700 Subject: [PATCH 051/372] [Tests] link eslint from the base config as well --- packages/eslint-config-airbnb/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 53079d4a07..fd25457d7b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -11,9 +11,10 @@ "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", - "pretravis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", + "link:eslint": "cd node_modules/eslint && npm link && cd -", + "pretravis": "npm run link:eslint && cd ../eslint-config-airbnb-base && npm link eslint && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", "travis": "npm run --silent test", - "posttravis": "npm unlink --no-save eslint-config-airbnb-base >/dev/null &" + "posttravis": "npm unlink --no-save eslint-config-airbnb-base eslint >/dev/null &" }, "repository": { "type": "git", From a510095acf20e3d96a94e6d0d0b26cfac71d2c7f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 15:06:18 -0700 Subject: [PATCH 052/372] [eslint config] [*] [new] add eslint v5 support --- .travis.yml | 23 ++++++++++++++++--- .../eslint-config-airbnb-base/package.json | 4 ++-- .../rules/best-practices.js | 10 +++++++- .../eslint-config-airbnb-base/rules/style.js | 16 +++++++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f4ecc3fb1..2fcc94de67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,20 +18,37 @@ script: sudo: false env: matrix: - - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' matrix: fast_finish: true include: - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true + exclude: + - node_js: "5" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "5" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "4" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "4" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb allow_failures: - node_js: "9" - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index cb9efcf519..1bdfc3b2ff 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -56,7 +56,7 @@ "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", @@ -64,7 +64,7 @@ "tape": "^4.9.1" }, "peerDependencies": { - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-plugin-import": "^2.13.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index b5712d00b2..421b591488 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -42,6 +42,11 @@ module.exports = { // make sure for-in loops have an if statement 'guard-for-in': 'error', + // enforce a maximum number of classes per file + // https://eslint.org/docs/rules/max-classes-per-file + // TODO: semver-major (eslint 5): enable + 'max-classes-per-file': ['off', 1], + // disallow the use of alert, confirm, and prompt 'no-alert': 'warn', @@ -243,7 +248,10 @@ module.exports = { // disallow self assignment // https://eslint.org/docs/rules/no-self-assign - 'no-self-assign': 'error', + // TODO: semver-major: props -> true + 'no-self-assign': ['error', { + props: false, + }], // disallow comparisons where both sides are exactly the same 'no-self-compare': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index ca8fc07ae6..ee5408f81c 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -21,6 +21,7 @@ module.exports = { 'brace-style': ['error', '1tbs', { allowSingleLine: true }], // require camel case names + // TODO: semver-major (eslint 5): add ignoreDestructuring: false option camelcase: ['error', { properties: 'never' }], // enforce or disallow capitalization of the first letter of a comment @@ -83,6 +84,7 @@ module.exports = { // requires function names to match the name of the variable or property to which they are // assigned // https://eslint.org/docs/rules/func-name-matching + // TODO: semver-major (eslint 5): add considerPropertyDescriptor: true 'func-name-matching': ['off', 'always', { includeCommonJSModuleExports: false }], @@ -208,6 +210,15 @@ module.exports = { skipComments: true }], + // enforce a maximum function length + // https://eslint.org/docs/rules/max-lines-per-function + 'max-lines-per-function': ['off', { + max: 50, + skipBlankLines: true, + skipComments: true, + IIFEs: true, + }], + // specify the maximum depth callbacks can be nested 'max-nested-callbacks': 'off', @@ -416,6 +427,11 @@ module.exports = { // https://eslint.org/docs/rules/padding-line-between-statements 'padding-line-between-statements': 'off', + // Prefer use of an object spread over Object.assign + // https://eslint.org/docs/rules/prefer-object-spread + // TODO: semver-major (eslint 5): enable + 'prefer-object-spread': 'off', + // require quotes around object literal property names // https://eslint.org/docs/rules/quote-props.html 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index fd25457d7b..63dbe709eb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -62,7 +62,7 @@ "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.1.0", @@ -73,7 +73,7 @@ "tape": "^4.9.1" }, "peerDependencies": { - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0" From 96317f8c79d6c5a6e9478a49eb89770863c4e6e1 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Thu, 5 Jul 2018 16:48:26 +0300 Subject: [PATCH 053/372] [guide] fix anchor tag in README.md Currently, this anchor with missing end tag breaks rendering: https://github.com/airbnb/javascript/blob/5d1f4b9a49ee7def65343f5efccfcce7723b9b4b/README.md#arrays--from-iterable --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54cb2c0d4c..ae13bca33a 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ Other Style Guides const itemsCopy = [...items]; ``` - + - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). From b6a268f780177e03b573a4f0df95ecc0d2e8783e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 9 Jul 2018 23:16:25 -0700 Subject: [PATCH 054/372] [eslint config] [react] disable two buggy rules, temporarily --- packages/eslint-config-airbnb/rules/react.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index dcd3ac95be..7d82df1302 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -413,11 +413,13 @@ module.exports = { // One JSX Element Per Line // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md - 'react/jsx-one-expression-per-line': 'error', + // TODO: re-enable when an option for text children is available + 'react/jsx-one-expression-per-line': 'off', // Enforce consistent usage of destructuring assignment of props, state, and context // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md - 'react/destructuring-assignment': ['error', 'always'], + // TODO: re-enable when component detection is fixed + 'react/destructuring-assignment': ['off', 'always'], // Prevent using this.state within a this.setState // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md From a12dec90d173464a3fc4e4536b8c6f639fb93236 Mon Sep 17 00:00:00 2001 From: Andrew Scheuermann Date: Wed, 11 Jul 2018 16:26:22 -0700 Subject: [PATCH 055/372] [guide] [react] boolean in jsx alignment --- react/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/react/README.md b/react/README.md index c4fcf76d56..340e780c01 100644 --- a/react/README.md +++ b/react/README.md @@ -193,6 +193,25 @@ This style guide is mostly based on the standards that are currently prevalent i > + + // bad + {showButton && +