From 32a7bf44c2e5b3d2a5d05af46716fbe45bc09bec Mon Sep 17 00:00:00 2001 From: Tokyo Date: Wed, 12 Sep 2018 15:37:59 +0100 Subject: [PATCH 001/302] :pencil2: fix docs for whitespace config --- 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 3c1a9ce914..9998d81fb3 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 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 errors 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 f679682936..a03c378fa3 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 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 errors 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 9af5ee89ebf4c491d2f5231bced89d8cb1863660 Mon Sep 17 00:00:00 2001 From: Parul Gupta Date: Tue, 2 Oct 2018 16:26:25 +0530 Subject: [PATCH 002/302] Updated wording of variable--one-const rule --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd986b04b5..13a618f9dc 100644 --- a/README.md +++ b/README.md @@ -1581,7 +1581,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) + - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable or assignment. 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. From 924dfb268208b0fa59ead2e256be1da38ee17bca Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Wed, 3 Oct 2018 23:56:48 +0700 Subject: [PATCH 003/302] [doc] add eslint rule reference for `no-prototype-builtins` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 13a618f9dc..7c74fedc63 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ Other Style Guides ``` - - [3.7](#objects--prototype-builtins) Do not call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. + - [3.7](#objects--prototype-builtins) Do not call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. eslint: [`no-prototype-builtins`](https://eslint.org/docs/rules/no-prototype-builtins) > Why? These methods may be shadowed by properties on the object in question - consider `{ hasOwnProperty: false }` - or, the object may be a null object (`Object.create(null)`). From 24da5bb540de12117bcdfa7b6d8ce3c0ff4b6504 Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Thu, 4 Oct 2018 20:29:10 +0700 Subject: [PATCH 004/302] [doc] add eslint rule references in react guide * react/jsx-filename-extension * react/no-array-index-key --- react/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/README.md b/react/README.md index 850373a129..8ec7a92313 100644 --- a/react/README.md +++ b/react/README.md @@ -80,7 +80,7 @@ This style guide is mostly based on the standards that are currently prevalent i ## Naming - - **Extensions**: Use `.jsx` extension for React components. + - **Extensions**: Use `.jsx` extension for React components. eslint: [`react/jsx-filename-extension`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md) - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`. - **Reference Naming**: Use PascalCase for React components and camelCase for their instances. eslint: [`react/jsx-pascal-case`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md) @@ -351,7 +351,7 @@ This style guide is mostly based on the standards that are currently prevalent i
``` - - Avoid using an array index as `key` prop, prefer a stable ID. + - Avoid using an array index as `key` prop, prefer a stable ID. eslint: [`react/no-array-index-key`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md) > Why? Not using a stable ID [is an anti-pattern](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318) because it can negatively impact performance and cause issues with component state. From 03a0734fcefa0e7ab351ce33fd1562e089de1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Anzorena?= Date: Wed, 17 Oct 2018 01:51:06 +0800 Subject: [PATCH 005/302] Add UrbanSim to organizations list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7c74fedc63..2a8844fd60 100644 --- a/README.md +++ b/README.md @@ -3797,6 +3797,7 @@ Other Style Guides - **TheLadders**: [TheLadders/javascript](https://github.com/TheLadders/javascript) - **The Nerdery**: [thenerdery/javascript-standards](https://github.com/thenerdery/javascript-standards) - **T4R Technology**: [T4R-Technology/javascript](https://github.com/T4R-Technology/javascript) + - **UrbanSim**: [urbansim](https://github.com/urbansim/) - **VoxFeed**: [VoxFeed/javascript-style-guide](https://github.com/VoxFeed/javascript-style-guide) - **WeBox Studio**: [weboxstudio/javascript](https://github.com/weboxstudio/javascript) - **Weggo**: [Weggo/javascript](https://github.com/Weggo/javascript) From 41a13e83eee02be3fcfc0657a6cb994018df700d Mon Sep 17 00:00:00 2001 From: Bikram Sutar <38653376+theBstar@users.noreply.github.com> Date: Tue, 30 Oct 2018 15:05:16 +0530 Subject: [PATCH 006/302] [19.16] changed Enforce to avoid Good practice is to avoid spaces between functions and their invocations. But by mistake (I think so) you used the word Enforce instead of Avoid --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a8844fd60..3959247747 100644 --- a/README.md +++ b/README.md @@ -2781,7 +2781,7 @@ Other Style Guides ``` - - [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) + - [19.16](#whitespace--func-call-spacing) Avoid spaces between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) ```javascript // bad From 74deb81d1fa670a5a462f6ada29d9447cf61c7c0 Mon Sep 17 00:00:00 2001 From: KY3LxD <38943742+KY3LxD@users.noreply.github.com> Date: Mon, 12 Nov 2018 23:38:19 -0800 Subject: [PATCH 007/302] [editorial] Improve conciseness of README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3959247747..88d26ff582 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ Other Style Guides - [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. + > Why? It is shorter and descriptive. ```javascript const lukeSkywalker = 'Luke Skywalker'; From 21b65e943c361f91af5a484460fb2c8d02e2ff92 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 20 Nov 2018 09:40:02 +0000 Subject: [PATCH 008/302] [eslint config] [base] [deps] Switch to confusing-browser-globals The `eslint-restricted-globals` package author created an equivalent package `confusing-browser-globals` that now resides within the create-react-app monorepo. In sidoshi/eslint-restricted-globals#2 @sidoshi suggested that we change eslint-config-airbnb-base to depend on the CRA package instead, in an effort to consolidate the two. Currently the two global lists are identical, so this does not change the generated eslint config: https://unpkg.com/eslint-restricted-globals@0.2.0/index.js https://unpkg.com/confusing-browser-globals@1.0.5/index.js --- packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb-base/rules/variables.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 91bcb47195..4ec1497674 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -71,7 +71,7 @@ "node": ">= 4" }, "dependencies": { - "eslint-restricted-globals": "^0.1.1", + "confusing-browser-globals": "^1.0.5", "object.assign": "^4.1.0", "object.entries": "^1.0.4" } diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index aeab992320..701340ab56 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -1,4 +1,4 @@ -const restrictedGlobals = require('eslint-restricted-globals'); +const confusingBrowserGlobals = require('confusing-browser-globals'); module.exports = { rules: { @@ -16,7 +16,7 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(restrictedGlobals), + 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(confusingBrowserGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From 0d6d854b5c70c8440091253c2d1fcc84b6f8ee20 Mon Sep 17 00:00:00 2001 From: "NullDev (Chris)" Date: Wed, 21 Nov 2018 10:48:35 +0100 Subject: [PATCH 009/302] [17.2] Added second anchor https://github.com/airbnb/javascript/pull/1960 See requested changes here: https://github.com/airbnb/javascript/pull/1960#pullrequestreview-176797787 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88d26ff582..a90c4d6a67 100644 --- a/README.md +++ b/README.md @@ -2249,7 +2249,7 @@ Other Style Guides } ``` - + - [17.2](#control-statements--value-selection) Don't use selection operators in place of control statements. ```javascript From 6ece1f58e91a06608145d03dbc949aa352cad5a8 Mon Sep 17 00:00:00 2001 From: "NullDev (Chris)" Date: Wed, 21 Nov 2018 10:51:20 +0100 Subject: [PATCH 010/302] Added NullDev because why not --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a90c4d6a67..6caee476d8 100644 --- a/README.md +++ b/README.md @@ -3770,6 +3770,7 @@ Other Style Guides - **Muber**: [muber](https://github.com/muber/) - **National Geographic**: [natgeo](https://github.com/natgeo/) - **Nimbl3**: [nimbl3/javascript](https://github.com/nimbl3/javascript) + - **NullDev**: [NullDevCo/JavaScript-Styleguide](https://github.com/NullDevCo/JavaScript-Styleguide) - **Nulogy**: [nulogy/javascript](https://github.com/nulogy/javascript) - **Orange Hill Development**: [orangehill/javascript](https://github.com/orangehill/javascript) - **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript) From 69e34378c603bac579ce16fd5d635d3589ca23d0 Mon Sep 17 00:00:00 2001 From: ernestodebesto Date: Fri, 14 Sep 2018 17:20:22 +0200 Subject: [PATCH 011/302] Examples more consistent with the guidline comparison operator <= shows better the confusion when using arrow function, than just operator < --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6caee476d8..2a18c4c7ee 100644 --- a/README.md +++ b/README.md @@ -1052,18 +1052,18 @@ Other Style Guides ```javascript // bad - const itemHeight = item => item.height > 256 ? item.largeSize : item.smallSize; + const itemHeight = item => item.height <= 256 ? item.largeSize : item.smallSize; // bad - const itemHeight = (item) => item.height > 256 ? item.largeSize : item.smallSize; + const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize; // good - const itemHeight = item => (item.height > 256 ? item.largeSize : item.smallSize); + const itemHeight = item => (item.height <= 256 ? item.largeSize : item.smallSize); // good const itemHeight = (item) => { const { height, largeSize, smallSize } = item; - return height > 256 ? largeSize : smallSize; + return height <= 256 ? largeSize : smallSize; }; ``` From ffe4fe967c8e0635a5c21b9b0b62eed0b2aa655a Mon Sep 17 00:00:00 2001 From: Kevin Weber Date: Sat, 25 Aug 2018 22:12:12 -0700 Subject: [PATCH 012/302] [guide] Clarify wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a18c4c7ee..4bb08eca75 100644 --- a/README.md +++ b/README.md @@ -2764,7 +2764,7 @@ Other Style Guides ``` - - [19.15](#whitespace--computed-property-spacing) Enforce spacing inside of computed properties. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + - [19.15](#whitespace--computed-property-spacing) Enforce spacing inside of computed property brackets. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) ```javascript // bad From 064e3bf8d578736c38a7d74419ea6ba10ee46d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Tue, 27 Nov 2018 20:51:21 +0100 Subject: [PATCH 013/302] :) conflicting with rule 8.2 :D --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4bb08eca75..8924f32c18 100644 --- a/README.md +++ b/README.md @@ -1072,16 +1072,16 @@ Other Style Guides ```javascript // bad - (foo) => + foo => bar; - (foo) => + foo => (bar); // good - (foo) => bar; - (foo) => (bar); - (foo) => ( + foo => bar; + foo => (bar); + foo => ( bar ) ``` From 5d25a2ee61ebe44a10617efed41dc54bb36fb625 Mon Sep 17 00:00:00 2001 From: Honza Javorek Date: Tue, 18 Dec 2018 16:11:26 +0100 Subject: [PATCH 014/302] capitalize means first letter uppercase, the rest lowercase The examples and the reasoning indicates the author of the rule meant uppercase instead of capitalization. According to Wikipedia, capitalization is "writing a word with its first letter as a capital letter (uppercase letter) and the remaining letters in lower case", while the rule apparently tries to prevent exactly that. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8924f32c18..0ae718ed09 100644 --- a/README.md +++ b/README.md @@ -3268,7 +3268,7 @@ Other Style Guides ``` - - [23.9](#naming--Acronyms-and-Initialisms) Acronyms and initialisms should always be all capitalized, or all lowercased. + - [23.9](#naming--Acronyms-and-Initialisms) Acronyms and initialisms should always be all uppercased, or all lowercased. > Why? Names are for readability, not to appease a computer algorithm. From 80920a07c5144148d2987f39fb9558246552648e Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Wed, 19 Dec 2018 13:06:08 -0600 Subject: [PATCH 015/302] Add Terra to README list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ae718ed09..aa09b7d66b 100644 --- a/README.md +++ b/README.md @@ -3795,6 +3795,7 @@ Other Style Guides - **SysGarage**: [sysgarage/javascript-style-guide](https://github.com/sysgarage/javascript-style-guide) - **Syzygy Warsaw**: [syzygypl/javascript](https://github.com/syzygypl/javascript) - **Target**: [target/javascript](https://github.com/target/javascript) + - **Terra**: [terra](https://github.com/cerner?utf8=%E2%9C%93&q=terra&type=&language=) - **TheLadders**: [TheLadders/javascript](https://github.com/TheLadders/javascript) - **The Nerdery**: [thenerdery/javascript-standards](https://github.com/thenerdery/javascript-standards) - **T4R Technology**: [T4R-Technology/javascript](https://github.com/T4R-Technology/javascript) From 218c4fefbb010922866c18ef88e34ec66bb962a5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 28 Dec 2018 13:36:01 -0800 Subject: [PATCH 016/302] [eslint config] [base] [fix] disable `no-var` in legacy entry point Fixes #1935. --- packages/eslint-config-airbnb-base/legacy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index 7cc2441ab3..94870c9263 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -27,5 +27,6 @@ module.exports = { property: '__defineSetter__', message: 'Please use Object.defineProperty instead.', }], + 'no-var': 'off' } }; From 387755e8feedf7288983c89fe79bc0c03a2a8bbc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 28 Dec 2018 14:31:03 -0800 Subject: [PATCH 017/302] [meta] add disabled `no-useless-catch` config --- packages/eslint-config-airbnb-base/rules/best-practices.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index fbd65cf7d3..cc470408ee 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -280,6 +280,11 @@ module.exports = { // disallow unnecessary .call() and .apply() 'no-useless-call': 'off', + // Disallow unnecessary catch clauses + // https://eslint.org/docs/rules/no-useless-catch + // TODO: enable, semver-major + 'no-useless-catch': 'off', + // disallow useless string concatenation // https://eslint.org/docs/rules/no-useless-concat 'no-useless-concat': 'error', From 070e6200bb6c70fa31470ed7a6294f2497468b44 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 28 Dec 2018 14:32:02 -0800 Subject: [PATCH 018/302] [Dev Deps] update `markdownlint-cli` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fdcd7be15..581c94f612 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint-cli": "^0.10.0" + "markdownlint-cli": "^0.13.0" } } From 95286eb496acf09fb8360d5368f798b040a0b5c1 Mon Sep 17 00:00:00 2001 From: Rahil Vora Date: Mon, 7 Jan 2019 10:24:16 -0600 Subject: [PATCH 019/302] [guide] [react] add note about `forbid-prop-types` rule --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index 8ec7a92313..542aa1fd7d 100644 --- a/react/README.md +++ b/react/README.md @@ -28,6 +28,7 @@ This style guide is mostly based on the standards that are currently prevalent i - However, multiple [Stateless, or Pure, Components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) are allowed per file. eslint: [`react/no-multi-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md#ignorestateless). - Always use JSX syntax. - Do not use `React.createElement` unless you’re initializing the app from a file that is not JSX. + - [`react/forbid-prod-types`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`. ## Class vs `React.createClass` vs stateless From 955f4e93b8ae0ace9c9e4c7c8934b37c12d300d6 Mon Sep 17 00:00:00 2001 From: Hoang Date: Sun, 13 Jan 2019 18:55:49 +0700 Subject: [PATCH 020/302] Vietnamese translation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa09b7d66b..48ae6defe8 100644 --- a/README.md +++ b/README.md @@ -3827,7 +3827,7 @@ Other Style Guides - ![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) + - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [dangkyokhoang/javascript-style-guide](https://github.com/dangkyokhoang/javascript-style-guide) ## The JavaScript Style Guide Guide From b6c56cb070445d62717913758d4b54f1efbdac77 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Mon, 21 Jan 2019 13:39:53 +0100 Subject: [PATCH 021/302] [eslint config] [base] [patch] Allow use of `__REDUX_DEVTOOLS_EXTENSION_COMPOSE__` This style guide disallows the use of underscores in properties. However, the Redux browser extension requires the use of a variable named `__REDUX_DEVTOOLS_EXTENSION_COMPOSE__`. Since Redux is so popular with React, it makes sense to allow this. --- 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 d288bc5ad2..007f276417 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -369,7 +369,7 @@ module.exports = { // disallow dangling underscores in identifiers // https://eslint.org/docs/rules/no-underscore-dangle 'no-underscore-dangle': ['error', { - allow: [], + allow: ['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'], allowAfterThis: false, allowAfterSuper: false, enforceInMethodNames: true, From 1439ebe78d043ed8c206367b23406da7ddb7c3ce Mon Sep 17 00:00:00 2001 From: Telmen Munkhdalai Date: Sat, 26 Jan 2019 16:55:34 +0800 Subject: [PATCH 022/302] [editorial] [react] fix typo --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 542aa1fd7d..51e035db46 100644 --- a/react/README.md +++ b/react/README.md @@ -28,7 +28,7 @@ This style guide is mostly based on the standards that are currently prevalent i - However, multiple [Stateless, or Pure, Components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) are allowed per file. eslint: [`react/no-multi-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md#ignorestateless). - Always use JSX syntax. - Do not use `React.createElement` unless you’re initializing the app from a file that is not JSX. - - [`react/forbid-prod-types`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`. + - [`react/forbid-prop-types`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`. ## Class vs `React.createClass` vs stateless From 25f11fb31e787a055329bdfaf9c4ad572780ac99 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 26 Jan 2019 10:12:49 -0800 Subject: [PATCH 023/302] [eslint config] [patch] extend `no-underscore-dangle` to allow for redux dev tools in the main config instead --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- packages/eslint-config-airbnb/rules/react.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 007f276417..d288bc5ad2 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -369,7 +369,7 @@ module.exports = { // disallow dangling underscores in identifiers // https://eslint.org/docs/rules/no-underscore-dangle 'no-underscore-dangle': ['error', { - allow: ['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'], + allow: [], allowAfterThis: false, allowAfterSuper: false, enforceInMethodNames: true, diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 527274dad6..eb3b648277 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -1,3 +1,8 @@ +const assign = require('object.assign'); +const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules; + +const dangleRules = baseStyleRules['no-underscore-dangle']; + module.exports = { plugins: [ 'react', @@ -12,6 +17,10 @@ module.exports = { // View link below for react rules documentation // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules rules: { + 'no-underscore-dangle': [dangleRules[0], assign({}, dangleRules[1], { + allow: dangleRules[1].allow.concat(['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']), + })], + // Specify whether double or single quotes should be used in JSX attributes // https://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': ['error', 'prefer-double'], From d8256fc886717c758cc3830478e072d897bd68b9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 27 Jan 2019 13:41:14 -0800 Subject: [PATCH 024/302] [eslint config] [*] [deps] update `object.entries`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- .../eslint-config-airbnb-base/rules/imports.js | 4 ++++ packages/eslint-config-airbnb/package.json | 14 +++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4ec1497674..3ad23c4477 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 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.14.0", + "eslint-plugin-import": "^2.15.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.14.0" + "eslint-plugin-import": "^2.15.0" }, "engines": { "node": ">= 4" @@ -73,6 +73,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.5", "object.assign": "^4.1.0", - "object.entries": "^1.0.4" + "object.entries": "^1.1.0" } } diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index fbeca8dc83..1853ae05d5 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -221,6 +221,10 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md 'import/no-default-export': 'off', + // Prohibit named exports. this is a terrible rule, do not use it. + // https://github.com/benmosher/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md + 'import/no-named-export': 'off', + // Forbid a module from importing itself // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 'import/no-self-import': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index b45487a126..d5710640a1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^13.1.0", "object.assign": "^4.1.0", - "object.entries": "^1.0.4" + "object.entries": "^1.1.0" }, "devDependencies": { "babel-preset-airbnb": "^2.5.3", @@ -64,9 +64,9 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-jsx-a11y": "^6.1.1", - "eslint-plugin-react": "^7.11.0", + "eslint-plugin-import": "^2.15.0", + "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-react": "^7.12.4", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.2", @@ -74,9 +74,9 @@ }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-jsx-a11y": "^6.1.1", - "eslint-plugin-react": "^7.11.0" + "eslint-plugin-import": "^2.15.0", + "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-react": "^7.12.4" }, "engines": { "node": ">= 4" From 96f95fa35e23f015448445b8d5bb7ac8e03a739a Mon Sep 17 00:00:00 2001 From: tclindner Date: Tue, 29 Jan 2019 21:58:23 -0600 Subject: [PATCH 025/302] [eslint config] [base] [patch] `no-extraneous-dependencies`: Add jest.setup.js to devDeps --- 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 1853ae05d5..6f0acf0563 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 + '**/jest.setup.js', // jest setup '**/vue.config.js', // vue-cli config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config From 6ef45d4bab39813e1ff31e41112009ffcb62277c Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Wed, 6 Feb 2019 14:09:18 +0400 Subject: [PATCH 026/302] [guide] make "good" example match "bad" example more closely --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48ae6defe8..49d025fbc2 100644 --- a/README.md +++ b/README.md @@ -963,7 +963,7 @@ Other Style Guides }); // good - [1, 2, 3].map(number => `A string containing the ${number}.`); + [1, 2, 3].map(number => `A string containing the ${number + 1}.`); // good [1, 2, 3].map((number) => { From 4f15da6146fc00096a909e4c53808a3068a4d853 Mon Sep 17 00:00:00 2001 From: Pier-Luc Brault Date: Thu, 7 Feb 2019 11:48:32 -0500 Subject: [PATCH 027/302] [eslint config] [*] [readme] Improve eslint config setup instructions for yarn --- packages/eslint-config-airbnb-base/README.md | 6 ++++-- packages/eslint-config-airbnb/README.md | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 9998d81fb3..a5c3b1075e 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -12,8 +12,6 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. -If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. - 1. Install the correct versions of each package, which are listed by the command: ```sh @@ -26,6 +24,10 @@ If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependenci npx install-peerdeps --dev eslint-config-airbnb-base ``` + If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly. + Otherwise, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. + + If using **npm < 5**, Linux/OSX users can run ```sh diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index a03c378fa3..f7f3c6390d 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,8 +12,6 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. - 1. Install the correct versions of each package, which are listed by the command: ```sh @@ -26,6 +24,9 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t npx install-peerdeps --dev eslint-config-airbnb ``` + If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly. + Otherwise, run `npm info "eslint-config-airbnb@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. + If using **npm < 5**, Linux/OSX users can run ```sh From 8694a873783629c3461b05f4ba654904d3d1ac42 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 14 Feb 2019 11:57:20 -0800 Subject: [PATCH 028/302] [eslint config] [react] [patch] Turn off `react/no-multi-comp` Splitting up a component into multiple components can be useful for many reasons, including making important performance optimizations. This lint rule discourages splitting up components because it forces you to: create a new file, copy over all the relevant imports, move over any local functions/values (or move them into yet another shared module), export the component (which makes your split off component now a public export), and re-import it into the new module. Having multiple components per file shouldn't be much different from having multiple functions per file. And you shouldn't be forced to make a component a public export if it's really just an internal implementation detail of another component. There's an argument to be made about _exporting_ multiple components, but mostly just in the context of React.lazy because it can only import default exports and you don't want something else in that file being statically imported (because that will prevent it from being code-split). --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index eb3b648277..8a9a10f360 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -194,7 +194,7 @@ module.exports = { // Prevent multiple component definition per file // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md - 'react/no-multi-comp': ['error', { ignoreStateless: true }], + 'react/no-multi-comp': 'off', // Prevent usage of setState // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md From 834d717c7bfdd08fe0f9fad2920626eb0e179398 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 17 Feb 2019 14:14:54 -0800 Subject: [PATCH 029/302] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `tape` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 3ad23c4477..88b78791c5 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 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.15.0", + "eslint-plugin-import": "^2.16.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", - "tape": "^4.9.1" + "tape": "^4.10.1" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.15.0" + "eslint-plugin-import": "^2.16.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d5710640a1..3188684425 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -64,13 +64,13 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.15.0", - "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-import": "^2.16.0", + "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-react": "^7.12.4", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.2", - "tape": "^4.9.1" + "tape": "^4.10.1" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", From a71c2d1ad3ff71627ea2848ae21ea35d5d7ef061 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 17 Feb 2019 14:20:53 -0800 Subject: [PATCH 030/302] [eslint config] add disabled `jsx-fragments` rule --- packages/eslint-config-airbnb/rules/react.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 8a9a10f360..fdf48690a3 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -460,6 +460,11 @@ module.exports = { // Prevent usage of UNSAFE_ methods // https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md 'react/no-unsafe': 'off', + + // Enforce shorthand or standard form for React fragments + // https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md + // TODO: enable, semver-major + 'react/jsx-fragments': ['off', 'syntax'], }, settings: { From da0cf088316692b59751bfd64e99125a4acd3869 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 17 Feb 2019 14:21:15 -0800 Subject: [PATCH 031/302] [Tests] on `node` `v11` --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2fcc94de67..90d9d857d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "11" - "10" - "9" - "8" From 495a62aaa9c2110cb06e6243d91373aa4fb384da Mon Sep 17 00:00:00 2001 From: Matthias Pries Date: Wed, 13 Feb 2019 13:52:39 +0100 Subject: [PATCH 032/302] [guide] fix example 4.7 for arrays method callbacks --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 49d025fbc2..9efbad4d15 100644 --- a/README.md +++ b/README.md @@ -423,13 +423,11 @@ Other Style Guides // bad - no returned value means `acc` becomes undefined after the first iteration [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => { const flatten = acc.concat(item); - acc[index] = flatten; }); // good [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => { const flatten = acc.concat(item); - acc[index] = flatten; return flatten; }); From be07f7a020749b37ce35a966a5c11ce76d5756ac Mon Sep 17 00:00:00 2001 From: Anton Honcharuk Date: Sun, 24 Feb 2019 13:28:34 +0200 Subject: [PATCH 033/302] [guide] [react] add more context about arrow functions, as props and in class fields --- react/README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/react/README.md b/react/README.md index 51e035db46..4d2aa63fb3 100644 --- a/react/README.md +++ b/react/README.md @@ -531,7 +531,7 @@ We don’t recommend using indexes for keys if the order of items may change. ## Methods - - Use arrow functions to close over local variables. + - Use arrow functions to close over local variables. It is handy when you need to pass additional data to an event handler. Although, make sure they [do not massively hurt performance](https://www.bignerdranch.com/blog/choosing-the-best-approach-for-react-event-handlers/), in particular when passed to custom components that might be PureComponents, because they will trigger a possibly needless rerender every time. ```jsx function ItemList(props) { @@ -540,7 +540,7 @@ We don’t recommend using indexes for keys if the order of items may change. {props.items.map((item, index) => ( doSomethingWith(item.name, index)} + onClick={(event) => doSomethingWith(event, item.name, index)} /> ))} @@ -550,7 +550,7 @@ We don’t recommend using indexes for keys if the order of items may change. - Bind event handlers for the render method in the constructor. eslint: [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md) - > Why? A bind call in the render path creates a brand new function on every single render. + > Why? A bind call in the render path creates a brand new function on every single render. Do not use arrow functions in class fields, because it makes them [challenging to test and debug, and can negatively impact performance](https://medium.com/@charpeni/arrow-functions-in-class-properties-might-not-be-as-great-as-we-think-3b3551c440b1), and because conceptually, class fields are for data, not logic. ```jsx // bad @@ -564,6 +564,17 @@ We don’t recommend using indexes for keys if the order of items may change. } } + // very bad + class extends React.Component { + onClickDiv = () => { + // do stuff + } + + render() { + return
+ } + } + // good class extends React.Component { constructor(props) { From b85baeafed8b66fdd9756439a0b8774860147913 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 3 Mar 2019 23:23:14 -0800 Subject: [PATCH 034/302] [eslint config] [base] [meta] add disabled `prefer-named-capture-group` rule --- .../eslint-config-airbnb-base/rules/best-practices.js | 4 ++++ packages/eslint-config-airbnb-base/rules/es6.js | 1 + packages/eslint-config-airbnb-base/rules/style.js | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index cc470408ee..d8dbfce90b 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -311,6 +311,10 @@ module.exports = { // https://eslint.org/docs/rules/prefer-promise-reject-errors 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], + // Suggest using named capture group in regular expression + // https://eslint.org/docs/rules/prefer-named-capture-group + 'prefer-named-capture-group': 'off', + // require use of the second argument for parseInt() radix: 'error', diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index f9e5198c96..9c6328700e 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -158,6 +158,7 @@ module.exports = { // https://eslint.org/docs/rules/sort-imports 'sort-imports': ['off', { ignoreCase: false, + ignoreDeclarationSort: false, ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], }], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index d288bc5ad2..1908c3ea81 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -422,7 +422,13 @@ module.exports = { 'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }], // disallow padding within blocks - 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], + // TODO, semver-major: uncomment option + 'padded-blocks': ['error', { + blocks: 'never', + classes: 'never', + switches: 'never', + // allowSingleLineBlocks: true, + }], // Require or disallow padding lines between statements // https://eslint.org/docs/rules/padding-line-between-statements From 60b96d322277c4c71a21a05caba8eb3320e0e3fa Mon Sep 17 00:00:00 2001 From: Anton Honcharuk Date: Wed, 27 Feb 2019 20:25:32 +0200 Subject: [PATCH 035/302] [guide] Add a 19.9 bullet in a Whitespace section - with explanations about preventing two blank lines from appearing consecutively in JavaScript code --- README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9efbad4d15..66eecb118a 100644 --- a/README.md +++ b/README.md @@ -2656,8 +2656,63 @@ Other Style Guides } ``` + + - [19.9](#whitespace--no-multiple-blanks) Do not use multiple blank lines to pad your code. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) + + + ```javascript + // bad + class Person { + constructor(fullName, email, birthday) { + this.fullName = fullName; + + + this.email = email; + + + this.setAge(birthday); + } + + + setAge(birthday) { + const today = new Date(); + + + const age = this.getAge(today, birthday); + + + this.age = age; + } + + + getAge(today, birthday) { + // .. + } + } + + // good + class Person { + constructor(fullName, email, birthday) { + this.fullName = fullName; + this.email = email; + this.setAge(birthday); + } + + + setAge(birthday) { + const today = new Date(); + const age = getAge(today, birthday); + this.age = age; + } + + getAge(today, birthday) { + // .. + } + } + ``` + - - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) + - [19.10](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) ```javascript // bad @@ -2682,7 +2737,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) + - [19.11](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) ```javascript // bad @@ -2695,7 +2750,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) + - [19.12](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) ```javascript // bad @@ -2706,7 +2761,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) + - [19.13](#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. @@ -2736,7 +2791,7 @@ Other Style Guides ``` - - [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) + - [19.14](#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 @@ -2749,7 +2804,7 @@ Other Style Guides ``` - - [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) + - [19.15](#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 @@ -2762,7 +2817,7 @@ Other Style Guides ``` - - [19.15](#whitespace--computed-property-spacing) Enforce spacing inside of computed property brackets. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + - [19.16](#whitespace--computed-property-spacing) Enforce spacing inside of computed property brackets. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) ```javascript // bad @@ -2779,7 +2834,7 @@ Other Style Guides ``` - - [19.16](#whitespace--func-call-spacing) Avoid spaces between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) + - [19.17](#whitespace--func-call-spacing) Avoid spaces between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) ```javascript // bad @@ -2793,7 +2848,7 @@ Other Style Guides ``` - - [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) + - [19.18](#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 @@ -2805,10 +2860,10 @@ Other Style Guides ``` - - [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-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) + - [19.20](#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 From 447466681e9c38858ef81af7a84aada801630352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Berthommier?= Date: Wed, 10 Apr 2019 10:22:57 +0200 Subject: [PATCH 036/302] [guide] remove extra blank line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 66eecb118a..4621f1d032 100644 --- a/README.md +++ b/README.md @@ -2698,7 +2698,6 @@ Other Style Guides this.setAge(birthday); } - setAge(birthday) { const today = new Date(); const age = getAge(today, birthday); From 117d4fce49096bec1cb5d3c030031aca994ddb5a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 27 Apr 2019 23:27:07 -0700 Subject: [PATCH 037/302] [Tests] fix issue with eslint dev deps --- packages/eslint-config-airbnb/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 3188684425..d7b8662945 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -11,7 +11,7 @@ "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", - "link:eslint": "cd node_modules/eslint && npm link && cd -", + "link:eslint": "cd node_modules/eslint && npm link --production && 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 eslint >/dev/null &" From 5cd011dfa1e07e292444d3632d582ffb87fceec9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 27 Apr 2019 23:51:44 -0700 Subject: [PATCH 038/302] [eslint config] [base] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 88b78791c5..462bfcd0b2 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 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.16.0", + "eslint-plugin-import": "^2.17.2", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", "tape": "^4.10.1" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.16.0" + "eslint-plugin-import": "^2.17.2" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 6f0acf0563..1c4e08d36c 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -248,5 +248,14 @@ module.exports = { // 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', + + // Reports modules without any exports, or with unused exports + // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md + // TODO: enable, semver-major + 'import/no-unused-modules': ['off', { + ignoreExports: [], + missingExports: true, + unusedExports: true, + }], }, }; From 1310ade9d0e4d1e5625f29b89d4c902bebc8cc11 Mon Sep 17 00:00:00 2001 From: Joseph Nields Date: Sat, 27 Apr 2019 14:00:50 -0700 Subject: [PATCH 039/302] [eslint config] [base] [patch] Ignore property modifications of `staticContext` params React Router passes a `staticContext` property to children to allow signalling status codes and redirected URLs, by allowing children to assign property values to it during render --- packages/eslint-config-airbnb-base/rules/best-practices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index d8dbfce90b..b16a974ccf 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -186,6 +186,7 @@ module.exports = { 'res', // for Express responses 'response', // for Express responses '$scope', // for Angular 1 scopes + 'staticContext', // for ReactRouter context ] }], From 19701d4a0cf69ff05e9a9b9c7e62c7126b0ea73f Mon Sep 17 00:00:00 2001 From: Kimball Bighorse Date: Thu, 9 May 2019 09:40:43 -0700 Subject: [PATCH 040/302] [inthewild] Add Coeur d'Alene Tribe --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4621f1d032..b5df3946a2 100644 --- a/README.md +++ b/README.md @@ -3779,6 +3779,7 @@ Other Style Guides - **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) + - **Coeur d'Alene Tribe**: [www.cdatribe-nsn.gov](https://www.cdatribe-nsn.gov) - **ComparaOnline**: [comparaonline/javascript](https://github.com/comparaonline/javascript-style-guide) - **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide) - **DailyMotion**: [dailymotion/javascript](https://github.com/dailymotion/javascript) From 4539dbcf17b960ab650665bc95421dc8d0d3276e Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Fri, 24 May 2019 16:29:24 +0800 Subject: [PATCH 041/302] [guide] remove redundant spaces --- README.md | 8 ++++---- react/README.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b5df3946a2..57f90f0651 100644 --- a/README.md +++ b/README.md @@ -3073,7 +3073,7 @@ Other Style Guides - [22.1](#coercion--explicit) Perform type coercion at the beginning of the statement. - - [22.2](#coercion--strings) Strings: eslint: [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) + - [22.2](#coercion--strings) Strings: eslint: [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) ```javascript // => this.reviewScore = 9; @@ -3360,7 +3360,7 @@ Other Style Guides > Why? This is an additional tool to assist in situations where the programmer would be unsure if a variable might ever change. UPPERCASE_VARIABLES are letting the programmer know that they can trust the variable (and its properties) not to change. - What about all `const` variables? - This is unnecessary, so uppercasing should not be used for constants within a file. It should be used for exported constants however. - - What about exported objects? - Uppercase at the top level of export (e.g. `EXPORTED_OBJECT.key`) and maintain that all nested properties do not change. + - What about exported objects? - Uppercase at the top level of export (e.g. `EXPORTED_OBJECT.key`) and maintain that all nested properties do not change. ```javascript // bad @@ -3467,7 +3467,7 @@ Other Style Guides ## Events - - [25.1](#events--hash) When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass an object literal (also known as a "hash") instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of: + - [25.1](#events--hash) When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass an object literal (also known as a "hash") instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of: ```javascript // bad @@ -3721,7 +3721,7 @@ Other Style Guides - [JavaScript: The Good Parts](https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford - [JavaScript Patterns](https://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov - - [Pro JavaScript Design Patterns](https://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X) - Ross Harmes and Dustin Diaz + - [Pro JavaScript Design Patterns](https://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X) - Ross Harmes and Dustin Diaz - [High Performance Web Sites: Essential Knowledge for Front-End Engineers](https://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309) - Steve Souders - [Maintainable JavaScript](https://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680) - Nicholas C. Zakas - [JavaScript Web Applications](https://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X) - Alex MacCaw diff --git a/react/README.md b/react/README.md index 4d2aa63fb3..87dbcb9996 100644 --- a/react/README.md +++ b/react/README.md @@ -447,13 +447,13 @@ We don’t recommend using indexes for keys if the order of items may change. ```jsx // bad render() { - const { irrelevantProp, ...relevantProps } = this.props; + const { irrelevantProp, ...relevantProps } = this.props; return } // good render() { - const { irrelevantProp, ...relevantProps } = this.props; + const { irrelevantProp, ...relevantProps } = this.props; return } ``` From 76ff7c7f793633596c262b78ae876da15839a65d Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Mon, 24 Jun 2019 22:45:35 +0900 Subject: [PATCH 042/302] [editorial] [docs] correct JavaScript capitalization --- README.md | 2 +- packages/eslint-config-airbnb-base/README.md | 2 +- packages/eslint-config-airbnb/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 57f90f0651..21b636d0e0 100644 --- a/README.md +++ b/README.md @@ -3670,7 +3670,7 @@ Other Style Guides - [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/13) - [innerHTML vs textContent for script text](https://jsperf.com/innerhtml-vs-textcontent-for-script-text) - [Long String Concatenation](https://jsperf.com/ya-string-concat) - - [Are Javascript functions like `map()`, `reduce()`, and `filter()` optimized for traversing arrays?](https://www.quora.com/JavaScript-programming-language-Are-Javascript-functions-like-map-reduce-and-filter-already-optimized-for-traversing-array/answer/Quildreen-Motta) + - [Are JavaScript functions like `map()`, `reduce()`, and `filter()` optimized for traversing arrays?](https://www.quora.com/JavaScript-programming-language-Are-Javascript-functions-like-map-reduce-and-filter-already-optimized-for-traversing-array/answer/Quildreen-Motta) - Loading... **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index a5c3b1075e..685e50060b 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -84,7 +84,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. 2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc -See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. +See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's JavaScript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. ### eslint-config-airbnb-base/whitespace diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index f7f3c6390d..7296176e26 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -68,7 +68,7 @@ This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.co This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and +See [Airbnb's JavaScript styleguide](https://github.com/airbnb/javascript) and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. From a9a83d9150ce2903032d64593243e3490f332b9f Mon Sep 17 00:00:00 2001 From: Glenn Goossens <48956933+glgoose@users.noreply.github.com> Date: Thu, 27 Jun 2019 11:37:32 +0200 Subject: [PATCH 043/302] [guide] add link to new version of Google Style Guide Add link to a newer version of this guide that includes ECMAScript 6th Edition features --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21b636d0e0..db6eed916c 100644 --- a/README.md +++ b/README.md @@ -3697,7 +3697,8 @@ Other Style Guides **Other Style Guides** - - [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml) + - [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) + - [Google JavaScript Style Guide (Old)](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) From 9fbe07f282ddff9585423a4eee738022e4f7ea33 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Jul 2019 15:05:02 -0700 Subject: [PATCH 044/302] [eslint-config] [base] v13.2.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 14 ++++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index c945013b25..4b475827cb 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,17 @@ +13.2.0 / 2019-07-01 +================== + - [minor] Enforce dangling underscores in method names (#1907) + - [fix] disable `no-var` in legacy entry point + - [patch] Ignore property modifications of `staticContext` params (#2029) + - [patch] `no-extraneous-dependencies`: Add jest.setup.js to devDeps (#1998) + - [meta] add disabled `prefer-named-capture-group` rule + - [meta] add disabled `no-useless-catch` config + - [deps] Switch to confusing-browser-globals (#1961) + - [deps] update `object.entries`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape` + - [docs] correct JavaScript capitalization (#2046) + - [readme] Improve eslint config setup instructions for yarn (#2001) + - [docs] fix docs for whitespace config (#1914, #1871) + 13.1.0 / 2018-08-13 ================== - [new] add eslint v5 support (#1834) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 462bfcd0b2..52603b1bb0 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": "13.1.0", + "version": "13.2.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7ea44cfc798b6789150ac7d22e7d6c399b3e6f18 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Jul 2019 16:12:08 -0700 Subject: [PATCH 045/302] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-jsx-a11y`, `babel-preset-airbnb`, `tape` --- packages/eslint-config-airbnb/package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d7b8662945..2df77c855f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,29 +54,29 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^13.1.0", + "eslint-config-airbnb-base": "^13.2.0", "object.assign": "^4.1.0", "object.entries": "^1.1.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.5.3", + "babel-preset-airbnb": "^2.6.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.16.0", - "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-react": "^7.12.4", + "eslint-plugin-import": "^2.18.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.14.2", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.2", - "tape": "^4.10.1" + "tape": "^4.11.0" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.15.0", - "eslint-plugin-jsx-a11y": "^6.2.0", - "eslint-plugin-react": "^7.12.4" + "eslint-plugin-import": "^2.18.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.14.2" }, "engines": { "node": ">= 4" From 873f302b00398e59f8622e8193f2f47f66960066 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Jul 2019 16:17:49 -0700 Subject: [PATCH 046/302] [eslint config] v17.1.1 --- packages/eslint-config-airbnb/CHANGELOG.md | 10 ++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 87bbfc8823..ed2d7af0e3 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,13 @@ +17.1.1 / 2019-07-01 +================== + - [patch] Turn off `react/no-multi-comp` (#2006) + - [patch] extend `no-underscore-dangle` to allow for redux dev tools in the main config instead (#1996) + - [meta] add disabled `jsx-fragments` rule + - [deps] update `eslint-config-airbnb-base`, `object.entries`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-jsx-a11y`, `babel-preset-airbnb`, `tape` (#2005, etc) + - [docs] correct JavaScript capitalization (#2046) + - [docs] fix docs for whitespace config (#1914, #1871) + - [readme] Improve eslint config setup instructions for yarn (#2001) + 17.1.0 / 2018-08-13 ================== - [new] add eslint v5 support diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2df77c855f..5bb3d78ba4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "17.1.0", + "version": "17.1.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 21493ad7e93d19c133481f833c1d1a3bdfe30098 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Jul 2019 16:26:52 -0700 Subject: [PATCH 047/302] [eslint config] [base] [deps] update `confusing-browser-globals`, `eslint-plugin-import`, `tape`, `babel-preset-airbnb` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 52603b1bb0..67a010f839 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,25 +53,25 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.5.3", + "babel-preset-airbnb": "^2.6.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.17.2", + "eslint-plugin-import": "^2.18.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", - "tape": "^4.10.1" + "tape": "^4.11.0" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.17.2" + "eslint-plugin-import": "^2.18.0" }, "engines": { "node": ">= 4" }, "dependencies": { - "confusing-browser-globals": "^1.0.5", + "confusing-browser-globals": "^1.0.7", "object.assign": "^4.1.0", "object.entries": "^1.1.0" } From 6a50516df70457d8b70fe4e6b2a02d5aaefb0f7d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Jul 2019 17:07:38 -0700 Subject: [PATCH 048/302] [eslint config] [meta] add disabled config for new react and a11y rules --- .../eslint-config-airbnb/rules/react-a11y.js | 30 +++++++++++++++++ packages/eslint-config-airbnb/rules/react.js | 33 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index dbb073fa67..ffb4d28c29 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -66,6 +66,36 @@ module.exports = { depth: 25 }], + // Enforce that a control (an interactive element) has a text label. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md + // TODO, semver-major: enable + 'jsx-a11y/control-has-associated-label': ['off', { + labelAttributes: ['label'], + controlComponents: [], + ignoreElements: [ + 'audio', + 'canvas', + 'embed', + 'input', + 'textarea', + 'tr', + 'video', + ], + ignoreRoles: [ + 'grid', + 'listbox', + 'menu', + 'menubar', + 'radiogroup', + 'row', + 'tablist', + 'toolbar', + 'tree', + 'treegrid', + ], + depth: 5, + }], + // 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', diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index fdf48690a3..bb2373cdbc 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -465,6 +465,39 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md // TODO: enable, semver-major 'react/jsx-fragments': ['off', 'syntax'], + + // Enforce linebreaks in curly braces in JSX attributes and expressions. + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md + // TODO: enable, semver-minor + 'react/jsx-curly-newline': ['off', { + multiline: 'consistent', + single: 'consistent', + }], + + // Enforce state initialization style + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md + // TODO: enable, semver-minor + // TODO: set to "always" once babel-preset-airbnb supports public class fields + 'react/state-in-constructor': ['off', 'never'], + + // Enforces where React component static properties should be positioned + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md + // TODO: enable, semver-minor + // TODO: set to "static public field" once babel-preset-airbnb supports public class fields + 'react/static-property-placement': ['off', 'property assignment'], + + // Disallow JSX props spreading + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md + // TODO: enable, semver-major + 'react/jsx-props-no-spreading': ['off', { + html: 'enforce', + custom: 'enforce', + exceptions: [], + }], + + // Enforce that props are read-only + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md + 'react/prefer-read-only-props': 'off', }, settings: { From 036612ec3d8af223d2a3adc40aca70365b5612fd Mon Sep 17 00:00:00 2001 From: Perttu Ristimella Date: Thu, 4 Jul 2019 14:59:47 +0300 Subject: [PATCH 049/302] [inthewile] Add Happeo to users list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db6eed916c..49f2b07e97 100644 --- a/README.md +++ b/README.md @@ -3801,6 +3801,7 @@ Other Style Guides - **GreenChef**: [greenchef/javascript](https://github.com/greenchef/javascript) - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript) - **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript) + - **Happeo**: [happeo/javascript](https://github.com/happeo/javascript) - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) - **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript-style-guide) - **Huballin**: [huballin](https://github.com/huballin/) From 030e23b13e9d21b0775239c475ea137ad13e8a64 Mon Sep 17 00:00:00 2001 From: Mathieu Dutto Date: Wed, 24 Jul 2019 15:36:48 +0200 Subject: [PATCH 050/302] [guide] Fix npm package has usage example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49f2b07e97..931b69d0c0 100644 --- a/README.md +++ b/README.md @@ -298,10 +298,10 @@ Other Style Guides // best const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. + console.log(has.call(object, key)); /* or */ import has from 'has'; // https://www.npmjs.com/package/has - // ... - console.log(has.call(object, key)); + console.log(has(object, key)); ``` From 6c0a884179c5fcb7b52d516dcfb54c6bcf4dc6c1 Mon Sep 17 00:00:00 2001 From: Yohan Siguret Date: Sat, 3 Aug 2019 00:57:12 +0200 Subject: [PATCH 051/302] [guide] fix dead jsperf links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 931b69d0c0..e478830ca8 100644 --- a/README.md +++ b/README.md @@ -3665,11 +3665,11 @@ Other Style Guides - [On Layout & Web Performance](https://www.kellegous.com/j/2013/01/26/layout-performance/) - [String vs Array Concat](https://jsperf.com/string-vs-array-concat/2) - - [Try/Catch Cost In a Loop](https://jsperf.com/try-catch-in-loop-cost) + - [Try/Catch Cost In a Loop](https://jsperf.com/try-catch-in-loop-cost/12) - [Bang Function](https://jsperf.com/bang-function) - - [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/13) + - [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/164) - [innerHTML vs textContent for script text](https://jsperf.com/innerhtml-vs-textcontent-for-script-text) - - [Long String Concatenation](https://jsperf.com/ya-string-concat) + - [Long String Concatenation](https://jsperf.com/ya-string-concat/38) - [Are JavaScript functions like `map()`, `reduce()`, and `filter()` optimized for traversing arrays?](https://www.quora.com/JavaScript-programming-language-Are-Javascript-functions-like-map-reduce-and-filter-already-optimized-for-traversing-array/answer/Quildreen-Motta) - Loading... From 792bb567e5d7437a381dfd9ab530b13fa2331c2e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 14:04:36 -0700 Subject: [PATCH 052/302] [eslint config] [*] update `eslint-find-rules`, `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 67a010f839..a35f36526c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,15 +57,15 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", - "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.18.0", + "eslint-find-rules": "^3.4.0", + "eslint-plugin-import": "^2.18.2", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", "tape": "^4.11.0" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.18.0" + "eslint-plugin-import": "^2.18.2" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 5bb3d78ba4..c7d7940c1e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,8 +63,8 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", - "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.18.0", + "eslint-find-rules": "^3.4.0", + "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.2", "in-publish": "^2.0.0", @@ -74,7 +74,7 @@ }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.18.0", + "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.2" }, From 820ccf7652f2f67a18b095a613ba99f9159eac93 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 14:06:58 -0700 Subject: [PATCH 053/302] [eslint config] [*] [tests] use `eclint` instead of `editorconfig-tools` --- .editorconfig | 5 ++++- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/test/requires.js | 5 +---- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/test/requires.js | 5 +---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.editorconfig b/.editorconfig index 49c154da45..db6f34c77c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,4 +8,7 @@ trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf # editorconfig-tools is unable to ignore longs strings or urls -max_line_length = null +max_line_length = off + +[CHANGELOG.md] +indent_size = false diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a35f36526c..2bb9923dd8 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -4,7 +4,7 @@ "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { - "prelint": "editorconfig-tools check * rules/* test/*", + "prelint": "eclint check * rules/* test/*", "lint": "eslint --report-unused-disable-directives .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", @@ -55,7 +55,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.6.0", "babel-tape-runner": "^2.0.1", - "editorconfig-tools": "^0.1.1", + "eclint": "^2.8.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", diff --git a/packages/eslint-config-airbnb-base/test/requires.js b/packages/eslint-config-airbnb-base/test/requires.js index 180a09bf42..8176480fe1 100644 --- a/packages/eslint-config-airbnb-base/test/requires.js +++ b/packages/eslint-config-airbnb-base/test/requires.js @@ -1,7 +1,4 @@ -/* eslint - strict: 0, - global-require: 0, - */ +/* eslint strict: 0, global-require: 0 */ 'use strict'; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c7d7940c1e..ff57a9312e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -4,7 +4,7 @@ "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { - "prelint": "editorconfig-tools check * rules/* test/*", + "prelint": "eclint check * rules/* test/*", "lint": "eslint .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", @@ -61,7 +61,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.6.0", "babel-tape-runner": "^2.0.1", - "editorconfig-tools": "^0.1.1", + "eclint": "^2.8.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", diff --git a/packages/eslint-config-airbnb/test/requires.js b/packages/eslint-config-airbnb/test/requires.js index 0ab4aae58d..964318521e 100644 --- a/packages/eslint-config-airbnb/test/requires.js +++ b/packages/eslint-config-airbnb/test/requires.js @@ -1,7 +1,4 @@ -/* eslint - strict: 0, - global-require: 0, - */ +/* eslint strict: 0, global-require: 0 */ 'use strict'; From 945c62f22996d0fd3e7917d2769d60b1dd533e49 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 14:11:27 -0700 Subject: [PATCH 054/302] [Tests] on `node` `v12` --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 90d9d857d2..87d8258fac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "12" - "11" - "10" - "9" From 3b18fea1ede26833c432e96f4330edcddd2f12b7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 14:20:40 -0700 Subject: [PATCH 055/302] [Tests] only run tests in non-lint per-package travis job --- 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 2bb9923dd8..753fd50076 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -12,7 +12,7 @@ "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", "pretravis": ":", - "travis": "npm run --silent test", + "travis": "npm run --silent tests-only", "posttravis": ":" }, "repository": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index ff57a9312e..0cc40907cc 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -13,7 +13,7 @@ "test": "npm run --silent tests-only", "link:eslint": "cd node_modules/eslint && npm link --production && 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", + "travis": "npm run --silent tests-only", "posttravis": "npm unlink --no-save eslint-config-airbnb-base eslint >/dev/null &" }, "repository": { From 8eacf24310f314abd40a1266e90818e11fefbdca Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 14:18:55 -0700 Subject: [PATCH 056/302] [eslint config] [*] [breaking] add eslint v6, drop eslint v4 See #2036 --- .travis.yml | 32 ++++++++----------- .../eslint-config-airbnb-base/package.json | 6 ++-- .../eslint-config-airbnb-base/whitespace.js | 2 +- packages/eslint-config-airbnb/package.json | 6 ++-- packages/eslint-config-airbnb/whitespace.js | 2 +- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87d8258fac..df4ad7cf56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,6 @@ node_js: - "10" - "9" - "8" - - "7" - - "6" - - "5" - - "4" before_install: - 'nvm install-latest-npm' install: @@ -20,37 +16,37 @@ script: sudo: false env: matrix: + - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=6 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=5 PACKAGE=eslint-config-airbnb-base + env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true - exclude: - - node_js: "5" + - node_js: "7" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "5" + - node_js: "7" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb - - node_js: "4" + - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "4" + - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + exclude: allow_failures: + - node_js: "11" - node_js: "9" - node_js: "7" - - node_js: "5" + - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=6 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 753fd50076..5959e0f89b 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.6.0", "babel-tape-runner": "^2.0.1", "eclint": "^2.8.1", - "eslint": "^4.19.1 || ^5.3.0", + "eslint": "^5.16.0 || ^6.1.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "in-publish": "^2.0.0", @@ -64,11 +64,11 @@ "tape": "^4.11.0" }, "peerDependencies": { - "eslint": "^4.19.1 || ^5.3.0", + "eslint": "^5.16.0 || ^6.1.0", "eslint-plugin-import": "^2.18.2" }, "engines": { - "node": ">= 4" + "node": ">= 6" }, "dependencies": { "confusing-browser-globals": "^1.0.7", diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index d215d4ae6a..917ee0c50e 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -7,7 +7,7 @@ const baseConfig = require('.'); function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); - const baseRules = cli.getConfigForFile('./').rules; + const baseRules = cli.getConfigForFile(require.resolve('./')).rules; entries(baseRules).forEach((rule) => { const ruleName = rule[0]; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0cc40907cc..466a8132b8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -62,7 +62,7 @@ "babel-preset-airbnb": "^2.6.0", "babel-tape-runner": "^2.0.1", "eclint": "^2.8.1", - "eslint": "^4.19.1 || ^5.3.0", + "eslint": "^5.16.0 || ^6.1.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", @@ -73,12 +73,12 @@ "tape": "^4.11.0" }, "peerDependencies": { - "eslint": "^4.19.1 || ^5.3.0", + "eslint": "^5.16.0 || ^6.1.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.2" }, "engines": { - "node": ">= 4" + "node": ">= 6" } } diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index 414f9c37a1..654773758d 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -7,7 +7,7 @@ const baseConfig = require('.'); function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); - const baseRules = cli.getConfigForFile('./').rules; + const baseRules = cli.getConfigForFile(require.resolve('./')).rules; entries(baseRules).forEach((rule) => { const ruleName = rule[0]; From 820745d61090139193cf9257b88974e36dfc9b35 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Mon, 9 Jul 2018 18:14:32 -0700 Subject: [PATCH 057/302] [guide] [eslint config] [base] [breaking] Require parens for arrow function args --- README.md | 46 +++++++++++-------- .../eslint-config-airbnb-base/rules/es6.js | 4 +- .../test/test-base.js | 2 +- .../eslint-config-airbnb/test/test-base.js | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e478830ca8..25fbd7f567 100644 --- a/README.md +++ b/README.md @@ -418,7 +418,7 @@ Other Style Guides }); // good - [1, 2, 3].map(x => x + 1); + [1, 2, 3].map((x) => x + 1); // bad - no returned value means `acc` becomes undefined after the first iteration [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => { @@ -955,13 +955,16 @@ Other Style Guides ```javascript // bad - [1, 2, 3].map(number => { + [1, 2, 3].map((number) => { const nextNumber = number + 1; `A string containing the ${nextNumber}.`; }); + // bad + [1, 2, 3].map((number) => `A string containing the ${number}.`); + // good - [1, 2, 3].map(number => `A string containing the ${number + 1}.`); + [1, 2, 3].map((number) => `A string containing the ${number + 1}.`); // good [1, 2, 3].map((number) => { @@ -1000,14 +1003,14 @@ Other Style Guides ```javascript // bad - ['get', 'post', 'put'].map(httpMethod => Object.prototype.hasOwnProperty.call( + ['get', 'post', 'put'].map((httpMethod) => Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, httpMethod, ) ); // good - ['get', 'post', 'put'].map(httpMethod => ( + ['get', 'post', 'put'].map((httpMethod) => ( Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, httpMethod, @@ -1016,22 +1019,27 @@ 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. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) + - [8.4](#arrows--one-arg-parens) Always include parentheses around arguments for clarity and consistency. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) - > Why? Less visual clutter. + > Why? Minimizes diff churn when adding or removing arguments. ```javascript // bad - [1, 2, 3].map((x) => x * x); - - // good [1, 2, 3].map(x => x * x); // good + [1, 2, 3].map((x) => x * x); + + // bad [1, 2, 3].map(number => ( `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!` )); + // good + [1, 2, 3].map((number) => ( + `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!` + )); + // bad [1, 2, 3].map(x => { const y = x + 1; @@ -1050,13 +1058,13 @@ Other Style Guides ```javascript // bad - const itemHeight = item => item.height <= 256 ? item.largeSize : item.smallSize; + const itemHeight = (item) => item.height <= 256 ? item.largeSize : item.smallSize; // bad const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize; // good - const itemHeight = item => (item.height <= 256 ? item.largeSize : item.smallSize); + const itemHeight = (item) => (item.height <= 256 ? item.largeSize : item.smallSize); // good const itemHeight = (item) => { @@ -1070,16 +1078,16 @@ Other Style Guides ```javascript // bad - foo => + (foo) => bar; - foo => + (foo) => (bar); // good - foo => bar; - foo => (bar); - foo => ( + (foo) => bar; + (foo) => (bar); + (foo) => ( bar ) ``` @@ -1448,7 +1456,7 @@ Other Style Guides }); // best (keeping it functional) - const increasedByOne = numbers.map(num => num + 1); + const increasedByOne = numbers.map((num) => num + 1); ``` @@ -3028,7 +3036,7 @@ Other Style Guides // bad - raises exception const luke = {} const leia = {} - [luke, leia].forEach(jedi => jedi.father = 'vader') + [luke, leia].forEach((jedi) => jedi.father = 'vader') // bad - raises exception const reaction = "No! That’s impossible!" diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 9c6328700e..dac5f4b98f 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -21,9 +21,7 @@ module.exports = { // require parens in arrow function arguments // https://eslint.org/docs/rules/arrow-parens - 'arrow-parens': ['error', 'as-needed', { - requireForBlockBody: true, - }], + 'arrow-parens': ['error', 'always'], // require space before/after arrow function's arrow // https://eslint.org/docs/rules/arrow-spacing diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 07d17b1027..181e04f453 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -26,7 +26,7 @@ Object.keys(files).forEach(( // scan rules for react/ and fail if any exist const reactRuleIds = Object.keys(config.rules) - .filter(ruleId => ruleId.indexOf('react/') === 0); + .filter((ruleId) => ruleId.indexOf('react/') === 0); t.deepEquals(reactRuleIds, [], 'there are no react/ rules'); }); }); diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js index 807191dfe3..c283c3410c 100644 --- a/packages/eslint-config-airbnb/test/test-base.js +++ b/packages/eslint-config-airbnb/test/test-base.js @@ -28,7 +28,7 @@ Object.keys(files).forEach((name) => { // scan rules for react/ and fail if any exist const reactRuleIds = Object.keys(config.rules) - .filter(ruleId => ruleId.indexOf('react/') === 0); + .filter((ruleId) => ruleId.indexOf('react/') === 0); t.deepEquals(reactRuleIds, [], 'there are no react/ rules'); }); }); From f6acb789a02a3295cfb2ae8c48f0e11060a0634c Mon Sep 17 00:00:00 2001 From: Sharmila Date: Tue, 10 Jul 2018 15:19:05 -0700 Subject: [PATCH 058/302] [guide] [eslint config] [base] [breaking] Simplifies `no-mixed-operators` - adds warning on mixing `/` and `*` arithmetic operators - removes warnings on mixing `**` and arithmetic operators - removes warning on mixing `in` and `instanceof` - removes warning on mixing `~` with other bitwise operators - removes mixing of assignment operators with comparison operators --- README.md | 10 +++++++--- packages/eslint-config-airbnb-base/rules/style.js | 10 +++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 25fbd7f567..d4d9845210 100644 --- a/README.md +++ b/README.md @@ -2049,7 +2049,8 @@ Other Style Guides ``` - - [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators (`+`, `-`, `*`, & `/`) since their precedence is broadly understood. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) + - [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators: `+`, `-`, and `**` since their precedence is broadly understood. We recommend enclosing `/` and `*` in parentheses because their precedence can be ambiguous when they are mixed. + eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) > Why? This improves readability and clarifies the developer’s intention. @@ -2066,11 +2067,14 @@ Other Style Guides return d; } + // bad + const bar = a + b / c * d; + // good const foo = (a && b < 0) || c > 0 || (d + 1 === 0); // good - const bar = (a ** b) - (5 % d); + const bar = a ** b - (5 % d); // good if (a || (b && c)) { @@ -2078,7 +2082,7 @@ Other Style Guides } // good - const bar = a + b / c * d; + const bar = a + (b / c) * d; ``` **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 1908c3ea81..2fdb5c5e3a 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -293,14 +293,10 @@ module.exports = { ['%', '-'], ['%', '*'], ['%', '/'], - ['**', '+'], - ['**', '-'], - ['**', '*'], - ['**', '/'], - ['&', '|', '^', '~', '<<', '>>', '>>>'], - ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + ['/', '*'], + ['&', '|', '<<', '>>', '>>>'], + ['==', '!=', '===', '!=='], ['&&', '||'], - ['in', 'instanceof'] ], allowSamePrecedence: false }], From b96341fb86f28e421ec5a6674ab55d95f6f4c1ad Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 20 Nov 2018 11:55:50 +0000 Subject: [PATCH 059/302] [eslint config] [base] [breaking] legacy: Enable 'strict' This enables the `strict` rule in 'safe' mode: https://eslint.org/docs/rules/strict#safe --- packages/eslint-config-airbnb-base/legacy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index 94870c9263..18576f83e5 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -27,6 +27,7 @@ module.exports = { property: '__defineSetter__', message: 'Please use Object.defineProperty instead.', }], - 'no-var': 'off' + 'no-var': 'off', + strict: ['error', 'safe'], } }; From 42c647f31b046fd56a51316caf681846100abd4f Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 20 Nov 2018 12:04:17 +0000 Subject: [PATCH 060/302] [eslint config] [base] [breaking] Set 'strict' to 'never' Previously `rules/strict.js` was only used by `eslint-config-airbnb` and not base. This change reduces the duplication, and means the rule is now set to 'never' as opposed to the ESLint default of 'safe'. For users that left the `sourceType` at this preset's default of `module` this change will be a no-op, since in module-mode the `strict` rule always behaves as though 'never' had been set. See: https://eslint.org/docs/rules/strict#options --- packages/eslint-config-airbnb-base/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index 16b423f35d..825456b8a4 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -7,12 +7,11 @@ module.exports = { './rules/variables', './rules/es6', './rules/imports', + './rules/strict', ].map(require.resolve), parserOptions: { ecmaVersion: 2018, sourceType: 'module', }, - rules: { - strict: 'error', - }, + rules: {}, }; From ad0c44c6affa87743419038682f00c0b9d0d9989 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 20 Nov 2018 12:06:34 +0000 Subject: [PATCH 061/302] [eslint config] Remove rules/strict from 'extends' Since the file is now imported in base instead. Fixes #1582. --- packages/eslint-config-airbnb/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-config-airbnb/index.js b/packages/eslint-config-airbnb/index.js index ddd3bfb712..6432e10dda 100644 --- a/packages/eslint-config-airbnb/index.js +++ b/packages/eslint-config-airbnb/index.js @@ -1,7 +1,6 @@ module.exports = { extends: [ 'eslint-config-airbnb-base', - 'eslint-config-airbnb-base/rules/strict', './rules/react', './rules/react-a11y', ].map(require.resolve), From 2160a77baa5eb62b78f0c2cfecfc37086e78c657 Mon Sep 17 00:00:00 2001 From: Waseem Dahman Date: Tue, 12 Mar 2019 23:36:07 -0400 Subject: [PATCH 062/302] [eslint config] [breaking] [react] add `react-hooks` plugin --- packages/eslint-config-airbnb/README.md | 12 +++++++---- packages/eslint-config-airbnb/hooks.js | 6 ++++++ packages/eslint-config-airbnb/package.json | 4 +++- .../eslint-config-airbnb/rules/react-hooks.js | 21 +++++++++++++++++++ .../eslint-config-airbnb/test/requires.js | 1 + 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 packages/eslint-config-airbnb/hooks.js create mode 100644 packages/eslint-config-airbnb/rules/react-hooks.js diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 7296176e26..da35d94344 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -10,7 +10,7 @@ We export three ESLint configurations for your usage. ### eslint-config-airbnb -Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). +Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). 1. Install the correct versions of each package, which are listed by the command: @@ -39,7 +39,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and Which produces and runs a command like: ```sh - npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# + npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# eslint-plugin-react-hooks@^#.#.# ``` If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool. @@ -51,10 +51,14 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and The cli will produce and run a command like: ```sh - npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# + npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# eslint-plugin-react-hooks@^#.#.# ``` -2. Add `"extends": "airbnb"` to your .eslintrc +2. Add `"extends": "airbnb"` to your `.eslintrc` + +### eslint-config/airbnb/hooks + +This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": "airbnb/hooks"` to your `.eslintrc` ### eslint-config-airbnb/whitespace diff --git a/packages/eslint-config-airbnb/hooks.js b/packages/eslint-config-airbnb/hooks.js new file mode 100644 index 0000000000..a7f70284e3 --- /dev/null +++ b/packages/eslint-config-airbnb/hooks.js @@ -0,0 +1,6 @@ +module.exports = { + extends: [ + './rules/react-hooks.js', + ].map(require.resolve), + rules: {} +}; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 466a8132b8..2a8e2e5b2e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -67,6 +67,7 @@ "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.2", + "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.2", @@ -76,7 +77,8 @@ "eslint": "^5.16.0 || ^6.1.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.2" + "eslint-plugin-react": "^7.14.2", + "eslint-plugin-react-hooks": "^1.7.0" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb/rules/react-hooks.js b/packages/eslint-config-airbnb/rules/react-hooks.js new file mode 100644 index 0000000000..be17c9a571 --- /dev/null +++ b/packages/eslint-config-airbnb/rules/react-hooks.js @@ -0,0 +1,21 @@ +module.exports = { + plugins: [ + 'react-hooks', + ], + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + + rules: { + // Enforce Rules of Hooks + // https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js + 'react-hooks/rules-of-hooks': 'error', + + // Verify the list of the dependencies for Hooks like useEffect and similar + // https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js + 'react-hooks/exhaustive-deps': 'error', + }, +}; diff --git a/packages/eslint-config-airbnb/test/requires.js b/packages/eslint-config-airbnb/test/requires.js index 964318521e..72f4ab8078 100644 --- a/packages/eslint-config-airbnb/test/requires.js +++ b/packages/eslint-config-airbnb/test/requires.js @@ -9,6 +9,7 @@ test('all entry points parse', (t) => { t.doesNotThrow(() => require('../base'), 'base does not throw'); t.doesNotThrow(() => require('../legacy'), 'legacy does not throw'); t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw'); + t.doesNotThrow(() => require('../hooks'), 'hooks does not throw'); t.end(); }); From a344d6c8e7f21e6af107ed3e335068bf6a621c5d Mon Sep 17 00:00:00 2001 From: JBallin Date: Mon, 10 Jun 2019 13:49:58 -0700 Subject: [PATCH 063/302] [guide] [eslint config] [base] [breaking] `no-multiple-empty-lines`: Restrict empty lines at beginning of file --- README.md | 15 ++++++++++++--- packages/eslint-config-airbnb-base/rules/style.js | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d4d9845210..7e16cb583a 100644 --- a/README.md +++ b/README.md @@ -2874,21 +2874,30 @@ Other Style Guides - [19.19](#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.20](#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) + - [19.20](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines, only allow one newline at the end of files, and avoid a newline at the beginning of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) ```javascript - // bad + // bad - multiple empty lines var x = 1; + var y = 2; + // bad - 2+ newlines at end of file + var x = 1; var y = 2; - // good + + // bad - 1+ newline(s) at beginning of file + var x = 1; + var y = 2; + // good + var x = 1; var y = 2; + ``` diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 2fdb5c5e3a..54f85e53b0 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -308,8 +308,9 @@ module.exports = { // https://eslint.org/docs/rules/no-multi-assign 'no-multi-assign': ['error'], - // disallow multiple empty lines and only one newline at the end - 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], + // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning + // https://eslint.org/docs/rules/no-multiple-empty-lines + 'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 1, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition From 8c686eac4b93bff8710ab1c31b3223bc5dc2f18d Mon Sep 17 00:00:00 2001 From: Rahil Vora Date: Mon, 22 Jul 2019 11:27:02 -0500 Subject: [PATCH 064/302] [eslint config] add componentDidCatch to lifecycle for react/sort-comp --- packages/eslint-config-airbnb/rules/react.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index bb2373cdbc..75bea2bb10 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -272,6 +272,7 @@ module.exports = { 'componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', + 'componentDidCatch' ], rendering: [ '/^render.+$/', From 61c7ae61895af2b3c7938015eaf72ca1e0fddb3e Mon Sep 17 00:00:00 2001 From: Felipe Pinheiro Date: Mon, 17 Jun 2019 12:58:54 -0300 Subject: [PATCH 065/302] [eslint config] Add missing/unsafe lifecycle methods to react/sort-comp rule --- packages/eslint-config-airbnb/rules/react.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 75bea2bb10..2a4acc39b4 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -265,12 +265,18 @@ module.exports = { 'getInitialState', 'state', 'getChildContext', + 'getDerivedStateFromProps', 'componentWillMount', + 'UNSAFE_componentWillMount', 'componentDidMount', 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', 'shouldComponentUpdate', 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', + 'getSnapshotBeforeUpdate', 'componentDidUpdate', + 'componentDidCatch', 'componentWillUnmount', 'componentDidCatch' ], From 19e9ce31fe051c2232c90bf63dab0ee2fe0efbaf Mon Sep 17 00:00:00 2001 From: amanjain <91aman@gmail.com> Date: Thu, 12 Jan 2017 12:15:39 +0530 Subject: [PATCH 066/302] [eslint config] [base] [breaking] `padded-blocks`: enable `allowSingleLineBlocks` option --- packages/eslint-config-airbnb-base/rules/style.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 54f85e53b0..b14a287c89 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -419,12 +419,12 @@ module.exports = { 'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }], // disallow padding within blocks - // TODO, semver-major: uncomment option 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never', - // allowSingleLineBlocks: true, + }, { + allowSingleLineBlocks: true, }], // Require or disallow padding lines between statements From 8148bfce3c670a8a234ee71903ca020e32506884 Mon Sep 17 00:00:00 2001 From: Vladimir Kutepov Date: Tue, 10 Oct 2017 18:21:50 +0300 Subject: [PATCH 067/302] [eslint config] [base] [patch] Do not prefer destructuring for object assignment expression ```js let param = 'default value'; if (object) param = object.param; // <= prefer-destructuring } // ... ``` I think that `param = object.param;` is better than `({ param } = object);` because it is easier to read and tedious to write brackets by hand. MDN: [Destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) --- packages/eslint-config-airbnb-base/rules/es6.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index dac5f4b98f..bfdc6d29e4 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -118,7 +118,7 @@ module.exports = { }, AssignmentExpression: { array: true, - object: true, + object: false, }, }, { enforceForRenamedProperties: false, From bb011c2f2f22e91399b2c5a0b90eb797b6e15d24 Mon Sep 17 00:00:00 2001 From: Jeff VanDyke Date: Thu, 29 Nov 2018 09:13:54 -0500 Subject: [PATCH 068/302] [eslint config] [base] [patch] Add markers to spaced-comment block for Flow types See --- 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 b14a287c89..b60c069641 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -498,7 +498,7 @@ module.exports = { }, block: { exceptions: ['-', '+'], - markers: ['=', '!'], // space here to support sprockets directives + markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types balanced: true, } }], From a490005ddfbd73f96f0fc4335bf035cd554ad2e6 Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Sat, 6 Jul 2019 23:45:11 +0430 Subject: [PATCH 069/302] [react] event handlers should not return values --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 87dbcb9996..7e247e7ac1 100644 --- a/react/README.md +++ b/react/README.md @@ -540,7 +540,7 @@ We don’t recommend using indexes for keys if the order of items may change. {props.items.map((item, index) => ( doSomethingWith(event, item.name, index)} + onClick={(event) => { doSomethingWith(event, item.name, index); }} /> ))} From 6b5922ca2132980609fe217353162c2338b29ae2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:39:06 -0700 Subject: [PATCH 070/302] [eslint config] [breaking] set react version to "detect" Fixes #1983. --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 2a4acc39b4..0c3411e963 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -515,7 +515,7 @@ module.exports = { }, react: { pragma: 'React', - version: '16.0' + version: 'detect', }, propWrapperFunctions: [ 'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types From e257deebd4544cf3609d5336f463688981897fe7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:40:53 -0700 Subject: [PATCH 071/302] [eslint config] [base] [patch] `camelcase`: enable ignoreDestructuring --- packages/eslint-config-airbnb-base/rules/style.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index b60c069641..2a70739624 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -21,8 +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' }], + camelcase: ['error', { properties: 'never', ignoreDestructuring: false }], // enforce or disallow capitalization of the first letter of a comment // https://eslint.org/docs/rules/capitalized-comments From 11ede40d55734064f2d497e29cb7fde21d3df209 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:41:33 -0700 Subject: [PATCH 072/302] [eslint config] [base] [breaking] `func-name-matching`: enable `considerPropertyDescriptor` option --- packages/eslint-config-airbnb-base/rules/style.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 2a70739624..3e5e5fa15e 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -83,9 +83,9 @@ 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 + includeCommonJSModuleExports: false, + considerPropertyDescriptor: true, }], // require function expressions to have a name From 88e71e6e5223701d353325035383c3a8d9fd88b2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:42:20 -0700 Subject: [PATCH 073/302] [eslint config] [base] [breaking] enable `prefer-object-spread` --- packages/eslint-config-airbnb-base/rules/style.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 3e5e5fa15e..3aa6eeac76 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -432,8 +432,7 @@ module.exports = { // 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', + 'prefer-object-spread': 'error', // require quotes around object literal property names // https://eslint.org/docs/rules/quote-props.html From f0c767fd398b7b10ee189a701823630d25100598 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:43:20 -0700 Subject: [PATCH 074/302] [eslint config] [base] [breaking] enable `no-async-promise-executor` --- packages/eslint-config-airbnb-base/rules/errors.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index aca6d7d9c3..fb4766cf40 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -10,8 +10,7 @@ module.exports = { // disallow using an async function as a Promise executor // https://eslint.org/docs/rules/no-async-promise-executor - // TODO: enable, semver-major - 'no-async-promise-executor': 'off', + 'no-async-promise-executor': 'error', // Disallow await inside of loops // https://eslint.org/docs/rules/no-await-in-loop From d03a712bba592da02631fb30824f6661788b2120 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:44:01 -0700 Subject: [PATCH 075/302] [eslint config] [base] [breaking] enable `no-misleading-character-class` --- packages/eslint-config-airbnb-base/rules/errors.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index fb4766cf40..5a56844e7c 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -84,8 +84,7 @@ module.exports = { // Disallow characters which are made with multiple code points in character class syntax // https://eslint.org/docs/rules/no-misleading-character-class - // TODO: enable, semver-major - 'no-misleading-character-class': 'off', + 'no-misleading-character-class': 'error', // disallow the use of object properties of the global object (Math and JSON) as functions 'no-obj-calls': 'error', From 08f8093ed112306b360e6d5f21eb45bedf69f214 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:45:27 -0700 Subject: [PATCH 076/302] [eslint config] [base] [breaking] enable `max-classes-per-file` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index b16a974ccf..2cfd8e3d22 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -44,8 +44,7 @@ module.exports = { // 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], + 'max-classes-per-file': ['error', 1], // disallow the use of alert, confirm, and prompt 'no-alert': 'warn', From d490ee1806abdf07fe53f023384b223dab643b0b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:45:49 -0700 Subject: [PATCH 077/302] [eslint config] [base] [breaking] enable `no-useless-catch` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 2cfd8e3d22..8c763dd62f 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -282,8 +282,7 @@ module.exports = { // Disallow unnecessary catch clauses // https://eslint.org/docs/rules/no-useless-catch - // TODO: enable, semver-major - 'no-useless-catch': 'off', + 'no-useless-catch': 'error', // disallow useless string concatenation // https://eslint.org/docs/rules/no-useless-concat From 282ef9ea9051dce725f382ac83cb5c3f2d4da0c2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 22:46:22 -0700 Subject: [PATCH 078/302] [eslint config] [base] [breaking] `no-self-assign`: enable `props` option --- packages/eslint-config-airbnb-base/rules/best-practices.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 8c763dd62f..41f85487a9 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -248,9 +248,8 @@ module.exports = { // disallow self assignment // https://eslint.org/docs/rules/no-self-assign - // TODO: semver-major: props -> true 'no-self-assign': ['error', { - props: false, + props: true, }], // disallow comparisons where both sides are exactly the same From e6f591f660a16da51a8fe8a9239703b9bde82c13 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:22:48 -0700 Subject: [PATCH 079/302] [Dev Deps] update babel-related deps to latest --- packages/eslint-config-airbnb-base/package.json | 5 +++-- packages/eslint-config-airbnb/package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 5959e0f89b..4546707cf2 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,8 +53,9 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.6.0", - "babel-tape-runner": "^2.0.1", + "@babel/runtime": "^7.5.5", + "babel-preset-airbnb": "^4.0.1", + "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.1.0", "eslint-find-rules": "^3.4.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2a8e2e5b2e..4af469ea3f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,8 +59,9 @@ "object.entries": "^1.1.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.6.0", - "babel-tape-runner": "^2.0.1", + "@babel/runtime": "^7.5.5", + "babel-preset-airbnb": "^4.0.1", + "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.1.0", "eslint-find-rules": "^3.4.0", From b05573cae4282e643c432ae688f2eb4cef229991 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:41:02 -0700 Subject: [PATCH 080/302] [eslint config] [base] v14.0.0 --- .../eslint-config-airbnb-base/CHANGELOG.md | 25 +++++++++++++++++++ .../eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 4b475827cb..73105da143 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,28 @@ +14.0.0 / 2019-08-09 +================== + - [breaking] `no-self-assign`: enable `props` option + - [breaking] enable `no-useless-catch` + - [breaking] enable `max-classes-per-file` + - [breaking] enable `no-misleading-character-class` + - [breaking] enable `no-async-promise-executor` + - [breaking] enable `prefer-object-spread` + - [breaking] `func-name-matching`: enable `considerPropertyDescriptor` option + - [breaking] `padded-blocks`: enable `allowSingleLineBlocks` option (#1255) + - [breaking] `no-multiple-empty-lines`: Restrict empty lines at beginning of file (#2042) + - [breaking] Set 'strict' to 'never' (#1962) + - [breaking] legacy: Enable 'strict' (#1962) + - [breaking] Simplifies `no-mixed-operators` (#1864) + - [breaking] Require parens for arrow function args (#1863) + - [breaking] add eslint v6, drop eslint v4 + - [patch] `camelcase`: enable ignoreDestructuring + - [patch] Add markers to spaced-comment block for Flow types (#1966) + - [patch] Do not prefer destructuring for object assignment expression (#1583) + - [deps] update `confusing-browser-globals`, `eslint-plugin-import`, `tape`, `babel-preset-airbnb` + - [dev deps] update babel-related deps to latest + - [dev deps] update `eslint-find-rules`, `eslint-plugin-import` + - [tests] only run tests in non-lint per-package travis job + - [tests] use `eclint` instead of `editorconfig-tools` + 13.2.0 / 2019-07-01 ================== - [minor] Enforce dangling underscores in method names (#1907) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4546707cf2..99830bcb67 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": "13.2.0", + "version": "14.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From b447768ad322d87ca88a0ecb9e0d0d6168d19aca Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:48:11 -0700 Subject: [PATCH 081/302] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4af469ea3f..a89da0e17b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^13.2.0", + "eslint-config-airbnb-base": "^14.0.0", "object.assign": "^4.1.0", "object.entries": "^1.1.0" }, @@ -67,7 +67,7 @@ "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.2", + "eslint-plugin-react": "^7.14.3", "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -78,7 +78,7 @@ "eslint": "^5.16.0 || ^6.1.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.2", + "eslint-plugin-react": "^7.14.3", "eslint-plugin-react-hooks": "^1.7.0" }, "engines": { From a23f93eb001ec398ff42f37945b01db2787f6c93 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:48:45 -0700 Subject: [PATCH 082/302] [eslint config] [breaking] enable `react/jsx-fragments` --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 0c3411e963..480afc0fd9 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -470,8 +470,7 @@ module.exports = { // Enforce shorthand or standard form for React fragments // https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md - // TODO: enable, semver-major - 'react/jsx-fragments': ['off', 'syntax'], + 'react/jsx-fragments': ['error', 'syntax'], // Enforce linebreaks in curly braces in JSX attributes and expressions. // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md From 25075b5f72bb6fad25fb4f72201aaee62b46fea6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:50:40 -0700 Subject: [PATCH 083/302] [eslint config] [minor] enable `react/jsx-curly-newline` --- packages/eslint-config-airbnb/rules/react.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 480afc0fd9..039586158a 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -474,10 +474,9 @@ module.exports = { // Enforce linebreaks in curly braces in JSX attributes and expressions. // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md - // TODO: enable, semver-minor - 'react/jsx-curly-newline': ['off', { + 'react/jsx-curly-newline': ['error', { multiline: 'consistent', - single: 'consistent', + singleline: 'consistent', }], // Enforce state initialization style From 7f5a65832daf975b36426171ecbde97574c0ad3d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:52:29 -0700 Subject: [PATCH 084/302] [eslint config] [minor] enable `react/state-in-constructor` --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 039586158a..5fbe8b35eb 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -481,9 +481,8 @@ module.exports = { // Enforce state initialization style // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md - // TODO: enable, semver-minor // TODO: set to "always" once babel-preset-airbnb supports public class fields - 'react/state-in-constructor': ['off', 'never'], + 'react/state-in-constructor': ['error', 'never'], // Enforces where React component static properties should be positioned // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md From 089022aeff7b4d753c9f419c5b4e3a26cdf625b8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:52:44 -0700 Subject: [PATCH 085/302] [eslint config] [minor] enable `react/static-property-placement` --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 5fbe8b35eb..558c5aee35 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -486,9 +486,8 @@ module.exports = { // Enforces where React component static properties should be positioned // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md - // TODO: enable, semver-minor // TODO: set to "static public field" once babel-preset-airbnb supports public class fields - 'react/static-property-placement': ['off', 'property assignment'], + 'react/static-property-placement': ['error', 'property assignment'], // Disallow JSX props spreading // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md From 73f71d9ba4f9ae48054438420c27651fc924d196 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:53:03 -0700 Subject: [PATCH 086/302] [eslint config] [breaking] enable `react/jsx-props-no-spreading` --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 558c5aee35..dc01c0d2e4 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -491,8 +491,7 @@ module.exports = { // Disallow JSX props spreading // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md - // TODO: enable, semver-major - 'react/jsx-props-no-spreading': ['off', { + 'react/jsx-props-no-spreading': ['error', { html: 'enforce', custom: 'enforce', exceptions: [], From 1e0a696730256af82d284f37a66032681cf23387 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 9 Aug 2019 23:54:08 -0700 Subject: [PATCH 087/302] [eslint config] [breaking] disable `label-has-for`; enable `control-has-associated-label` --- packages/eslint-config-airbnb/rules/react-a11y.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index ffb4d28c29..69cf63b01f 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -48,7 +48,8 @@ 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', { + // deprecated: replaced by `label-has-associated-control` rule + 'jsx-a11y/label-has-for': ['off', { components: [], required: { every: ['nesting', 'id'], @@ -68,8 +69,7 @@ module.exports = { // Enforce that a control (an interactive element) has a text label. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md - // TODO, semver-major: enable - 'jsx-a11y/control-has-associated-label': ['off', { + 'jsx-a11y/control-has-associated-label': ['error', { labelAttributes: ['label'], controlComponents: [], ignoreElements: [ From bdba997ac704f7fdcebf4467babaa3f35828c0a5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 10 Aug 2019 08:41:05 -0700 Subject: [PATCH 088/302] [eslint config] v18.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 21 +++++++++++++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index ed2d7af0e3..48cfba3dd8 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,24 @@ +18.0.0 / 2019-08-10 +================== + - [breaking] add eslint v6, drop eslint v4 + - [deps] [breaking] update `eslint-config-airbnb-base`, `eslint-plugin-react`, `eslint-find-rules`, `eslint-plugin-import` + - [breaking] Remove rules/strict from 'extends' (#1962) + - [breaking] set react version to "detect" + - [breaking] disable `label-has-for`; enable `control-has-associated-label` + - [breaking] enable `react/jsx-props-no-spreading` + - [breaking] enable `react/jsx-fragments` + - [minor] enable `react/static-property-placement` + - [minor] enable `react/state-in-constructor` + - [minor] enable `react/jsx-curly-newline` + - [react] Add missing/unsafe lifecycle methods to react/sort-comp rule (#2043) + - [react] add componentDidCatch to lifecycle for react/sort-comp (#2060) + - [react] add `react-hooks` plugin (#2022) + - [dev deps] update babel-related deps to latest + - [tests] only run tests in non-lint per-package travis job + - [tests] use `eclint` instead of `editorconfig-tools` + - [meta] add disabled config for new react and a11y rules + + 17.1.1 / 2019-07-01 ================== - [patch] Turn off `react/no-multi-comp` (#2006) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index a89da0e17b..b71f94ac14 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "17.1.1", + "version": "18.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 530278467f8b0a1b2aee632fbeee543e6732ef35 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Aug 2019 12:29:20 -0700 Subject: [PATCH 089/302] [eslint config] [patch] `react/state-in-constructor`: fix incorrect configuration --- packages/eslint-config-airbnb/rules/react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index dc01c0d2e4..1fe097bb07 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -481,8 +481,8 @@ module.exports = { // Enforce state initialization style // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md - // TODO: set to "always" once babel-preset-airbnb supports public class fields - 'react/state-in-constructor': ['error', 'never'], + // TODO: set to "never" once babel-preset-airbnb supports public class fields + 'react/state-in-constructor': ['error', 'always'], // Enforces where React component static properties should be positioned // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md From a204cdf38a3e67a405c191773456d18296a9b37b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Aug 2019 12:30:37 -0700 Subject: [PATCH 090/302] [eslint config] v18.0.1 --- packages/eslint-config-airbnb/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 48cfba3dd8..8c16dd3c1a 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +18.0.1 / 2019-08-13 +================== + - [patch] `react/state-in-constructor`: fix incorrect configuration + 18.0.0 / 2019-08-10 ================== - [breaking] add eslint v6, drop eslint v4 diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index b71f94ac14..14b51c5717 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "18.0.0", + "version": "18.0.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 295d1e61cbebd33d06cbd287fc1d7ea59ba959f7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 14 Aug 2019 08:46:20 -0700 Subject: [PATCH 091/302] [guide] clean up confusing example from bad rebase ... from https://github.com/airbnb/javascript/commit/820745d61090139193cf9257b88974e36dfc9b35#diff-04c6e90faac2675aa89e2176d2eec7d8R963-R965 / #1863. Fixes #2071. --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 7e16cb583a..20b42ecfdf 100644 --- a/README.md +++ b/README.md @@ -960,9 +960,6 @@ Other Style Guides `A string containing the ${nextNumber}.`; }); - // bad - [1, 2, 3].map((number) => `A string containing the ${number}.`); - // good [1, 2, 3].map((number) => `A string containing the ${number + 1}.`); From 1ca21aba799699ba556bed058e3900514a9fbee3 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Sat, 17 Aug 2019 19:14:24 -0500 Subject: [PATCH 092/302] [eslint config] clarify hooks section in readme It took me too long to realize that `"extends": "airbnb/hooks"` won't cut it, and that you need to include both `"extends": ["airbnb", "airbnb/hooks"]`. I think the docs should be explicit about this. --- packages/eslint-config-airbnb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index da35d94344..94e4ac54c4 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -58,7 +58,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and ### eslint-config/airbnb/hooks -This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": "airbnb/hooks"` to your `.eslintrc` +This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": ["airbnb", "airbnb/hooks"]` to your `.eslintrc` ### eslint-config-airbnb/whitespace From 7932a52e4b8f5a96089b245e2086769bf30cf0e4 Mon Sep 17 00:00:00 2001 From: Tom Prats Date: Wed, 4 Sep 2019 14:11:39 -0400 Subject: [PATCH 093/302] Added Tomify and Traitify to the organizations --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 20b42ecfdf..9e649fed07 100644 --- a/README.md +++ b/README.md @@ -3871,6 +3871,8 @@ Other Style Guides - **Terra**: [terra](https://github.com/cerner?utf8=%E2%9C%93&q=terra&type=&language=) - **TheLadders**: [TheLadders/javascript](https://github.com/TheLadders/javascript) - **The Nerdery**: [thenerdery/javascript-standards](https://github.com/thenerdery/javascript-standards) + - **Tomify**: [tomprats](https://github.com/tomprats) + - **Traitify**: [traitify/eslint-config-traitify](https://github.com/traitify/eslint-config-traitify) - **T4R Technology**: [T4R-Technology/javascript](https://github.com/T4R-Technology/javascript) - **UrbanSim**: [urbansim](https://github.com/urbansim/) - **VoxFeed**: [VoxFeed/javascript-style-guide](https://github.com/VoxFeed/javascript-style-guide) From 79047a947000b4b328fb9a6579d00e538768629e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 3 Oct 2019 19:10:12 -0400 Subject: [PATCH 094/302] [eslint config] [base] [deps] update `confusing-browser-globals` --- packages/eslint-config-airbnb-base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 99830bcb67..411498b1a8 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -72,7 +72,7 @@ "node": ">= 6" }, "dependencies": { - "confusing-browser-globals": "^1.0.7", + "confusing-browser-globals": "^1.0.9", "object.assign": "^4.1.0", "object.entries": "^1.1.0" } From 8c94d53bf88346cc4f55bfed769e3ee8c8247f80 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 3 Oct 2019 19:10:47 -0400 Subject: [PATCH 095/302] [eslint config] [*] [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 411498b1a8..dd3023d3d1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,15 +53,15 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.5.5", - "babel-preset-airbnb": "^4.0.1", + "@babel/runtime": "^7.6.2", + "babel-preset-airbnb": "^4.1.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.1.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "in-publish": "^2.0.0", - "safe-publish-latest": "^1.1.2", + "safe-publish-latest": "^1.1.3", "tape": "^4.11.0" }, "peerDependencies": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 14b51c5717..d9b3f5d950 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,8 +59,8 @@ "object.entries": "^1.1.0" }, "devDependencies": { - "@babel/runtime": "^7.5.5", - "babel-preset-airbnb": "^4.0.1", + "@babel/runtime": "^7.6.2", + "babel-preset-airbnb": "^4.1.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.1.0", @@ -71,7 +71,7 @@ "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", - "safe-publish-latest": "^1.1.2", + "safe-publish-latest": "^1.1.3", "tape": "^4.11.0" }, "peerDependencies": { From c66cfc3f89335643b6fd89def665b959389b70ea Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 3 Oct 2019 19:20:10 -0400 Subject: [PATCH 096/302] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- .../eslint-config-airbnb/test/test-react-order.js | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d9b3f5d950..1ffd85fc1a 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -67,7 +67,7 @@ "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.3", + "eslint-plugin-react": "^7.15.1", "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -78,7 +78,7 @@ "eslint": "^5.16.0 || ^6.1.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.3", + "eslint-plugin-react": "^7.15.1", "eslint-plugin-react-hooks": "^1.7.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 2527f04e19..af9287ab23 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -29,8 +29,7 @@ import React from 'react'; export default class MyComponent extends React.Component { /* eslint no-empty-function: 0, class-methods-use-this: 0 */ -${body} -} +${body}} `; } @@ -44,25 +43,24 @@ test('validate react prop order', (t) => { t.test('passes a good component', (t) => { t.plan(3); const result = lint(wrapComponent(` - componentWillMount() {} componentDidMount() {} setFoo() {} getFoo() {} setBar() {} someMethod() {} renderDogs() {} - render() { return
; }`)); + render() { return
; } +`)); t.notOk(result.warningCount, 'no warnings'); - t.notOk(result.errorCount, 'no errors'); t.deepEquals(result.messages, [], 'no messages in results'); + t.notOk(result.errorCount, 'no errors'); }); t.test('order: when random method is first', (t) => { t.plan(2); const result = lint(wrapComponent(` someMethod() {} - componentWillMount() {} componentDidMount() {} setFoo() {} getFoo() {} @@ -72,13 +70,12 @@ test('validate react prop order', (t) => { `)); t.ok(result.errorCount, 'fails'); - t.equal(result.messages[0].ruleId, 'react/sort-comp', 'fails due to sort'); + t.deepEqual(result.messages.map(x => x.ruleId), ['react/sort-comp'], 'fails due to sort'); }); t.test('order: when random method after lifecycle methods', (t) => { t.plan(2); const result = lint(wrapComponent(` - componentWillMount() {} componentDidMount() {} someMethod() {} setFoo() {} @@ -89,6 +86,6 @@ test('validate react prop order', (t) => { `)); t.ok(result.errorCount, 'fails'); - t.equal(result.messages[0].ruleId, 'react/sort-comp', 'fails due to sort'); + t.deepEqual(result.messages.map(x => x.ruleId), ['react/sort-comp'], 'fails due to sort'); }); }); From dee4f172e752f3e6180f88409aa4424de02f9d4c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 3 Oct 2019 19:18:32 -0400 Subject: [PATCH 097/302] [eslint config] [base] add new rules in eslint 6.x, disabled --- .../eslint-config-airbnb-base/rules/best-practices.js | 8 ++++++++ packages/eslint-config-airbnb-base/rules/errors.js | 4 ++++ packages/eslint-config-airbnb-base/rules/style.js | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 41f85487a9..e780a43b47 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -28,6 +28,10 @@ module.exports = { // require default case in switch statements 'default-case': ['error', { commentPattern: '^no default$' }], + // https://eslint.org/docs/rules/default-param-last + // TODO: enable, semver-minor, when eslint v6.4 is required (which is a major) + 'default-param-last': 'off', + // encourages use of dot notation whenever possible 'dot-notation': ['error', { allowKeywords: true }], @@ -313,6 +317,10 @@ module.exports = { // https://eslint.org/docs/rules/prefer-named-capture-group 'prefer-named-capture-group': 'off', + // https://eslint.org/docs/rules/prefer-regex-literals + // TODO; enable, semver-minor, once eslint v6.4 is required (which is a major) + 'prefer-regex-literals': 'off', + // require use of the second argument for parseInt() radix: 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 5a56844e7c..c996395299 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -73,6 +73,10 @@ module.exports = { // disallow overwriting functions written as function declarations 'no-func-assign': 'error', + // https://eslint.org/docs/rules/no-import-assign + // TODO: enable, semver-minor, once eslint v6.4 is required (which is a major) + 'no-import-assign': 'off', + // disallow function or variable declarations in nested blocks 'no-inner-declarations': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 3aa6eeac76..77412c94cd 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -76,6 +76,10 @@ module.exports = { // enforce newline at the end of file, with no multiple empty lines 'eol-last': ['error', 'always'], + // https://eslint.org/docs/rules/function-call-argument-newline + // TODO: enable, semver-minor, once eslint v6.2 is required (which is a major) + 'function-call-argument-newline': ['off', 'consistent'], + // enforce spacing between functions and their invocations // https://eslint.org/docs/rules/func-call-spacing 'func-call-spacing': ['error', 'never'], From ab72ab9e90f403e90590f8815e0563248af10470 Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Thu, 3 Oct 2019 21:31:32 +0200 Subject: [PATCH 098/302] [eslint config] [patch] Remove duplicate `componentDidCatch` See https://github.com/airbnb/javascript/pull/2043#discussion_r331208075 I left the one before `cWU`, as in [defaults](https://github.com/airbnb/javascript/pull/2043#discussion_r331208075) --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 1fe097bb07..964577054f 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -277,8 +277,7 @@ module.exports = { 'getSnapshotBeforeUpdate', 'componentDidUpdate', 'componentDidCatch', - 'componentWillUnmount', - 'componentDidCatch' + 'componentWillUnmount' ], rendering: [ '/^render.+$/', From df2c99c81474ab0fe9aecf0244d465785d3ee3df Mon Sep 17 00:00:00 2001 From: Pirasis <1pete@users.noreply.github.com> Date: Sat, 5 Oct 2019 08:21:45 +0700 Subject: [PATCH 099/302] [tests] fix eslint errors from c66cfc3 --- packages/eslint-config-airbnb/test/test-react-order.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index af9287ab23..6289973f03 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -70,7 +70,7 @@ test('validate react prop order', (t) => { `)); t.ok(result.errorCount, 'fails'); - t.deepEqual(result.messages.map(x => x.ruleId), ['react/sort-comp'], 'fails due to sort'); + t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); t.test('order: when random method after lifecycle methods', (t) => { @@ -86,6 +86,6 @@ test('validate react prop order', (t) => { `)); t.ok(result.errorCount, 'fails'); - t.deepEqual(result.messages.map(x => x.ruleId), ['react/sort-comp'], 'fails due to sort'); + t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); }); From 5a32c33bf2bf967ce32bae2fd33b3fea275a99be Mon Sep 17 00:00:00 2001 From: Pirasis <1pete@users.noreply.github.com> Date: Sat, 5 Oct 2019 08:49:01 +0700 Subject: [PATCH 100/302] [eslint config] [base] [minor] enable `import/no-useless-path-segments` for commonjs Fixes #2077. --- 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 1c4e08d36c..ff358e6116 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -236,7 +236,7 @@ module.exports = { // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md - 'import/no-useless-path-segments': 'error', + 'import/no-useless-path-segments': ['error', { "commonjs": true }], // dynamic imports require a leading comment with a webpackChunkName // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md From 8f78e1f44b9ca2f3a7da970771982694fa84fd72 Mon Sep 17 00:00:00 2001 From: Pirasis <1pete@users.noreply.github.com> Date: Sat, 5 Oct 2019 08:01:44 +0700 Subject: [PATCH 101/302] [tests] re-enable eslint rule `prefer-destructuring` internally --- packages/eslint-config-airbnb-base/.eslintrc | 2 -- packages/eslint-config-airbnb-base/whitespace.js | 2 +- packages/eslint-config-airbnb/.eslintrc | 2 -- packages/eslint-config-airbnb/whitespace.js | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/.eslintrc b/packages/eslint-config-airbnb-base/.eslintrc index f9bd289286..ab2c306fd9 100644 --- a/packages/eslint-config-airbnb-base/.eslintrc +++ b/packages/eslint-config-airbnb-base/.eslintrc @@ -4,7 +4,5 @@ // disable requiring trailing commas because it might be nice to revert to // being JSON at some point, and I don't want to make big changes now. "comma-dangle": 0, - // we support node 4 - "prefer-destructuring": 0, }, } diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 917ee0c50e..9ada683b21 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,6 +1,6 @@ const assign = require('object.assign'); const entries = require('object.entries'); -const CLIEngine = require('eslint').CLIEngine; +const { CLIEngine } = require('eslint'); const baseConfig = require('.'); diff --git a/packages/eslint-config-airbnb/.eslintrc b/packages/eslint-config-airbnb/.eslintrc index f9bd289286..ab2c306fd9 100644 --- a/packages/eslint-config-airbnb/.eslintrc +++ b/packages/eslint-config-airbnb/.eslintrc @@ -4,7 +4,5 @@ // disable requiring trailing commas because it might be nice to revert to // being JSON at some point, and I don't want to make big changes now. "comma-dangle": 0, - // we support node 4 - "prefer-destructuring": 0, }, } diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index 654773758d..63fa0ce6e4 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,6 +1,6 @@ const assign = require('object.assign'); const entries = require('object.entries'); -const CLIEngine = require('eslint').CLIEngine; +const { CLIEngine } = require('eslint'); const baseConfig = require('.'); From 3fb312f18198364bacc07e61ca58ff89f9f0afa2 Mon Sep 17 00:00:00 2001 From: Alexander Wesolowski Date: Fri, 4 Oct 2019 15:57:05 -0700 Subject: [PATCH 102/302] [eslint config] [patch] Add `static-variables` to `sort-comp` rule --- packages/eslint-config-airbnb/rules/react.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 964577054f..fc1a3a90a9 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -240,6 +240,7 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md 'react/sort-comp': ['error', { order: [ + 'static-variables', 'static-methods', 'instance-variables', 'lifecycle', From 64b965efe0355c8290996ff5a675cd8fb30bf843 Mon Sep 17 00:00:00 2001 From: trg Date: Tue, 1 Oct 2019 01:27:12 +0300 Subject: [PATCH 103/302] [guide] Fix Temporal dead zone link anchor --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e649fed07..efa2905a55 100644 --- a/README.md +++ b/README.md @@ -1805,7 +1805,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). 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 56b75dc3592c2118cefc5296c94d5fce5923a487 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Sun, 3 Nov 2019 21:00:57 +0100 Subject: [PATCH 104/302] [guide] Document `class-methods-use-this` This PR documents the currently enforced `class-methods-use-this` ESlint rule as discussed in #2129 --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index efa2905a55..b0e7442ef7 100644 --- a/README.md +++ b/README.md @@ -1254,6 +1254,39 @@ Other Style Guides } ``` + + - [9.7](#classes--methods-use-this) Class methods should use `this` or be made into a static method unless an external library or framework requires to use specific non-static methods. Being an instance method should indicate that it behaves differently based on properties of the receiver. eslint: [`class-methods-use-this`](https://eslint.org/docs/rules/class-methods-use-this) + + ```javascript + // bad + class Foo { + bar() { + console.log('bar'); + } + } + + // good - this i used + class Foo { + bar() { + console.log(this.bar); + } + } + + // good - constructor is exempt + class Foo { + constructor() { + // ... + } + } + + // good - static methods aren't expected to use this + class Foo { + static bar() { + console.log('bar'); + } + } + ``` + **[⬆ back to top](#table-of-contents)** ## Modules From 5927c7f706feee7542341faaa298176c2a82263d Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 8 Nov 2019 16:05:06 +0200 Subject: [PATCH 105/302] [guide] fix possible typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0e7442ef7..5ba3d46d9d 100644 --- a/README.md +++ b/README.md @@ -1265,7 +1265,7 @@ Other Style Guides } } - // good - this i used + // good - this is used class Foo { bar() { console.log(this.bar); From 2e3adc98c784be7fa63c7a05271f7aa86c9d6bc7 Mon Sep 17 00:00:00 2001 From: Jonas Scheffner Date: Mon, 28 Oct 2019 13:42:10 +0100 Subject: [PATCH 106/302] [eslint config] [base] [patch] `import/no-extraneous-dependencies`: Support karma config files --- 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 ff358e6116..c5ac1f920b 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -90,6 +90,7 @@ module.exports = { '**/Gruntfile{,.js}', // grunt config '**/protractor.conf.js', // protractor config '**/protractor.conf.*.js', // protractor config + '**/karma.conf.js' // karma config ], optionalDependencies: false, }], From 370793b3ddfecfef29c05a62bdf17ec3d1b0a8b3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 10 Dec 2019 16:32:17 -0800 Subject: [PATCH 107/302] [eslint-config] [*] [fix] `whitespace`: only set erroring rules to "warn" Fixes #2105 --- packages/eslint-config-airbnb-base/whitespace.js | 15 ++++++++++++++- packages/eslint-config-airbnb/whitespace.js | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 9ada683b21..0b7bda8f6f 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -4,6 +4,18 @@ const { CLIEngine } = require('eslint'); const baseConfig = require('.'); +const severities = ['off', 'warn', 'error']; + +function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; +} + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); @@ -12,8 +24,9 @@ function onlyErrorOnRules(rulesToError, config) { entries(baseRules).forEach((rule) => { const ruleName = rule[0]; const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); - if (rulesToError.indexOf(ruleName) === -1) { + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { if (Array.isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index 63fa0ce6e4..48445ada24 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -4,6 +4,18 @@ const { CLIEngine } = require('eslint'); const baseConfig = require('.'); +const severities = ['off', 'warn', 'error']; + +function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; +} + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); @@ -12,8 +24,9 @@ function onlyErrorOnRules(rulesToError, config) { entries(baseRules).forEach((rule) => { const ruleName = rule[0]; const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); - if (rulesToError.indexOf(ruleName) === -1) { + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { if (Array.isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { From b5954c32b34aab98d6713692fd33695fe8f7b12b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 10 Dec 2019 16:47:51 -0800 Subject: [PATCH 108/302] [eslint config] [base] [deps] [minor] add new disabled rules, update eslint --- packages/eslint-config-airbnb-base/package.json | 4 ++-- .../eslint-config-airbnb-base/rules/best-practices.js | 10 ++++++++++ packages/eslint-config-airbnb-base/rules/errors.js | 10 ++++++++++ packages/eslint-config-airbnb-base/rules/style.js | 5 +++++ packages/eslint-config-airbnb/package.json | 4 ++-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index dd3023d3d1..8da8cebaf1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,7 +57,7 @@ "babel-preset-airbnb": "^4.1.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.1.0", + "eslint": "^5.16.0 || ^6.7.2", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "in-publish": "^2.0.0", @@ -65,7 +65,7 @@ "tape": "^4.11.0" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.1.0", + "eslint": "^5.16.0 || ^6.7.2", "eslint-plugin-import": "^2.18.2" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index e780a43b47..2ac83edc8a 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -43,6 +43,11 @@ module.exports = { // https://eslint.org/docs/rules/eqeqeq eqeqeq: ['error', 'always', { null: 'ignore' }], + // Require grouped accessor pairs in object literals and classes + // https://eslint.org/docs/rules/grouped-accessor-pairs + // TODO: enable in next major, altho the guide forbids getters/setters anyways + 'grouped-accessor-pairs': 'off', + // make sure for-in loops have an if statement 'guard-for-in': 'error', @@ -60,6 +65,11 @@ module.exports = { // https://eslint.org/docs/rules/no-case-declarations.html 'no-case-declarations': 'error', + // Disallow returning value in constructor + // https://eslint.org/docs/rules/no-constructor-return + // TODO: enable, semver-major + 'no-constructor-return': 'off', + // disallow division operators explicitly at beginning of regular expression // https://eslint.org/docs/rules/no-div-regex 'no-div-regex': 'off', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index c996395299..e4cd542683 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -38,6 +38,11 @@ module.exports = { // disallow duplicate arguments in functions 'no-dupe-args': 'error', + // Disallow duplicate conditions in if-else-if chains + // https://eslint.org/docs/rules/no-dupe-else-if + // TODO: enable, semver-major + 'no-dupe-else-if': 'off', + // disallow duplicate keys when creating object literals 'no-dupe-keys': 'error', @@ -100,6 +105,11 @@ module.exports = { // disallow multiple spaces in a regular expression literal 'no-regex-spaces': 'error', + // Disallow returning values from setters + // https://eslint.org/docs/rules/no-setter-return + // TODO: enable, semver-major (altho the guide forbids getters/setters already) + 'no-setter-return': 'off', + // disallow sparse arrays 'no-sparse-arrays': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 77412c94cd..69bc42b588 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -434,6 +434,11 @@ module.exports = { // https://eslint.org/docs/rules/padding-line-between-statements 'padding-line-between-statements': 'off', + // Disallow the use of Math.pow in favor of the ** operator + // https://eslint.org/docs/rules/prefer-exponentiation-operator + // TODO: enable, semver-major when eslint 5 is dropped + 'prefer-exponentiation-operator': 'off', + // Prefer use of an object spread over Object.assign // https://eslint.org/docs/rules/prefer-object-spread 'prefer-object-spread': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1ffd85fc1a..dcdefd47fe 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,7 +63,7 @@ "babel-preset-airbnb": "^4.1.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.1.0", + "eslint": "^5.16.0 || ^6.7.2", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", @@ -75,7 +75,7 @@ "tape": "^4.11.0" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.1.0", + "eslint": "^5.16.0 || ^6.7.2", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.15.1", From 6d05dd898acfec3299cc2be8b6188be542824965 Mon Sep 17 00:00:00 2001 From: Geo Artemenko Date: Fri, 22 Nov 2019 22:04:23 -0500 Subject: [PATCH 109/302] [eslint config] [*] [readme] normalize multiline word according to merriam-webster --- README.md | 6 +++--- packages/eslint-config-airbnb-base/rules/best-practices.js | 2 +- packages/eslint-config-airbnb-base/rules/imports.js | 2 +- react/README.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5ba3d46d9d..73371e6b44 100644 --- a/README.md +++ b/README.md @@ -2120,7 +2120,7 @@ Other Style Guides ## Blocks - - [16.1](#blocks--braces) Use braces with all multi-line blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position) + - [16.1](#blocks--braces) Use braces with all multiline blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position) ```javascript // bad @@ -2145,7 +2145,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) + - [16.2](#blocks--cuddled-elses) If you’re using multiline 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 @@ -2307,7 +2307,7 @@ Other Style Guides ## Comments - - [18.1](#comments--multiline) Use `/** ... */` for multi-line comments. + - [18.1](#comments--multiline) Use `/** ... */` for multiline comments. ```javascript // bad diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 2ac83edc8a..4cf2de48d9 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -23,7 +23,7 @@ module.exports = { 'consistent-return': 'error', // specify curly brace conventions for all control statements - curly: ['error', 'multi-line'], + curly: ['error', 'multi-line'], // multiline // require default case in switch statements 'default-case': ['error', { commentPattern: '^no default$' }], diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index c5ac1f920b..b88ace540f 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -237,7 +237,7 @@ module.exports = { // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md - 'import/no-useless-path-segments': ['error', { "commonjs": true }], + 'import/no-useless-path-segments': ['error', { commonjs: true }], // dynamic imports require a leading comment with a webpackChunkName // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md diff --git a/react/README.md b/react/README.md index 7e247e7ac1..a17cdf7a5b 100644 --- a/react/README.md +++ b/react/README.md @@ -514,7 +514,7 @@ We don’t recommend using indexes for keys if the order of items may change. ``` - - If your component has multi-line properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) + - If your component has multiline properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) ```jsx // bad From 377fbcac88728737dd8bd3180ec3819c3a2a5231 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 7 Feb 2020 08:25:49 -1000 Subject: [PATCH 110/302] [eslint config] [*] [deps] update `object.entries` --- 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 8da8cebaf1..7eed1e2034 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -74,6 +74,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.9", "object.assign": "^4.1.0", - "object.entries": "^1.1.0" + "object.entries": "^1.1.1" } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index dcdefd47fe..834584d74a 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^14.0.0", "object.assign": "^4.1.0", - "object.entries": "^1.1.0" + "object.entries": "^1.1.1" }, "devDependencies": { "@babel/runtime": "^7.6.2", From 4df908033fb52184ac58deacc19c00ceb11020d1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 7 Feb 2020 08:29:46 -1000 Subject: [PATCH 111/302] [eslint config] [*] [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest`, `tape` --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 7eed1e2034..87e4176b18 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,16 +53,16 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.6.2", - "babel-preset-airbnb": "^4.1.0", + "@babel/runtime": "^7.8.4", + "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.7.2", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.18.2", "in-publish": "^2.0.0", - "safe-publish-latest": "^1.1.3", - "tape": "^4.11.0" + "safe-publish-latest": "^1.1.4", + "tape": "^5.0.0-next.4" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.7.2", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 834584d74a..8f625c29e2 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,8 +59,8 @@ "object.entries": "^1.1.1" }, "devDependencies": { - "@babel/runtime": "^7.6.2", - "babel-preset-airbnb": "^4.1.0", + "@babel/runtime": "^7.8.4", + "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.7.2", @@ -71,8 +71,8 @@ "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", - "safe-publish-latest": "^1.1.3", - "tape": "^4.11.0" + "safe-publish-latest": "^1.1.4", + "tape": "^5.0.0-next.4" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.7.2", From f86f19cefc3b1ce19c4bf473606c95de86779b68 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 7 Feb 2020 08:32:08 -1000 Subject: [PATCH 112/302] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 87e4176b18..9d32da979c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -59,14 +59,14 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.7.2", "eslint-find-rules": "^3.4.0", - "eslint-plugin-import": "^2.18.2", + "eslint-plugin-import": "^2.20.1", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.4", "tape": "^5.0.0-next.4" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.7.2", - "eslint-plugin-import": "^2.18.2" + "eslint-plugin-import": "^2.20.1" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 8f625c29e2..c58f98a902 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -65,9 +65,9 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.7.2", "eslint-find-rules": "^3.4.0", - "eslint-plugin-import": "^2.18.2", + "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.15.1", + "eslint-plugin-react": "^7.18.3", "eslint-plugin-react-hooks": "^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -76,9 +76,9 @@ }, "peerDependencies": { "eslint": "^5.16.0 || ^6.7.2", - "eslint-plugin-import": "^2.18.2", + "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.15.1", + "eslint-plugin-react": "^7.18.3", "eslint-plugin-react-hooks": "^1.7.0" }, "engines": { From 651280e5a22d08170187bea9a2b1697832c87ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Berthommier?= Date: Fri, 7 Feb 2020 16:49:10 +0100 Subject: [PATCH 113/302] [eslint config] [base] Fix indentation with JSX Fragments --- 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 69bc42b588..e5ff42a018 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -143,7 +143,7 @@ module.exports = { ImportDeclaration: 1, flatTernaryExpressions: false, // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js - ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], + ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], ignoreComments: false }], From 41ca203e3e5afff7ccc74179caf72494c2e7bd01 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 7 Feb 2020 08:05:47 -1000 Subject: [PATCH 114/302] [Dev Deps] update `markdownlint-cli` --- README.md | 2 ++ linters/.markdownlint.json | 3 ++- package.json | 4 +++- react/README.md | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73371e6b44..ed145f3f17 100644 --- a/README.md +++ b/README.md @@ -1590,6 +1590,7 @@ Other Style Guides const isJedi = getProp('jedi'); ``` + - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties). @@ -1703,6 +1704,7 @@ Other Style Guides return name; } ``` + - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. eslint: [`no-multi-assign`](https://eslint.org/docs/rules/no-multi-assign) diff --git a/linters/.markdownlint.json b/linters/.markdownlint.json index 594886042d..118b8a6ec6 100644 --- a/linters/.markdownlint.json +++ b/linters/.markdownlint.json @@ -26,7 +26,8 @@ "comment": "MD007: Unordered list indentation: 2 spaces.", "ul-indent": { - "indent": 2 + "indent": 2, + "start_indented": true }, "comment": "MD009: Disallow trailing spaces!", diff --git a/package.json b/package.json index 581c94f612..36b4e19fab 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A mostly reasonable approach to JavaScript.", "scripts": { "preinstall": "npm run install:config && npm run install:config:base", + "postinstall": "rm -rf node_modules/markdownlint-cli/node_modules/markdownlint", "install:config": "cd packages/eslint-config-airbnb && npm prune && npm install", "install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install", "lint": "markdownlint --config linters/.markdownlint.json README.md */README.md", @@ -39,6 +40,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint-cli": "^0.13.0" + "markdownlint": "^0.19.0", + "markdownlint-cli": "^0.21.0" } } diff --git a/react/README.md b/react/README.md index a17cdf7a5b..af8c13d720 100644 --- a/react/README.md +++ b/react/README.md @@ -111,6 +111,7 @@ This style guide is mostly based on the standards that are currently prevalent i // good import Footer from './Footer'; ``` + - **Higher-order Component Naming**: Use a composite of the higher-order component’s name and the passed-in component’s name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`. > Why? A component’s `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening. From 019e0f7e07477e85249e1d584f22773120c41b91 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 13 Feb 2020 17:42:08 -0800 Subject: [PATCH 115/302] [eslint config] add config for disabled new rules --- packages/eslint-config-airbnb/rules/react.js | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index fc1a3a90a9..e712f0d77f 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -500,6 +500,35 @@ module.exports = { // Enforce that props are read-only // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md 'react/prefer-read-only-props': 'off', + + // Prevent usage of `javascript:` URLs + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md + // TODO: enable, semver-major + 'react/jsx-no-script-url': ['off', [ + { + name: 'Link', + props: ['to'], + }, + ]], + + // Disallow unnecessary fragments + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md + // TODO: enable, semver-major + 'react/jsx-no-useless-fragment': 'off', + + // Prevent adjacent inline elements not separated by whitespace + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md + // TODO: enable? semver-major + 'react/no-adjacent-inline-elements': 'off', + + // Enforce a specific function type for function components + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md + // TODO: enable! semver-minor, but do it in a major to be safe + // TODO: investigate if setting namedComponents to expression vs declaration is problematic + 'react/function-component-definition': ['off', { + namedComponents: 'function-expression', + unnamedComponents: 'function-expression', + }], }, settings: { From 3493b060ec5efddc8a06733b5dbfe9f33cbce63e Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Mon, 16 Sep 2019 19:37:29 +0900 Subject: [PATCH 116/302] [eslint config] [minor] Support eslint-plugin-react-hooks@2 --- .travis.yml | 11 +++++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index df4ad7cf56..b43ee559d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ install: - 'if [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' - 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi' + - 'if [ -n "${REACT_HOOKS}" ]; then npm install --no-save "eslint-plugin-react-hooks@${REACT_HOOKS}"; fi' script: - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi' sudo: false @@ -18,8 +19,10 @@ env: matrix: - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' matrix: fast_finish: true include: @@ -27,20 +30,28 @@ matrix: env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - node_js: "lts/*" env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "lts/*" 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=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true - node_js: "7" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "7" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "7" + env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "6" + env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb exclude: allow_failures: - node_js: "11" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c58f98a902..74a699a34c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -68,7 +68,7 @@ "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.18.3", - "eslint-plugin-react-hooks": "^1.7.0", + "eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", @@ -79,7 +79,7 @@ "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.18.3", - "eslint-plugin-react-hooks": "^1.7.0" + "eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0" }, "engines": { "node": ">= 6" From 9890b4067700be1f2d045788f4ea5fbf12b5f8bf Mon Sep 17 00:00:00 2001 From: Cain Hall Date: Mon, 2 Mar 2020 16:27:57 +1100 Subject: [PATCH 117/302] guide: import/extensions rule documentation --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index ed145f3f17..f18c47b4b7 100644 --- a/README.md +++ b/README.md @@ -1441,6 +1441,23 @@ Other Style Guides import barCss from 'bar.css'; ``` + + - [10.10](#modules--import-extensions) Do not include JavaScript filename extensions + eslint: [`import/extensions`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md) + > Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer. + + ```javascript + // bad + import foo from './foo.js'; + import bar from './bar.jsx'; + import baz from './baz/index.jsx'; + + // good + import foo from './foo'; + import bar from './bar'; + import baz from './baz'; + ``` + **[⬆ back to top](#table-of-contents)** ## Iterators and Generators From 717ba5187af3b4c36877c2a7031edf202e72cf88 Mon Sep 17 00:00:00 2001 From: lagagain Date: Fri, 28 Feb 2020 14:53:58 +0800 Subject: [PATCH 118/302] [guide]: add "bigint" type to the primitives type section. ```js var bn = 123n ``` (with "n" as suffix) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f18c47b4b7..5aa7ca2c63 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Other Style Guides - `null` - `undefined` - `symbol` + - `bigint` ```javascript const foo = 1; @@ -81,7 +82,7 @@ Other Style Guides console.log(foo, bar); // => 1, 9 ``` - - Symbols cannot be faithfully polyfilled, so they should not be used when targeting browsers/environments that don’t support them natively. + - Symbols and BigInts cannot be faithfully polyfilled, so they should not be used when targeting browsers/environments that don’t support them natively. - [1.2](#types--complex) **Complex**: When you access a complex type you work on a reference to its value. From e6e6414c973d6aa5f3672296fe3cf6c399ca570a Mon Sep 17 00:00:00 2001 From: Dmitry Semigradsky Date: Mon, 9 Mar 2020 12:55:31 +0300 Subject: [PATCH 119/302] [guide] Add link to eslint rule for https://github.com/airbnb/javascript#modules--multiline-imports-over-newlines --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5aa7ca2c63..cab3365246 100644 --- a/README.md +++ b/README.md @@ -1410,6 +1410,7 @@ Other Style Guides - [10.8](#modules--multiline-imports-over-newlines) Multiline imports should be indented just like multiline array and object literals. + eslint: [`object-curly-newline`](https://eslint.org/docs/rules/object-curly-newline) > Why? The curly braces follow the same indentation rules as every other curly brace block in the style guide, as do the trailing commas. From 165af9b6c881a0e413df824276aab4c7134dc4f9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 15:41:30 -0700 Subject: [PATCH 120/302] [Tests] actually run the linter on subpackages --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index b43ee559d0..458da3173f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,10 @@ matrix: env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true + - node_js: "lts/*" + env: LINT=true PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: LINT=true PACKAGE=eslint-config-airbnb-base - node_js: "7" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "7" From 6924bd36041c59d7b248e47f31667dbe56a8aa55 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 15:58:18 -0700 Subject: [PATCH 121/302] [Dev Deps] update `@babel/runtime` --- 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 9d32da979c..54e76a0c5e 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,7 +53,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.8.4", + "@babel/runtime": "^7.8.7", "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 74a699a34c..4888f10c02 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,7 +59,7 @@ "object.entries": "^1.1.1" }, "devDependencies": { - "@babel/runtime": "^7.8.4", + "@babel/runtime": "^7.8.7", "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", From e279b6d3a86aacbb03bd7059b899f12bfb201497 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 15:58:42 -0700 Subject: [PATCH 122/302] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-react-hooks` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 54e76a0c5e..f282516f6f 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,7 +57,7 @@ "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.7.2", + "eslint": "^5.16.0 || ^6.8.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.20.1", "in-publish": "^2.0.0", @@ -65,7 +65,7 @@ "tape": "^5.0.0-next.4" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.7.2", + "eslint": "^5.16.0 || ^6.8.0", "eslint-plugin-import": "^2.20.1" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4888f10c02..84512f8184 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,23 +63,23 @@ "babel-preset-airbnb": "^4.4.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.7.2", + "eslint": "^5.16.0 || ^6.8.0", "eslint-find-rules": "^3.4.0", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.18.3", - "eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0", + "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", "tape": "^5.0.0-next.4" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.7.2", + "eslint": "^5.16.0 || ^6.8.9", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.18.3", - "eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0" + "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0" }, "engines": { "node": ">= 6" From c75b66daa6e9f1bc0c80138465ad5115764fb18d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 16:45:56 -0700 Subject: [PATCH 123/302] [eslint config] [base] v14.1.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 12 ++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 73105da143..3d31c2426b 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,15 @@ +14.1.0 / 2020-03-12 +================== + - [minor] add new disabled rules, update eslint + - [minor] enable `import/no-useless-path-segments` for commonjs (#2113) + - [fix] `whitespace`: only set erroring rules to "warn" + - Fix indentation with JSX Fragments (#2157) + - [patch] `import/no-extraneous-dependencies`: Support karma config files (#2121) + - [readme] normalize multiline word according to merriam-webster (#2138) + - [deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `object.entries`, `confusing-browser-globals` + - [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest`, `tape` + - [tests] re-enable eslint rule `prefer-destructuring` internally (#2110) + 14.0.0 / 2019-08-09 ================== - [breaking] `no-self-assign`: enable `props` option diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f282516f6f..f5bdc3a5bf 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": "14.0.0", + "version": "14.1.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From e7062c32bbb032a721dedbc5982b8fefe8b6850a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 22:47:00 -0700 Subject: [PATCH 124/302] [eslint config] [deps] 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 84512f8184..c7f966eb74 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^14.0.0", + "eslint-config-airbnb-base": "^14.1.0", "object.assign": "^4.1.0", "object.entries": "^1.1.1" }, @@ -75,7 +75,7 @@ "tape": "^5.0.0-next.4" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.9", + "eslint": "^5.16.0 || ^6.8.0", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.19.0", From a3355f90c4b52445dbe828fd4e71a7e7d12ef202 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Mar 2020 22:58:43 -0700 Subject: [PATCH 125/302] [eslint config] v18.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 13 +++++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 8c16dd3c1a..4bb3083e8b 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,16 @@ +18.1.0 / 2020-03-12 +================== + - [minor] Support eslint-plugin-react-hooks@2 (#2090) + - [minor] add new disabled rules, update eslint + - [fix] `whitespace`: only set erroring rules to "warn" + - [patch] Remove duplicate `componentDidCatch` (#2108) + - [patch] Add `static-variables` to `sort-comp` rule (#2109) + - [readme] clarify hooks section in readme (#2074) + - [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `object.entries` + - [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest`, `tape` + - [tests] re-enable eslint rule `prefer-destructuring` internally (#2110) + - [tests] fix eslint errors from c66cfc3 (#2112) + 18.0.1 / 2019-08-13 ================== - [patch] `react/state-in-constructor`: fix incorrect configuration diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c7f966eb74..975b067b50 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "18.0.1", + "version": "18.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From d529ccaea3b3da1c1cfce686b119d662e8e05c69 Mon Sep 17 00:00:00 2001 From: "David J. Bradshaw" Date: Sat, 14 Mar 2020 07:36:30 +0000 Subject: [PATCH 126/302] [eslint config] readme: fix typo --- packages/eslint-config-airbnb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 94e4ac54c4..9cb0270467 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -56,7 +56,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and 2. Add `"extends": "airbnb"` to your `.eslintrc` -### eslint-config/airbnb/hooks +### eslint-config-airbnb/hooks This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": ["airbnb", "airbnb/hooks"]` to your `.eslintrc` From f075a0db50f1fd6a798cb6e0c3677421deb7b522 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 14 Mar 2020 15:39:55 -0700 Subject: [PATCH 127/302] [eslint config] [patch] relax `eslint-plugin-react-hooks` down to v2.3, due to a controversial change in v2.5 Fixes #2195. --- 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 975b067b50..baebcb04f5 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -68,7 +68,7 @@ "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.19.0", - "eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0", + "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", @@ -79,7 +79,7 @@ "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.19.0", - "eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0" + "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0" }, "engines": { "node": ">= 6" From d3628e26003a602535b91a8951da7a692fc685ca Mon Sep 17 00:00:00 2001 From: Nick Reiley Date: Mon, 16 Mar 2020 23:39:16 +0500 Subject: [PATCH 128/302] [eslint config] [base] [patch] Disable `prefer-object-spread` for `airbnb-base/legacy` --- packages/eslint-config-airbnb-base/legacy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index 18576f83e5..e5c9089c75 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -28,6 +28,7 @@ module.exports = { message: 'Please use Object.defineProperty instead.', }], 'no-var': 'off', + 'prefer-object-spread': 'off', strict: ['error', 'safe'], } }; From 0375265cbd43635f8062615995a6a86f22fd0fc2 Mon Sep 17 00:00:00 2001 From: Nick Reiley Date: Mon, 16 Mar 2020 23:27:49 +0500 Subject: [PATCH 129/302] [eslint config] [base] [patch] Allow triple-slash (///) comments --- 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 e5ff42a018..793fe9185f 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -501,7 +501,7 @@ module.exports = { 'spaced-comment': ['error', 'always', { line: { exceptions: ['-', '+'], - markers: ['=', '!'], // space here to support sprockets directives + markers: ['=', '!', '/'], // space here to support sprockets directives, slash for TS /// comments }, block: { exceptions: ['-', '+'], From e4f3dd4effd8e579427eeceb60d2f4e2ed5d08a7 Mon Sep 17 00:00:00 2001 From: Jiahao Date: Tue, 10 Mar 2020 23:24:39 -0400 Subject: [PATCH 130/302] [react] Update Chinese (Simplified) Translation The translation for Chinese (Simplified) is outdated. Changed to an up-to-date translation that synced with current English version, enhanced expressions for better readability, and also added notes of technical terms for Chinese readers. --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index af8c13d720..99518e5a75 100644 --- a/react/README.md +++ b/react/README.md @@ -718,7 +718,7 @@ We don’t recommend using indexes for keys if the order of items may change. This JSX/React style guide is also available in other languages: - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [JasonBoy/javascript](https://github.com/JasonBoy/javascript/tree/master/react) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [jhcccc/javascript](https://github.com/jhcccc/javascript/tree/master/react) - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript/tree/master/react) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) - ![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/tree/master/react) From c0ee2c492460ac7428286c2bb0b48b4a058430fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9A=8A=E9=85=B1?= Date: Tue, 31 Mar 2020 17:41:38 +0800 Subject: [PATCH 131/302] [guide] unquote properties in whitespace key spacing section --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cab3365246..57ebc57624 100644 --- a/README.md +++ b/README.md @@ -2914,11 +2914,11 @@ Other Style Guides ```javascript // bad - var obj = { "foo" : 42 }; - var obj2 = { "foo":42 }; + var obj = { foo : 42 }; + var obj2 = { foo:42 }; // good - var obj = { "foo": 42 }; + var obj = { foo: 42 }; ``` From 06b3ab11d9a443ff46f052dd00375e271e5146e6 Mon Sep 17 00:00:00 2001 From: Paul Matthew Barrameda Date: Wed, 19 Feb 2020 22:56:52 -0800 Subject: [PATCH 132/302] [eslint config] [minor] Fix typo in no-multiple-empty-lines rule ## Why is the change being made? This change is made because the Airbnb documentation states to "avoid a newline at the beginning of files", yet the code does not follow this. ## What has changed to address the problem? This change fixes the `no-multiple-empty-lines` rule by setting max beginning of file (`maxBOF`) to from 1 to 0. ## How was this change tested? This change was tested with `npm test`. ## Related docs https://github.com/airbnb/javascript#whitespace--no-multiple-empty-lines --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- packages/eslint-config-airbnb/test/test-react-order.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 793fe9185f..cf5a7b5dd5 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -313,7 +313,7 @@ module.exports = { // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning // https://eslint.org/docs/rules/no-multiple-empty-lines - 'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 1, maxEOF: 0 }], + 'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 0, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 6289973f03..15dd8da2f6 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -24,7 +24,7 @@ function lint(text) { } function wrapComponent(body) { - return ` + return `\ import React from 'react'; export default class MyComponent extends React.Component { From c48a060aff9a4ba66003b18e6a27fd899581f95a Mon Sep 17 00:00:00 2001 From: Severiano Badajoz Date: Fri, 5 Jun 2020 15:09:12 -0700 Subject: [PATCH 133/302] [eslint config] [patch] set `explicitSpread` to ignore for `react/jsx-props-no-spreading` --- packages/eslint-config-airbnb/rules/react.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index e712f0d77f..84bbf6c162 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -494,6 +494,7 @@ module.exports = { 'react/jsx-props-no-spreading': ['error', { html: 'enforce', custom: 'enforce', + explicitSpread: 'ignore', exceptions: [], }], From d34f8074590e1497a9a90947181339435ce335d4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 7 Jun 2020 20:05:48 -0700 Subject: [PATCH 134/302] [Deps] update `object.entries` --- 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 f5bdc3a5bf..5ef97f70b5 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -74,6 +74,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.9", "object.assign": "^4.1.0", - "object.entries": "^1.1.1" + "object.entries": "^1.1.2" } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index baebcb04f5..4e0ad31f90 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^14.1.0", "object.assign": "^4.1.0", - "object.entries": "^1.1.1" + "object.entries": "^1.1.2" }, "devDependencies": { "@babel/runtime": "^7.8.7", From 7aa0fa14d65d10e7bf259089d9964d41eb8ca5e0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 7 Jun 2020 20:50:43 -0700 Subject: [PATCH 135/302] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `babel-preset-airbnb`, `eslint-find-rules`, `in-publish`, `tape` --- packages/eslint-config-airbnb-base/package.json | 12 ++++++------ packages/eslint-config-airbnb/package.json | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 5ef97f70b5..494b1aa879 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -54,19 +54,19 @@ "homepage": "https://github.com/airbnb/javascript", "devDependencies": { "@babel/runtime": "^7.8.7", - "babel-preset-airbnb": "^4.4.0", + "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0", - "eslint-find-rules": "^3.4.0", - "eslint-plugin-import": "^2.20.1", - "in-publish": "^2.0.0", + "eslint-find-rules": "^3.5.0", + "eslint-plugin-import": "^2.21.1", + "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", - "tape": "^5.0.0-next.4" + "tape": "^5.0.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0", - "eslint-plugin-import": "^2.20.1" + "eslint-plugin-import": "^2.21.1" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4e0ad31f90..7f56732360 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -60,25 +60,25 @@ }, "devDependencies": { "@babel/runtime": "^7.8.7", - "babel-preset-airbnb": "^4.4.0", + "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0", - "eslint-find-rules": "^3.4.0", - "eslint-plugin-import": "^2.20.1", + "eslint-find-rules": "^3.5.0", + "eslint-plugin-import": "^2.21.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0", - "in-publish": "^2.0.0", + "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", - "tape": "^5.0.0-next.4" + "tape": "^5.0.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0", - "eslint-plugin-import": "^2.20.1", + "eslint-plugin-import": "^2.21.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0" }, "engines": { From cad3db31695631a7877cece8903eea1f41d59e03 Mon Sep 17 00:00:00 2001 From: Vlad Shcherbin Date: Sun, 7 Jun 2020 00:01:51 +0300 Subject: [PATCH 136/302] [eslint config] [base] [minor] Disallow multiple empty lines --- 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 cf5a7b5dd5..05f687171e 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -313,7 +313,7 @@ module.exports = { // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning // https://eslint.org/docs/rules/no-multiple-empty-lines - 'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 0, maxEOF: 0 }], + 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition From 8aee3e160053d07b4c156f0885fb5a6da4e19603 Mon Sep 17 00:00:00 2001 From: Vlad Shcherbin Date: Wed, 20 May 2020 13:21:10 +0300 Subject: [PATCH 137/302] [eslint config] [base] [patch] Include 'context' exception for `no-param-reassign` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 4cf2de48d9..0307c64345 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -194,6 +194,7 @@ module.exports = { 'accumulator', // for reduce accumulators 'e', // for e.returnvalue 'ctx', // for Koa routing + 'context', // for Koa routing 'req', // for Express requests 'request', // for Express requests 'res', // for Express responses From b58700607707c7e280e5e266a884115cbcea806c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Jun 2020 14:49:21 -0700 Subject: [PATCH 138/302] [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 494b1aa879..2957b06427 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -59,14 +59,14 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0", "eslint-find-rules": "^3.5.0", - "eslint-plugin-import": "^2.21.1", + "eslint-plugin-import": "^2.21.2", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", "tape": "^5.0.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0", - "eslint-plugin-import": "^2.21.1" + "eslint-plugin-import": "^2.21.2" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7f56732360..3d96a8a55e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -65,7 +65,7 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0", "eslint-find-rules": "^3.5.0", - "eslint-plugin-import": "^2.21.1", + "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0", @@ -76,7 +76,7 @@ }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0", - "eslint-plugin-import": "^2.21.1", + "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0" From fe2e451ba75b2ebfedc1cf4f9bf217f104b06a1d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Jun 2020 14:58:23 -0700 Subject: [PATCH 139/302] [Tests] add `node` `v14`; remove `v9`, `v11` --- .travis.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 458da3173f..a240129152 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: node_js node_js: + - "14" - "12" - - "11" - "10" - - "9" - "8" before_install: - 'nvm install-latest-npm' @@ -44,12 +43,6 @@ matrix: env: LINT=true PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true PACKAGE=eslint-config-airbnb-base - - node_js: "7" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "7" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb - - node_js: "7" - env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "6" @@ -58,9 +51,6 @@ matrix: env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb exclude: allow_failures: - - node_js: "11" - - node_js: "9" - - node_js: "7" - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base From 22adc06f56a94437a533c4935d6706a511b3dc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 10 Apr 2020 00:47:18 +0200 Subject: [PATCH 140/302] [eslint config] [minor] Allow using `eslint-plugin-react-hooks` v3 and v4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kristóf Poduszló Co-authored-by: Jordan Harband --- .travis.yml | 16 ++++++++++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a240129152..ee392c7703 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,13 @@ env: matrix: - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' matrix: fast_finish: true @@ -29,12 +33,20 @@ matrix: env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - node_js: "lts/*" env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "lts/*" 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=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "lts/*" @@ -47,6 +59,10 @@ matrix: env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "6" + env: TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "6" + env: TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - node_js: "6" env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb exclude: diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 3d96a8a55e..0e08d078fc 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -68,7 +68,7 @@ "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", - "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0", + "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", @@ -79,7 +79,7 @@ "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", - "eslint-plugin-react-hooks": "^2.3.0 || ^1.7.0" + "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0" }, "engines": { "node": ">= 6" From 5b462a04cdfebba712a3df18926edfcb4103d2a9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Jun 2020 15:43:13 -0700 Subject: [PATCH 141/302] [eslint config] [*] [new] add `eslint` `v7` --- .travis.yml | 37 ++++++++++++++++++- .../eslint-config-airbnb-base/package.json | 4 +- .../rules/best-practices.js | 5 +++ .../eslint-config-airbnb-base/rules/errors.js | 13 ++++++- .../eslint-config-airbnb-base/rules/es6.js | 10 +++++ packages/eslint-config-airbnb/package.json | 4 +- 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee392c7703..b7eb96d7ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ node_js: - "14" - "12" - "10" - - "8" before_install: - 'nvm install-latest-npm' install: @@ -16,6 +15,11 @@ script: sudo: false env: matrix: + - 'TEST=true ESLINT=7 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=7 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=7 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=7 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=7 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' @@ -29,6 +33,17 @@ env: matrix: fast_finish: true include: + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=7 PACKAGE=eslint-config-airbnb-base + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=7 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb + - node_js: "lts/*" - node_js: "lts/*" env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - node_js: "lts/*" @@ -55,6 +70,26 @@ matrix: env: LINT=true PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true PACKAGE=eslint-config-airbnb-base + - node_js: "8" + env: TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base + - node_js: "8" + env: TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "8" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb + - node_js: "8" + env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - node_js: "6" env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - node_js: "6" diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2957b06427..b691e1a3b2 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,7 +57,7 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.8.0", + "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.5.0", "eslint-plugin-import": "^2.21.2", "in-publish": "^2.0.1", @@ -65,7 +65,7 @@ "tape": "^5.0.1" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.0", + "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.21.2" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 0307c64345..8e1d991304 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -28,6 +28,11 @@ module.exports = { // require default case in switch statements 'default-case': ['error', { commentPattern: '^no default$' }], + // Enforce default clauses in switch statements to be last + // https://eslint.org/docs/rules/default-case-last + // TODO: enable, semver-minor, when eslint v7 is required (which is a major) + 'default-case-last': 'off', + // https://eslint.org/docs/rules/default-param-last // TODO: enable, semver-minor, when eslint v6.4 is required (which is a major) 'default-param-last': 'off', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index e4cd542683..15b6130a20 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -91,6 +91,11 @@ module.exports = { // disallow irregular whitespace outside of strings and comments 'no-irregular-whitespace': 'error', + // Disallow Number Literals That Lose Precision + // https://eslint.org/docs/rules/no-loss-of-precision + // TODO: enable, semver-minor, once eslint v7.1 is required (which is major) + 'no-loss-of-precision': 'off', + // Disallow characters which are made with multiple code points in character class syntax // https://eslint.org/docs/rules/no-misleading-character-class 'no-misleading-character-class': 'error', @@ -131,13 +136,19 @@ module.exports = { // disallow negating the left operand of relational operators // https://eslint.org/docs/rules/no-unsafe-negation 'no-unsafe-negation': 'error', + + // Disallow useless backreferences in regular expressions + // https://eslint.org/docs/rules/no-useless-backreference + // TODO: enable, semver-minor, once eslint v7 is required (which is major) + 'no-useless-backreference': 'off', + // disallow negation of the left operand of an in expression // deprecated in favor of no-unsafe-negation 'no-negated-in-lhs': 'off', // Disallow assignments that can lead to race conditions due to usage of await or yield // https://eslint.org/docs/rules/require-atomic-updates - // TODO: enable, semver-major + // note: not enabled because it is very buggy 'require-atomic-updates': 'off', // disallow comparisons with the value NaN diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index bfdc6d29e4..02c616dad5 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -60,6 +60,16 @@ module.exports = { // https://eslint.org/docs/rules/no-new-symbol 'no-new-symbol': 'error', + // Disallow specified names in exports + // https://eslint.org/docs/rules/no-restricted-exports + // TODO enable, semver-minor, once eslint v7 is required (which is major) + 'no-restricted-exports': ['off', { + restrictedNamedExports: [ + 'default', // use `export default` to provide a default export + 'then', // this will cause tons of confusion when your module is dynamically `import()`ed + ], + }], + // disallow specific imports // https://eslint.org/docs/rules/no-restricted-imports 'no-restricted-imports': ['off', { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0e08d078fc..97703e59b0 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,7 +63,7 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.8.0", + "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.5.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", @@ -75,7 +75,7 @@ "tape": "^5.0.1" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.0", + "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", From 78457af2c55cc62cf4379c190b7621a341814692 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Jun 2020 23:25:49 -0700 Subject: [PATCH 142/302] [eslint config] [base] v14.2.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 10 ++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 3d31c2426b..2dd956f691 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,13 @@ +14.2.0 / 2020-06-10 +================== + - [new] add `eslint` `v7` + - [minor] Disallow multiple empty lines (#2238) + - [minor] Fix typo in no-multiple-empty-lines rule (#2168) + - [patch] Include 'context' exception for `no-param-reassign` (#2230) + - [patch] Allow triple-slash (///) comments (#2197) + - [patch] Disable `prefer-object-spread` for `airbnb-base/legacy` (#2198) + - [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `babel-preset-airbnb`, `eslint-find-rules`, `in-publish`, `tape`, `object.entries` + 14.1.0 / 2020-03-12 ================== - [minor] add new disabled rules, update eslint diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index b691e1a3b2..cea08e9df9 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": "14.1.0", + "version": "14.2.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 562e3519b874d91b369c5c6fe8a94408a380758b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Jun 2020 11:53:53 -0700 Subject: [PATCH 143/302] [Dev Deps] update `markdownlint`, `markdownlint-cli` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 36b4e19fab..e4fe0f3dea 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint": "^0.19.0", - "markdownlint-cli": "^0.21.0" + "markdownlint": "^0.20.3", + "markdownlint-cli": "^0.23.1" } } From f550ded6dab8dac9d42f2dfa5f2ed9858f0fe045 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Jun 2020 12:03:46 -0700 Subject: [PATCH 144/302] [eslint config] [tests] fix for eslint 7 --- packages/eslint-config-airbnb/test/test-react-order.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 15dd8da2f6..d45cac8ae1 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -1,10 +1,10 @@ import test from 'tape'; -import { CLIEngine } from 'eslint'; +import { CLIEngine, ESLint } from 'eslint'; import eslintrc from '..'; import reactRules from '../rules/react'; import reactA11yRules from '../rules/react-a11y'; -const cli = new CLIEngine({ +const cli = new (CLIEngine || ESLint)({ useEslintrc: false, baseConfig: eslintrc, @@ -19,7 +19,7 @@ const cli = new CLIEngine({ function lint(text) { // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext - const linter = cli.executeOnText(text); + const linter = CLIEngine ? cli.executeOnText(text) : cli.lintText(text); return linter.results[0]; } From 197b50c07627863e5b3524504bf4f3240a0e2537 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Jun 2020 11:57:41 -0700 Subject: [PATCH 145/302] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 6 +++--- packages/eslint-config-airbnb/rules/react-a11y.js | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 97703e59b0..e66cc67033 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^14.1.0", + "eslint-config-airbnb-base": "^14.2.0", "object.assign": "^4.1.0", "object.entries": "^1.1.2" }, @@ -66,7 +66,7 @@ "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.5.0", "eslint-plugin-import": "^2.21.2", - "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-jsx-a11y": "^6.3.0", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", @@ -77,7 +77,7 @@ "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.21.2", - "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-jsx-a11y": "^6.3.0", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 69cf63b01f..85485b03bb 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -236,5 +236,11 @@ module.exports = { specialLink: ['to'], aspects: ['noHref', 'invalidHref', 'preferButton'], }], + + // Ensure the autocomplete attribute is correct and suitable for the form field it is used with + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md + 'jsx-a11y/autocomplete-valid': ['off', { + inputComponents: [], + }], }, }; From 54955410ee53fd82e6caa5879ccd0c413640706a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Jun 2020 13:11:38 -0700 Subject: [PATCH 146/302] [eslint config] v18.2.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 11 +++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 4bb3083e8b..11595f01a6 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,14 @@ +18.2.0 / 2020-06-18 +================== + - [new] add `eslint` `v7` (#2240) + - [minor] Allow using `eslint-plugin-react-hooks` v3 and v4 (#2235, #2207) + - [minor] Fix typo in no-multiple-empty-lines rule (#2168) + - [patch] set `explicitSpread` to ignore for `react/jsx-props-no-spreading` (#2237) + - [patch] relax `eslint-plugin-react-hooks` down to v2.3, due to a controversial change in v2.5 + - [readme] fix typo (#2194) + - [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-plugin-react`, `babel-preset-airbnb`, `eslint-find-rules`, `in-publish`, `tape`, `object.entries` + - [tests] fix for eslint 7 + 18.1.0 / 2020-03-12 ================== - [minor] Support eslint-plugin-react-hooks@2 (#2090) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e66cc67033..2b4be69fdb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "18.1.0", + "version": "18.2.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 5124de23da0190b686850c9582e5a0960a607ae6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 27 Jun 2020 13:22:33 -0700 Subject: [PATCH 147/302] [eslint config] [base] add new rules from v7.3 --- packages/eslint-config-airbnb-base/rules/errors.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 15b6130a20..fa54905ef8 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -103,6 +103,11 @@ module.exports = { // disallow the use of object properties of the global object (Math and JSON) as functions 'no-obj-calls': 'error', + // Disallow returning values from Promise executor functions + // https://eslint.org/docs/rules/no-promise-executor-return + // TODO: enable, semver-minor, once eslint v7.3 is required (which is major) + 'no-promise-executor-return': 'off', + // disallow use of Object.prototypes builtins directly // https://eslint.org/docs/rules/no-prototype-builtins 'no-prototype-builtins': 'error', @@ -129,6 +134,13 @@ module.exports = { // disallow unreachable statements after a return, throw, continue, or break statement 'no-unreachable': 'error', + // Disallow loops with a body that allows only one iteration + // https://eslint.org/docs/rules/no-unreachable-loop + // TODO: enable, semver-minor, once eslint v7.3 is required (which is major) + 'no-unreachable-loop': ['off', { + ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement + }], + // disallow return/throw/break/continue inside finally blocks // https://eslint.org/docs/rules/no-unsafe-finally 'no-unsafe-finally': 'error', From c5bee75b1b358a3749f1a6d38ee6fad73de28e29 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Jun 2020 22:55:52 -0700 Subject: [PATCH 148/302] [eslint config] [*] [deps] update `eslint-plugin-import`, use valid `import/no-cycle` `maxDepth` option --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 2 +- packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index cea08e9df9..146b7d5035 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -59,14 +59,14 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.5.0", - "eslint-plugin-import": "^2.21.2", + "eslint-plugin-import": "^2.22.0", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", "tape": "^5.0.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.21.2" + "eslint-plugin-import": "^2.22.0" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index b88ace540f..95568d6103 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -233,7 +233,7 @@ module.exports = { // Forbid cyclical dependencies between modules // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md - 'import/no-cycle': ['error', { maxDepth: Infinity }], + 'import/no-cycle': ['error', { maxDepth: '∞' }], // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2b4be69fdb..02c702ca76 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -65,7 +65,7 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.5.0", - "eslint-plugin-import": "^2.21.2", + "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsx-a11y": "^6.3.0", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", @@ -76,7 +76,7 @@ }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.21.2", + "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsx-a11y": "^6.3.0", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0" From 3dcc59112308211b6ac8478a4ad997ed3f17d9b1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 5 Aug 2020 22:04:10 -0700 Subject: [PATCH 149/302] [eslint config] [base] add `id-denylist` rule --- packages/eslint-config-airbnb-base/rules/style.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 05f687171e..8403ebb75b 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -107,8 +107,13 @@ module.exports = { // Blacklist certain identifiers to prevent them being used // https://eslint.org/docs/rules/id-blacklist + // TODO: semver-major, remove once eslint v7.4+ is required 'id-blacklist': 'off', + // disallow specified identifiers + // https://eslint.org/docs/rules/id-denylist + 'id-denylist': 'off', + // this option enforces minimum and maximum identifier lengths // (variable names, property names etc.) 'id-length': 'off', From 973384be1b4ec2c58c5d9ba113a54a10cb757b96 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 5 Aug 2020 22:06:20 -0700 Subject: [PATCH 150/302] [eslint config] [*] [dev deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 146b7d5035..7bb31343e5 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,12 +53,12 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.8.7", + "@babel/runtime": "^7.11.2", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-find-rules": "^3.5.0", + "eslint-find-rules": "^3.6.0", "eslint-plugin-import": "^2.22.0", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 02c702ca76..105b3811a6 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,15 +59,15 @@ "object.entries": "^1.1.2" }, "devDependencies": { - "@babel/runtime": "^7.8.7", + "@babel/runtime": "^7.11.2", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-find-rules": "^3.5.0", + "eslint-find-rules": "^3.6.0", "eslint-plugin-import": "^2.22.0", - "eslint-plugin-jsx-a11y": "^6.3.0", - "eslint-plugin-react": "^7.20.0", + "eslint-plugin-jsx-a11y": "^6.3.1", + "eslint-plugin-react": "^7.20.5", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", From 1dc71d38395633f9f9099614765bd4361c9a9c64 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Aug 2020 09:36:24 -0700 Subject: [PATCH 151/302] [guide] [react] add missing PascalCase guidance for prop names --- react/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 99518e5a75..d964d17a30 100644 --- a/react/README.md +++ b/react/README.md @@ -267,7 +267,7 @@ This style guide is mostly based on the standards that are currently prevalent i ## Props - - Always use camelCase for prop names. + - Always use camelCase for prop names, or PascalCase if the prop value is a React component. ```jsx // bad @@ -280,6 +280,7 @@ This style guide is mostly based on the standards that are currently prevalent i ``` From a24dc34a4a2748c99006a48e997aa0a06b1d4d94 Mon Sep 17 00:00:00 2001 From: Akshath Sivaprasad Date: Wed, 5 Aug 2020 21:38:20 -0700 Subject: [PATCH 152/302] [guide] [react] Add examples for formatting multiline conditional components --- react/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/react/README.md b/react/README.md index d964d17a30..4811ddaf70 100644 --- a/react/README.md +++ b/react/README.md @@ -214,6 +214,27 @@ This style guide is mostly based on the standards that are currently prevalent i // good {showButton &&