From 530278467f8b0a1b2aee632fbeee543e6732ef35 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Aug 2019 12:29:20 -0700 Subject: [PATCH 001/214] [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 002/214] [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 003/214] [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 004/214] [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 005/214] 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 006/214] [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 007/214] [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 008/214] [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 009/214] [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 010/214] [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 011/214] [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 012/214] [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 013/214] [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 014/214] [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 015/214] [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 016/214] [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 017/214] [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 018/214] [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 019/214] [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 020/214] [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 021/214] [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 022/214] [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 023/214] [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 024/214] [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 025/214] [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 026/214] [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 027/214] [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 028/214] [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 029/214] 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 030/214] [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 031/214] [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 032/214] [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 033/214] [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 034/214] [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 035/214] [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 036/214] [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 037/214] [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 038/214] [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 039/214] [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 040/214] [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 041/214] [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 042/214] [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 043/214] [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 044/214] [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 045/214] [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 046/214] [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 047/214] [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 048/214] [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 049/214] [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 050/214] [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 051/214] [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 052/214] [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 053/214] [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 054/214] [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 055/214] [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 056/214] [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 057/214] [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 058/214] [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 059/214] [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 060/214] [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 061/214] [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 062/214] [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 063/214] [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 064/214] [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 &&