From abd5b3d1e2e79a7e4db1be06cf639c1768cab760 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 07:13:34 +0200 Subject: [PATCH 01/35] upgrade eslint-plugin-react-hooks --- CHANGELOG.md | 6 ++++++ package.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3e38818..06e7e630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.4.0 + +## Changes + +- **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` + # v0.3.1 ## Changes diff --git a/package.json b/package.json index be36e5c7..abc560c6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", "eslint-plugin-react": "^7.17.0", - "eslint-plugin-react-hooks": "^2.3.0" + "eslint-plugin-react-hooks": "^4.0.2" }, "peerDependencies": { "babel-eslint": "^10.0.3", @@ -47,7 +47,7 @@ "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", "eslint-plugin-react": "^7.17.0", - "eslint-plugin-react-hooks": "^2.3.0" + "eslint-plugin-react-hooks": "^4.0.2" }, "engines": { "node": ">= 6" From e0e33d4070db07fcf54c24218a761faf20dc548a Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 07:17:27 +0200 Subject: [PATCH 02/35] Fix dependency list in README --- CHANGELOG.md | 2 ++ README.md | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06e7e630..f2e32ef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Changes - **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` +- Fix dependency list in README + # v0.3.1 diff --git a/README.md b/README.md index 61512793..62580dfb 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+, FlowJS and React. -It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, +It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-ramda`, `eslint-plugin-react-hooks`, `eslint-plugin-jsx-a11y` and `eslint-plugin-eslint-comments`. If you don't need React, see `eslint-config-nugit/base`. @@ -39,6 +39,6 @@ see `eslint-config-nugit/base`. Our default export contains all of our ESLint rules, including ECMAScript 6+ and FlowJS. -It requires `eslint` and `eslint-plugin-import`. +It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-flowtype` and `eslint-plugin-ramda`. - Add `"extends": "nugit/base"` to your .eslintrc From d44cec595d8f817256d754a776c4183828988121 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 08:05:49 +0200 Subject: [PATCH 03/35] upgrade eslint-plugin-flowtype --- CHANGELOG.md | 1 + package.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2e32ef5..ea90b2f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Changes - **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` +- **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.1.0` - Fix dependency list in README diff --git a/package.json b/package.json index abc560c6..89168771 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "babel-eslint": "^10.0.3", "eslint": "^6.8.0", "eslint-plugin-eslint-comments": "^3.1.2", - "eslint-plugin-flowtype": "^4.5.3", + "eslint-plugin-flowtype": "^5.1.0", "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", @@ -42,7 +42,7 @@ "babel-eslint": "^10.0.3", "eslint": "^6.8.0", "eslint-plugin-eslint-comments": "^3.1.2", - "eslint-plugin-flowtype": "^4.5.3", + "eslint-plugin-flowtype": "^5.1.0", "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", From 0ada918932706bf2da48decf28300e99ca32bab2 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 08:13:36 +0200 Subject: [PATCH 04/35] upgrade eslint-plugin-react --- CHANGELOG.md | 1 + package.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea90b2f3..5a92aed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` - **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.1.0` +- upgrade `eslint-plugin-react` to `^7.20.0` - Fix dependency list in README diff --git a/package.json b/package.json index 89168771..45fc9163 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", - "eslint-plugin-react": "^7.17.0", + "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.2" }, "peerDependencies": { @@ -46,7 +46,7 @@ "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-ramda": "^2.5.1", - "eslint-plugin-react": "^7.17.0", + "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.2" }, "engines": { From 90568b4641af0769e945ff35b96f18c113047822 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 08:54:55 +0200 Subject: [PATCH 05/35] set `require-atomic-updates`: `error` --- CHANGELOG.md | 6 +++++- rules/errors.js | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a92aed2..dadb8511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# v0.4.0 +# Unreleased ## Changes @@ -7,6 +7,10 @@ - upgrade `eslint-plugin-react` to `^7.20.0` - Fix dependency list in README +## Likely to cause new errors + +- `require-atomic-updates`: `error` +- # v0.3.1 diff --git a/rules/errors.js b/rules/errors.js index d7e704bd..2db35418 100644 --- a/rules/errors.js +++ b/rules/errors.js @@ -123,8 +123,7 @@ module.exports = { // 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 - 'require-atomic-updates': 'off', + 'require-atomic-updates': 'error', // disallow comparisons with the value NaN 'use-isnan': 'error', From 2f3fa09dc18fcc21bcfa52ec791db55dec8edc85 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 08:57:09 +0200 Subject: [PATCH 06/35] Add flowtype rules --- CHANGELOG.md | 7 +++++-- rules/flow.js | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dadb8511..564b2718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,11 @@ ## Likely to cause new errors -- `require-atomic-updates`: `error` -- +- `require-atomic-updates` +- `flowtype/require-compound-type-alias`: `always` +- `flowtype/require-readonly-react-props` +- `flowtype/require-types-at-top` +- `lowtype/type-import-style`: `identifier` # v0.3.1 diff --git a/rules/flow.js b/rules/flow.js index 3bd74931..0ddd1a99 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -15,23 +15,40 @@ module.exports = { 'flowtype/delimiter-dangle': ['error', 'always-multiline', 'always-multiline', 'always-multiline'], 'flowtype/generic-spacing': ['error', 'never'], 'flowtype/newline-after-flow-annotation': ['error', 'always'], - 'flowtype/object-type-delimiter': ['error', 'comma'], 'flowtype/no-mixed': 'off', 'flowtype/no-dupe-keys': 'error', + // TODO: enable? + 'flowtype/no-existential-type': 'off', + 'flowtype/no-flow-fix-me-comments': 'off', + 'flowtype/no-mixed': 'off', + // TODO: enable? + 'flowtype/no-mutable-array': 'off', 'flowtype/no-primitive-constructor-types': 'error', 'flowtype/no-types-missing-file-annotation': 'error', 'flowtype/no-unused-expressions': 'error', + // TODO: disable any? 'flowtype/no-weak-types': ['error', { any: false }], + 'flowtype/object-type-delimiter': ['error', 'comma'], + 'flowtype/require-compound-type-alias': ['error', 'always'], + 'flowtype/require-exact-type': 'off', + 'flowtype/require-indexer-name': 'off', + 'flowtype/require-inexact-type': 'off', 'flowtype/require-parameter-type': 'off', - 'flowtype/require-readonly-react-props': 'off', + 'flowtype/require-readonly-react-props': 'error', 'flowtype/require-return-type': 'off', + 'flowtype/require-types-at-top': 'error', 'flowtype/require-valid-file-annotation': 'off', - 'flowtype/sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], + 'flowtype/require-variable-type': 'off', 'flowtype/semi': ['error', 'always'], + 'flowtype/sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], 'flowtype/space-after-type-colon': ['error', 'always'], 'flowtype/space-before-generic-bracket': ['error', 'never'], 'flowtype/space-before-type-colon': ['error', 'never'], + // TODO: enable? + 'flowtype/spread-exact-type': 'off', 'flowtype/type-id-match': 'off', + // Use identifier as declaration imports are not well supported by vscode + 'flowtype/type-import-style': ['error', 'identifier'], 'flowtype/union-intersection-spacing': ['error', 'always'], 'flowtype/use-flow-type': 'warn', }, From 3d4e63b0d850baf271b3c8878d7cdd7f195e0987 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 09:07:33 +0200 Subject: [PATCH 07/35] add import rules --- CHANGELOG.md | 10 +++++++++- base.js | 5 +++++ rules/imports.js | 34 ++++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 564b2718..854457f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,15 @@ - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/require-types-at-top` -- `lowtype/type-import-style`: `identifier` +- `flowtype/type-import-style`: `identifier` +- `import/no-namespace` +- `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` +- `import/no-unassigned-import` +- `import/no-anonymous-default-export`: for functions & classes +- `import/exports-last` +- `import/group-exports` +- `import/no-unused-modules` + # v0.3.1 diff --git a/base.js b/base.js index 85079ae4..96caa586 100644 --- a/base.js +++ b/base.js @@ -33,6 +33,11 @@ module.exports = { 'jest': true, 'shared-node-browser': true, }, + rules: { + // Reports modules without any exports, or with unused exports + // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md + 'import/no-unused-modules': 'off' + } }, ], }; diff --git a/rules/imports.js b/rules/imports.js index 1217127a..5b730d57 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -129,9 +129,8 @@ module.exports = { 'import/no-duplicates': 'error', // disallow namespace imports - // TODO: enable? // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md - 'import/no-namespace': 'off', + 'import/no-namespace': 'error', // Ensure consistent use of file extension within the import path // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md @@ -146,8 +145,18 @@ module.exports = { // TODO: enforce a stricter convention in module import order? 'import/order': [ 'error', { - 'groups': [['builtin', 'external', 'internal']], + 'groups': [ + ['builtin'], + ['external'], + ['internal'], + ['parent'], + ['sibling'] + ], 'newlines-between': 'never', + 'alphabetize': { + 'order': 'asc', + 'caseInsensitive': true, + } }, ], @@ -195,7 +204,7 @@ module.exports = { // Prevent unassigned imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md // importing for side effects is perfectly acceptable, if you need side effects. - 'import/no-unassigned-import': 'off', + 'import/no-unassigned-import': 'error', // Prevent importing the default as if it were named // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md @@ -203,25 +212,24 @@ module.exports = { // Reports if a module's default export is unnamed // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md - 'import/no-anonymous-default-export': ['off', { - allowArray: false, + 'import/no-anonymous-default-export': ['error', { + allowArray: true, allowArrowFunction: false, allowAnonymousClass: false, allowAnonymousFunction: false, - allowLiteral: false, - allowObject: false, + allowLiteral: true, + allowObject: true, }], // This rule enforces that all exports are declared at the bottom of the file. // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md - // TODO: enable? - 'import/exports-last': 'off', + 'import/exports-last': 'error', // Reports when named exports are not grouped together in a single export declaration // or when multiple assignments to CommonJS module.exports or exports object are present // in a single file. // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md - 'import/group-exports': 'off', + 'import/group-exports': 'error', // forbid default exports. this is a terrible rule, do not use it. // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md @@ -256,9 +264,7 @@ module.exports = { // Reports modules without any exports, or with unused exports // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md - // TODO: enable, semver-major - 'import/no-unused-modules': ['off', { - ignoreExports: [], + 'import/no-unused-modules': ['error', { missingExports: true, unusedExports: true, }], From 81e002ad01c13e22f3268dd4a2a0cbdedd0c81fe Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 09:08:08 +0200 Subject: [PATCH 08/35] enable no-undefined --- CHANGELOG.md | 1 + rules/variables.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 854457f0..2384b22b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Likely to cause new errors - `require-atomic-updates` +- `no-undefined` - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/require-types-at-top` diff --git a/rules/variables.js b/rules/variables.js index 96408bd4..331bd571 100644 --- a/rules/variables.js +++ b/rules/variables.js @@ -32,8 +32,7 @@ module.exports = { // disallow use of undefined variable // https://eslint.org/docs/rules/no-undefined - // TODO: enable? - 'no-undefined': 'off', + 'no-undefined': 'error', // disallow declaration of variables that are not used in the code 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], From eb56be7caa2da1854000dfbab95e040d2b2226bf Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 09:11:07 +0200 Subject: [PATCH 09/35] add style rules --- CHANGELOG.md | 7 +++++++ rules/style.js | 21 +++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2384b22b..48b8f563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,13 @@ - `require-atomic-updates` - `no-undefined` +- `array-bracket-newline` +- `func-names`: is now reported as error instead of warning +- `func-style` +- `lines-around-directive`: removed & replaced by `padding-line-between-statements` +- `no-multiple-empty-lines`: `{ max: 1, maxBOF: 0, maxEOF: 0 }` +- `no-restricted-syntax`: allow `for..of` usage +- `sort-keys` - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/require-types-at-top` diff --git a/rules/style.js b/rules/style.js index a8578933..a199bb6a 100644 --- a/rules/style.js +++ b/rules/style.js @@ -2,12 +2,10 @@ module.exports = { rules: { // enforce line breaks after opening and before closing array brackets // https://eslint.org/docs/rules/array-bracket-newline - // TODO: enable? semver-major - 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } + 'array-bracket-newline': ['error', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } // enforce line breaks between array elements // https://eslint.org/docs/rules/array-element-newline - // TODO: enable? semver-major 'array-element-newline': ['off', { multiline: true, minItems: 3 }], // enforce spacing inside array brackets @@ -90,12 +88,11 @@ module.exports = { // require function expressions to have a name // https://eslint.org/docs/rules/func-names - 'func-names': 'warn', + 'func-names': 'error', // enforces use of function declarations or expressions // https://eslint.org/docs/rules/func-style - // TODO: enable - 'func-style': ['off', 'expression'], + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], // enforce consistent line breaks inside function parentheses // https://eslint.org/docs/rules/function-paren-newline @@ -163,7 +160,6 @@ module.exports = { // enforce position of line comments // https://eslint.org/docs/rules/line-comment-position - // TODO: enable? 'line-comment-position': ['off', { position: 'above', ignorePattern: '', @@ -183,7 +179,8 @@ module.exports = { // require or disallow newlines around directives // https://eslint.org/docs/rules/lines-around-directive - 'lines-around-directive': ['error', { + // Deprecated in favor of padding-line-between-statements + 'lines-around-directive': ['off', { before: 'always', after: 'always', }], @@ -303,7 +300,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: 1, maxBOF: 0, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition @@ -327,10 +324,6 @@ module.exports = { selector: 'ForInStatement', message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', }, - { - selector: 'ForOfStatement', - message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', - }, { selector: 'LabeledStatement', message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', @@ -454,7 +447,7 @@ module.exports = { 'semi-style': ['error', 'last'], // requires object keys to be sorted - 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], + 'sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], // sort variables within the same declaration block 'sort-vars': 'off', From 5ba8acb690d96a35763b8c5eeda6da41058218bf Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 19 May 2020 09:11:56 +0200 Subject: [PATCH 10/35] Add react rules --- CHANGELOG.md | 6 +++++- rules/react.js | 17 +++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48b8f563..44130440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,11 @@ - `import/exports-last` - `import/group-exports` - `import/no-unused-modules` - +- `react/function-component-definition` +- `react/jsx-key` +- `react/no-direct-mutation-state` +- `react/state-in-constructor` +- `react/prefer-read-only-props` # v0.3.1 diff --git a/rules/react.js b/rules/react.js index c6f948e5..7b06201f 100644 --- a/rules/react.js +++ b/rules/react.js @@ -53,6 +53,13 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md 'react/forbid-dom-props': ['off', { forbid: [] }], + // Enforce a specific function type for function components. + // https://github.com/yannickcr/eslint-plugin-react/blob/v7.20.0/docs/rules/function-component-definition.md + 'react/function-component-definition': ['error', { + namedComponents: 'function-declaration', + unnamedComponents: 'function-declaration', + }], + // Enforce boolean attributes notation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md 'react/jsx-boolean-value': ['error', 'never', { always: [] }], @@ -82,7 +89,7 @@ module.exports = { // Validate JSX has key prop when in array or iterator // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md - 'react/jsx-key': 'off', + 'react/jsx-key': ['error', { checkFragmentShorthand: true }], // Limit maximum of props on a single line in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md @@ -177,7 +184,7 @@ module.exports = { // Prevent direct mutation of this.state // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md - 'react/no-direct-mutation-state': 'off', + 'react/no-direct-mutation-state': 'error', // Prevent usage of isMounted // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md @@ -476,12 +483,10 @@ module.exports = { // Enforce state initialization style // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md - // TODO: set to "never" once babel-preset-airbnb supports public class fields - 'react/state-in-constructor': ['off', 'never'], + 'react/state-in-constructor': ['error', 'never'], // Enforces where React component static properties should be positioned // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md - // TODO: set to "static public field" once babel-preset-airbnb supports public class fields 'react/static-property-placement': ['error', 'static public field'], // Disallow JSX props spreading @@ -494,7 +499,7 @@ 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', + 'react/prefer-read-only-props': 'error', }, settings: { From de32f9322c474c7269f7915785d01439f5db76df Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 09:11:57 +0200 Subject: [PATCH 11/35] remove eslint-plugin-ramda --- package.json | 2 -- rules/ramda.js | 38 -------------------------------------- 2 files changed, 40 deletions(-) delete mode 100644 rules/ramda.js diff --git a/package.json b/package.json index 45fc9163..5a8cc411 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "eslint-plugin-flowtype": "^5.1.0", "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-ramda": "^2.5.1", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.2" }, @@ -45,7 +44,6 @@ "eslint-plugin-flowtype": "^5.1.0", "eslint-plugin-import": "^2.19.1", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-ramda": "^2.5.1", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.2" }, diff --git a/rules/ramda.js b/rules/ramda.js deleted file mode 100644 index e693a6b7..00000000 --- a/rules/ramda.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = { - env: { - es6: true, - }, - - plugins: [ - 'ramda', - ], - - rules: { - 'ramda/always-simplification': 'error', - 'ramda/any-pass-simplification': 'error', - 'ramda/both-simplification': 'error', - 'ramda/complement-simplification': 'error', - 'ramda/compose-pipe-style': 'off', - 'ramda/compose-simplification': 'error', - 'ramda/cond-simplification': 'error', - 'ramda/either-simplification': 'error', - 'ramda/eq-by-simplification': 'error', - 'ramda/filter-simplification': 'error', - 'ramda/if-else-simplification': 'error', - 'ramda/map-simplification': 'error', - 'ramda/merge-simplification': 'error', - 'ramda/no-redundant-and': 'error', - 'ramda/no-redundant-not': 'error', - 'ramda/no-redundant-or': 'error', - 'ramda/pipe-simplification': 'error', - 'ramda/prefer-both-either': 'off', - 'ramda/prefer-complement': 'error', - 'ramda/prefer-ramda-boolean': 'off', - 'ramda/prop-satisfies-simplification': 'error', - 'ramda/reduce-simplification': 'error', - 'ramda/reject-simplification': 'error', - 'ramda/set-simplification': 'error', - 'ramda/unless-simplification': 'error', - 'ramda/when-simplification': 'error', - }, -}; From cc03c0229d081d2efe6efef6abecfb4b70a79705 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 09:16:22 +0200 Subject: [PATCH 12/35] upgrade dependencies --- CHANGELOG.md | 10 ++++++++-- README.md | 4 ++-- package.json | 34 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44130440..72824b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,14 @@ ## Changes - **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` -- **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.1.0` -- upgrade `eslint-plugin-react` to `^7.20.0` +- **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.2.0` +- **[Breaking]**: remove `eslint-plugin-ramda` to `^5.1.0` +- upgrade `babel-eslint` to `^10.1.0` +- upgrade `eslint-plugin-eslint-comments` to `^3.2.0` +- upgrade `eslint-plugin-import` to `^2.22.0` +- upgrade `eslint-plugin-jsx-a11y` to `^6.3.1` +- upgrade `eslint-plugin-react` to `^7.21.2` +- upgrade `eslint-plugin-react-hooks` to `^4.1.2` - Fix dependency list in README ## Likely to cause new errors diff --git a/README.md b/README.md index 62580dfb..e139c2c8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+, FlowJS and React. -It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-ramda`, `eslint-plugin-react-hooks`, +It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `eslint-plugin-jsx-a11y` and `eslint-plugin-eslint-comments`. If you don't need React, see `eslint-config-nugit/base`. @@ -39,6 +39,6 @@ see `eslint-config-nugit/base`. Our default export contains all of our ESLint rules, including ECMAScript 6+ and FlowJS. -It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-flowtype` and `eslint-plugin-ramda`. +It requires `eslint`, `eslint-plugin-import` and `eslint-plugin-flowtype`. - Add `"extends": "nugit/base"` to your .eslintrc diff --git a/package.json b/package.json index 5a8cc411..0904e349 100644 --- a/package.json +++ b/package.json @@ -28,29 +28,29 @@ }, "homepage": "https://github.com/nugit/eslint-config-nugit", "devDependencies": { - "babel-eslint": "^10.0.3", - "eslint": "^6.8.0", - "eslint-plugin-eslint-comments": "^3.1.2", - "eslint-plugin-flowtype": "^5.1.0", - "eslint-plugin-import": "^2.19.1", - "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.20.0", - "eslint-plugin-react-hooks": "^4.0.2" + "babel-eslint": "^10.1.0", + "eslint": "^7.10.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-flowtype": "^5.2.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jsx-a11y": "^6.3.1", + "eslint-plugin-react": "^7.21.2", + "eslint-plugin-react-hooks": "^4.1.2" }, "peerDependencies": { - "babel-eslint": "^10.0.3", - "eslint": "^6.8.0", - "eslint-plugin-eslint-comments": "^3.1.2", - "eslint-plugin-flowtype": "^5.1.0", - "eslint-plugin-import": "^2.19.1", - "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.20.0", - "eslint-plugin-react-hooks": "^4.0.2" + "babel-eslint": "^10.1.0", + "eslint": "^7.10.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-flowtype": "^5.2.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jsx-a11y": "^6.3.1", + "eslint-plugin-react": "^7.21.2", + "eslint-plugin-react-hooks": "^4.1.2" }, "engines": { "node": ">= 6" }, "dependencies": { - "confusing-browser-globals": "^1.0.7" + "confusing-browser-globals": "^1.0.9" } } From 1ed29e26fb96473f087e5de340bdf28b6474280b Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 09:17:34 +0200 Subject: [PATCH 13/35] Set minimum NodeJs version --- CHANGELOG.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72824b0f..5d1970d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` - **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.2.0` - **[Breaking]**: remove `eslint-plugin-ramda` to `^5.1.0` +- **[Breaking]**: minimum supported NodeJs version 12.18 - upgrade `babel-eslint` to `^10.1.0` - upgrade `eslint-plugin-eslint-comments` to `^3.2.0` - upgrade `eslint-plugin-import` to `^2.22.0` diff --git a/package.json b/package.json index 0904e349..e11c9c0d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "eslint-plugin-react-hooks": "^4.1.2" }, "engines": { - "node": ">= 6" + "node": ">= 12" }, "dependencies": { "confusing-browser-globals": "^1.0.9" From 108abf08f10c54f4b482391557d12deecc975218 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 09:52:34 +0200 Subject: [PATCH 14/35] disable sort-keys --- rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/style.js b/rules/style.js index a199bb6a..5d0bb7ee 100644 --- a/rules/style.js +++ b/rules/style.js @@ -447,7 +447,7 @@ module.exports = { 'semi-style': ['error', 'last'], // requires object keys to be sorted - 'sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], + 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], // sort variables within the same declaration block 'sort-vars': 'off', From cd4f9af96758a80bb40906b72bc7a40020df5632 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 09:52:50 +0200 Subject: [PATCH 15/35] fix lint --- .eslintrc | 2 +- base.js | 5 ++--- rules/flow.js | 3 +-- rules/imports.js | 8 ++++---- script.js | 7 ++++--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index 76867059..e1c24ff2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,3 +1,3 @@ { - "extends": "./base.js" + "extends": "./script.js" } diff --git a/base.js b/base.js index 96caa586..67915d21 100644 --- a/base.js +++ b/base.js @@ -8,7 +8,6 @@ module.exports = { './rules/es6', './rules/imports', './rules/strict', - './rules/ramda.js', './rules/flow.js', './rules/eslint-comments', ].map(require.resolve), @@ -36,8 +35,8 @@ module.exports = { rules: { // Reports modules without any exports, or with unused exports // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md - 'import/no-unused-modules': 'off' - } + 'import/no-unused-modules': 'off', + }, }, ], }; diff --git a/rules/flow.js b/rules/flow.js index 0ddd1a99..fabc5ce3 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -16,7 +16,6 @@ module.exports = { 'flowtype/generic-spacing': ['error', 'never'], 'flowtype/newline-after-flow-annotation': ['error', 'always'], 'flowtype/no-mixed': 'off', - 'flowtype/no-dupe-keys': 'error', // TODO: enable? 'flowtype/no-existential-type': 'off', 'flowtype/no-flow-fix-me-comments': 'off', @@ -40,7 +39,7 @@ module.exports = { 'flowtype/require-valid-file-annotation': 'off', 'flowtype/require-variable-type': 'off', 'flowtype/semi': ['error', 'always'], - 'flowtype/sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }], + 'flowtype/sort-keys': ['error', 'asc'], 'flowtype/space-after-type-colon': ['error', 'always'], 'flowtype/space-before-generic-bracket': ['error', 'never'], 'flowtype/space-before-type-colon': ['error', 'never'], diff --git a/rules/imports.js b/rules/imports.js index 5b730d57..0c220cbf 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -150,13 +150,13 @@ module.exports = { ['external'], ['internal'], ['parent'], - ['sibling'] + ['sibling'], ], 'newlines-between': 'never', 'alphabetize': { - 'order': 'asc', - 'caseInsensitive': true, - } + order: 'asc', + caseInsensitive: true, + }, }, ], diff --git a/script.js b/script.js index cc77de66..3f3645a1 100644 --- a/script.js +++ b/script.js @@ -1,11 +1,11 @@ module.exports = { - extends: [ - './base', - ].map(require.resolve), env: { 'node': true, 'shared-node-browser': false, }, + extends: [ + './base', + ].map(require.resolve), rules: { 'import/no-extraneous-dependencies': [ 'error', @@ -14,6 +14,7 @@ module.exports = { optionalDependencies: false, }, ], + 'import/no-unused-modules': 'off', 'no-console': 'off', }, }; From 12689b611cef2ad7380d210b574bcc6d77291b6a Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:04:38 +0200 Subject: [PATCH 16/35] Enable 'flowtype/no-existential-type' --- CHANGELOG.md | 2 +- rules/flow.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d1970d7..31c29ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,11 +24,11 @@ - `lines-around-directive`: removed & replaced by `padding-line-between-statements` - `no-multiple-empty-lines`: `{ max: 1, maxBOF: 0, maxEOF: 0 }` - `no-restricted-syntax`: allow `for..of` usage -- `sort-keys` - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/require-types-at-top` - `flowtype/type-import-style`: `identifier` +- `flowtype/no-existential-type` - `import/no-namespace` - `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` - `import/no-unassigned-import` diff --git a/rules/flow.js b/rules/flow.js index fabc5ce3..99984012 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -15,9 +15,8 @@ module.exports = { 'flowtype/delimiter-dangle': ['error', 'always-multiline', 'always-multiline', 'always-multiline'], 'flowtype/generic-spacing': ['error', 'never'], 'flowtype/newline-after-flow-annotation': ['error', 'always'], - 'flowtype/no-mixed': 'off', // TODO: enable? - 'flowtype/no-existential-type': 'off', + 'flowtype/no-existential-type': 'error', 'flowtype/no-flow-fix-me-comments': 'off', 'flowtype/no-mixed': 'off', // TODO: enable? From 3f4c2c175fe2be815047109b331c4bdfc964b5e4 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:05:09 +0200 Subject: [PATCH 17/35] Enable flowtype/no-mutable-array --- CHANGELOG.md | 1 + rules/flow.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c29ea5..a26a03df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - `flowtype/require-types-at-top` - `flowtype/type-import-style`: `identifier` - `flowtype/no-existential-type` +- `flowtype/no-mutable-array` - `import/no-namespace` - `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` - `import/no-unassigned-import` diff --git a/rules/flow.js b/rules/flow.js index 99984012..d684f4eb 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -19,8 +19,7 @@ module.exports = { 'flowtype/no-existential-type': 'error', 'flowtype/no-flow-fix-me-comments': 'off', 'flowtype/no-mixed': 'off', - // TODO: enable? - 'flowtype/no-mutable-array': 'off', + 'flowtype/no-mutable-array': 'error', 'flowtype/no-primitive-constructor-types': 'error', 'flowtype/no-types-missing-file-annotation': 'error', 'flowtype/no-unused-expressions': 'error', From d353749b1a0048a3e3ca6c8ffdd90fad47d78c6f Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:05:53 +0200 Subject: [PATCH 18/35] enable flowtype/spread-exact-type --- CHANGELOG.md | 1 + rules/flow.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a26a03df..c0b24950 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - `flowtype/type-import-style`: `identifier` - `flowtype/no-existential-type` - `flowtype/no-mutable-array` +- `flowtype/spread-exact-type` - `import/no-namespace` - `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` - `import/no-unassigned-import` diff --git a/rules/flow.js b/rules/flow.js index d684f4eb..72bbd4ef 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -41,8 +41,7 @@ module.exports = { 'flowtype/space-after-type-colon': ['error', 'always'], 'flowtype/space-before-generic-bracket': ['error', 'never'], 'flowtype/space-before-type-colon': ['error', 'never'], - // TODO: enable? - 'flowtype/spread-exact-type': 'off', + 'flowtype/spread-exact-type': 'error', 'flowtype/type-id-match': 'off', // Use identifier as declaration imports are not well supported by vscode 'flowtype/type-import-style': ['error', 'identifier'], From 3c7c5753f222eb8dfd9f0baa1f79115816c5b3c5 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:26:56 +0200 Subject: [PATCH 19/35] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0a5f716e..f30c215e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ yarn.lock +.npmrc From a46b862426b5b08a4d5253a98af9de46e4ac7ce1 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:27:38 +0200 Subject: [PATCH 20/35] v1.0.0-alpha.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e11c9c0d..e94c766a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "0.3.1", + "version": "1.0.0-alpha.1", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2206a9b1885d46470f59bf39e98e9b5f9d5aab1d Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 10:46:01 +0200 Subject: [PATCH 21/35] fix react/function-component-definition rule --- package.json | 2 +- rules/react.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e94c766a..2cf324a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.1", + "version": "1.0.0-alpha.2", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { diff --git a/rules/react.js b/rules/react.js index 7b06201f..92acab2e 100644 --- a/rules/react.js +++ b/rules/react.js @@ -57,7 +57,7 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/v7.20.0/docs/rules/function-component-definition.md 'react/function-component-definition': ['error', { namedComponents: 'function-declaration', - unnamedComponents: 'function-declaration', + unnamedComponents: 'function-expression', }], // Enforce boolean attributes notation in JSX From 405fcae9d624dafd5764af14ca7aaff150eb047f Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 29 Sep 2020 11:33:36 +0200 Subject: [PATCH 22/35] v1.0.0-alpha.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2cf324a0..d24fd27e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.2", + "version": "1.0.0-alpha.3", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From a2238336e3346386d5859c12ac578179a2db3818 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 30 Sep 2020 17:12:16 +0200 Subject: [PATCH 23/35] disable rules without autofix --- CHANGELOG.md | 5 ----- rules/flow.js | 7 +++---- rules/imports.js | 4 ++-- rules/variables.js | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b24950..b5106a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ ## Likely to cause new errors - `require-atomic-updates` -- `no-undefined` - `array-bracket-newline` - `func-names`: is now reported as error instead of warning - `func-style` @@ -27,17 +26,13 @@ - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/require-types-at-top` -- `flowtype/type-import-style`: `identifier` - `flowtype/no-existential-type` -- `flowtype/no-mutable-array` -- `flowtype/spread-exact-type` - `import/no-namespace` - `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` - `import/no-unassigned-import` - `import/no-anonymous-default-export`: for functions & classes - `import/exports-last` - `import/group-exports` -- `import/no-unused-modules` - `react/function-component-definition` - `react/jsx-key` - `react/no-direct-mutation-state` diff --git a/rules/flow.js b/rules/flow.js index 72bbd4ef..506f5646 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -15,11 +15,10 @@ module.exports = { 'flowtype/delimiter-dangle': ['error', 'always-multiline', 'always-multiline', 'always-multiline'], 'flowtype/generic-spacing': ['error', 'never'], 'flowtype/newline-after-flow-annotation': ['error', 'always'], - // TODO: enable? 'flowtype/no-existential-type': 'error', 'flowtype/no-flow-fix-me-comments': 'off', 'flowtype/no-mixed': 'off', - 'flowtype/no-mutable-array': 'error', + 'flowtype/no-mutable-array': 'off', 'flowtype/no-primitive-constructor-types': 'error', 'flowtype/no-types-missing-file-annotation': 'error', 'flowtype/no-unused-expressions': 'error', @@ -41,10 +40,10 @@ module.exports = { 'flowtype/space-after-type-colon': ['error', 'always'], 'flowtype/space-before-generic-bracket': ['error', 'never'], 'flowtype/space-before-type-colon': ['error', 'never'], - 'flowtype/spread-exact-type': 'error', + 'flowtype/spread-exact-type': 'off', 'flowtype/type-id-match': 'off', // Use identifier as declaration imports are not well supported by vscode - 'flowtype/type-import-style': ['error', 'identifier'], + 'flowtype/type-import-style': ['off', 'declaration'], 'flowtype/union-intersection-spacing': ['error', 'always'], 'flowtype/use-flow-type': 'warn', }, diff --git a/rules/imports.js b/rules/imports.js index 0c220cbf..d3e8680d 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -245,7 +245,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', { ignoreExternal: true, maxDepth: Infinity }], // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md @@ -264,7 +264,7 @@ module.exports = { // Reports modules without any exports, or with unused exports // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md - 'import/no-unused-modules': ['error', { + 'import/no-unused-modules': ['off', { missingExports: true, unusedExports: true, }], diff --git a/rules/variables.js b/rules/variables.js index 331bd571..759eb8a9 100644 --- a/rules/variables.js +++ b/rules/variables.js @@ -32,7 +32,7 @@ module.exports = { // disallow use of undefined variable // https://eslint.org/docs/rules/no-undefined - 'no-undefined': 'error', + 'no-undefined': 'off', // disallow declaration of variables that are not used in the code 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], From 2424c1c846335f90fd4075b7dfbfcd8722932e1f Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 30 Sep 2020 17:14:12 +0200 Subject: [PATCH 24/35] disable flowtype/require-types-at-top --- CHANGELOG.md | 1 - rules/flow.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5106a10..8d383d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,6 @@ - `no-restricted-syntax`: allow `for..of` usage - `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` -- `flowtype/require-types-at-top` - `flowtype/no-existential-type` - `import/no-namespace` - `import/order`: add `alphabetize: { order: 'asc' 'caseInsensitive': true }` & change `groups` to the following - `order: `builtin`, `external`, `internal`, `parent`, `sibling` diff --git a/rules/flow.js b/rules/flow.js index 506f5646..161fbd6a 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -32,7 +32,7 @@ module.exports = { 'flowtype/require-parameter-type': 'off', 'flowtype/require-readonly-react-props': 'error', 'flowtype/require-return-type': 'off', - 'flowtype/require-types-at-top': 'error', + 'flowtype/require-types-at-top': 'off', 'flowtype/require-valid-file-annotation': 'off', 'flowtype/require-variable-type': 'off', 'flowtype/semi': ['error', 'always'], From fb718afba3916599dfe02f0929f90fa0087d0efd Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 30 Sep 2020 17:15:12 +0200 Subject: [PATCH 25/35] v1.0.0-alpha.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d24fd27e..246368db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.3", + "version": "1.0.0-alpha.4", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2427366d65e6d057ed0cd5722f28b76c30740614 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Thu, 1 Oct 2020 09:54:57 +0200 Subject: [PATCH 26/35] remove flowtype/require-compound-type-alias --- CHANGELOG.md | 1 - rules/flow.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d383d6b..ffe54fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ - `lines-around-directive`: removed & replaced by `padding-line-between-statements` - `no-multiple-empty-lines`: `{ max: 1, maxBOF: 0, maxEOF: 0 }` - `no-restricted-syntax`: allow `for..of` usage -- `flowtype/require-compound-type-alias`: `always` - `flowtype/require-readonly-react-props` - `flowtype/no-existential-type` - `import/no-namespace` diff --git a/rules/flow.js b/rules/flow.js index 161fbd6a..8698f47c 100644 --- a/rules/flow.js +++ b/rules/flow.js @@ -25,7 +25,7 @@ module.exports = { // TODO: disable any? 'flowtype/no-weak-types': ['error', { any: false }], 'flowtype/object-type-delimiter': ['error', 'comma'], - 'flowtype/require-compound-type-alias': ['error', 'always'], + 'flowtype/require-compound-type-alias': ['off', 'always'], 'flowtype/require-exact-type': 'off', 'flowtype/require-indexer-name': 'off', 'flowtype/require-inexact-type': 'off', From 833c3926e54d13455a1a0c4446df50cbbcc7fbef Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Thu, 1 Oct 2020 09:55:44 +0200 Subject: [PATCH 27/35] v1.0.0-alpha.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 246368db..d9949931 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.4", + "version": "1.0.0-alpha.5", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From cd6f942bce07174b4a19e2895c5f993ac7c15701 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 6 Oct 2020 09:28:19 +0200 Subject: [PATCH 28/35] feat: consider import starting with $ to be internal --- rules/imports.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rules/imports.js b/rules/imports.js index d3e8680d..d7da6c5e 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -157,6 +157,12 @@ module.exports = { order: 'asc', caseInsensitive: true, }, + 'pathGroups': [ + { + pattern: '$*/**', + group: 'internal', + }, + ], }, ], From cc49768d6d45c7509f69f5ac7e5368569f9b2388 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 6 Oct 2020 09:28:39 +0200 Subject: [PATCH 29/35] v1.0.0-alpha.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9949931..8fc5410b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.5", + "version": "1.0.0-alpha.6", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From eeb204026d6a689b79c40ed2032415f4deab8e48 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 6 Oct 2020 09:29:41 +0200 Subject: [PATCH 30/35] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe54fa8..7a663855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - upgrade `eslint-plugin-react` to `^7.21.2` - upgrade `eslint-plugin-react-hooks` to `^4.1.2` - Fix dependency list in README +- Consider import starting with $ to be internal ## Likely to cause new errors From ef3bf96cf1966b7d605862b70794513660f3be24 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 6 Oct 2020 09:50:40 +0200 Subject: [PATCH 31/35] feat: react/jsx-indent check logicExpressions & attributes --- rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/react.js b/rules/react.js index 92acab2e..7fa84e6f 100644 --- a/rules/react.js +++ b/rules/react.js @@ -307,7 +307,7 @@ module.exports = { // Enforce JSX indentation // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md - 'react/jsx-indent': ['error', 2], + 'react/jsx-indent': ['error', 2, { indentLogicalExpressions: true, checkAttributes: true }], // Disallow target="_blank" on links // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md From 1e102c12458589370e42d3035d37f8daab1adfb4 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Tue, 6 Oct 2020 09:51:13 +0200 Subject: [PATCH 32/35] v1.0.0-alpha.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8fc5410b..27109297 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.6", + "version": "1.0.0-alpha.7", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 70bdcdd0093300e715e325c5d8f9a1a88c95fe6c Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 7 Oct 2020 09:40:26 +0200 Subject: [PATCH 33/35] chore: update Changelog --- CHANGELOG.md | 6 +++--- rules/imports.js | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a663855..4035b733 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,16 @@ ## Changes -- **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.0.2` +- **[Breaking]**: upgrade `eslint` to `^7.10.0` +- **[Breaking]**: upgrade `eslint-plugin-react-hooks` to `^4.1.2` - **[Breaking]**: upgrade `eslint-plugin-flowtype` to `^5.2.0` - **[Breaking]**: remove `eslint-plugin-ramda` to `^5.1.0` - **[Breaking]**: minimum supported NodeJs version 12.18 - upgrade `babel-eslint` to `^10.1.0` - upgrade `eslint-plugin-eslint-comments` to `^3.2.0` -- upgrade `eslint-plugin-import` to `^2.22.0` +- upgrade `eslint-plugin-import` to `^2.22.1` - upgrade `eslint-plugin-jsx-a11y` to `^6.3.1` - upgrade `eslint-plugin-react` to `^7.21.2` -- upgrade `eslint-plugin-react-hooks` to `^4.1.2` - Fix dependency list in README - Consider import starting with $ to be internal diff --git a/rules/imports.js b/rules/imports.js index d7da6c5e..57d81cdb 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -142,7 +142,6 @@ module.exports = { // ensure absolute imports are above relative imports and that unassigned imports are ignored // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md - // TODO: enforce a stricter convention in module import order? 'import/order': [ 'error', { 'groups': [ From 00b2789fc41e62de957f117f5f152284177cca8b Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 7 Oct 2020 11:06:19 +0200 Subject: [PATCH 34/35] fix: internal path pattern --- rules/imports.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rules/imports.js b/rules/imports.js index 57d81cdb..9173233c 100644 --- a/rules/imports.js +++ b/rules/imports.js @@ -161,6 +161,10 @@ module.exports = { pattern: '$*/**', group: 'internal', }, + { + pattern: '$*', + group: 'internal', + }, ], }, ], From 8f4b52c24660e061c27030e06b22d484169dc5cc Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 7 Oct 2020 11:06:36 +0200 Subject: [PATCH 35/35] v1.0.0-alpha.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27109297..c1312189 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-nugit", - "version": "1.0.0-alpha.7", + "version": "1.0.0-alpha.8", "description": "Nugit's JS ESLint config, following our styleguide", "main": "index.js", "scripts": {