Skip to content

Commit

Permalink
Update ESLint and plugins
Browse files Browse the repository at this point in the history
ESLint and most of the used plugins already released new major versions.
Trying to use later versions of these plugins as well as ESLint itself
caused error when using npm v7 because peer dependencies are installed
automatically [1] now, which is a fantastic change, but also broke and
blocked the usage of the configuration packages due to outdated
`peerDependencies` like `eslint@^6`.

>> Core

The latest version 7 comes with great features and improvements.
See the official v7 migration guide [2] for all details.

- Update ESLint package version - updated from `v6.2.0` to
  `v7.23.0` [3].
- Allow to define additional file extensions in configuration
  packages - files matched by `overrides[].files` are now linted by
  default [4] which allows to add extensions like `*.ts` and `*.tsx` to
  `@arcticicestudio/eslint-config-typescript` without the need to
  specify this override over and over again in each project.
- Remove deprecated rules** - some rules have been deprecated [5] and
  have been removed in favor of the support for `eslint-plugin-node`
  like documented in GH-30.
  - `callback-return` [6] → `node/callback-return` [7]
  - `global-require` [8] → `node/global-require` [9]
  - `handle-callback-err` [10] → `node/handle-callback-err` [11]
  - `no-mixed-requires` [12] → `node/no-mixed-requires` [13]
  - `no-new-require` [14] → `node/no-new-require` [15]
  - `no-path-concat` [16] → `node/no-path-concat` [17]
  - `no-process-env` [18] → `node/no-process-env` [19]
  - `no-process-exit` [20] → `node/no-process-exit` [21]
  - `no-restricted-modules` [22] → `node/no-restricted-modules` [23]
  - `no-sync` [24] → `node/no-sync` [25]
- Adapt new recommended rules - some rules have been added and enabled
  on the `eslint:recommended` rule set [26] and have been added to
  `@arcticicestudio/eslint-config-base` with `error` level:
  - `no-dupe-else-if` [27]
  - `no-import-assign` [28]
  - `no-setter-return` [29]

>> Plugins & Dependencies

>>> `@arcticicestudio/eslint-config`

- eslint-config-prettier [30] - Bumped version from `v6.0.0` to
  `v8.1.0` [31]. As of version `8.0.0` all rule sets have been merged
  into the main `prettier` set [32]. Therefore the additional
  `prettier/react` set has been removed from the `extends` array of the
  Prettier specific rules.
- eslint-find-rules [33] - Bumped version from `v3.4.0` to
  `v3.6.1` [34].
- eslint-plugin-import [35] - Bumped minimum version from `v2.18.2`
  to `v2.22.1` [36].
- eslint-plugin-jsx-a11y [37] - Bumped minimum version from `v6.2.3`
  to `v6.4.1` [38].
- eslint-plugin-prettier [39] - Bumped minimum version from `v3.1.0` to
  `v3.3.1` [40].
- eslint-plugin-react [41] - Bumped minimum version from `v7.14.3` to
  `v7.23.1` [42]. This includes new rules and improvements to existing
  ones:
  - Added new `react/jsx-no-useless-fragment` [43] rule with `error`
    level (introduced in `v7.15.0` [44]) that disallows unnecessary
    fragments.
  - Added the new `static-variables` option to the
    `react/sort-comp` [45] rule (introduced in `v7.15.0` [44]).
  - Added new `react/jsx-newline` [46] rule (introduced in
    `v7.22.0` [47]) and disabled by default.
  - Added new `react/jsx-no-constructed-context-values` [48] rule
    (introduced in `v7.22.0` [47]) and enabled by default to prevent
    React contexts from taking non-stable values.
      "React Context, and all its child nodes and Consumers are
       rerendered whenever the value prop changes. Because each
       Javascript object carries its own identity, things like object
       expressions (`{foo: "bar"}`) or function expressions get a new
       identity on every run through the component. This makes the
       context think it has gotten a new object and can cause needless
       rerenders and unintended consequences.
       This can be a pretty large performance hit because not only will
       it cause the context providers and consumers to rerender with all
       the elements in its subtree, the processing for the tree scan
       React does to render the provider and find consumers is also
       wasted."
  - Added `enforceDynamicLinks` option with value `always` for
    `react/jsx-no-target-blank` [49] rule (introduced in `v7.9.0` [50])
  - Added `react/no-unstable-nested-components` [51] rule and enabled by
    default to prevent creating unstable components inside components.
      "Creating components inside components without memoization leads
       to unstable components. The nested component and all its children
       are recreated during each re-render. Given stateful children of
       the nested component will lose their state on each re-render.
       React reconcilation performs element type comparison with
       reference equality [52]. The reference to the same element
       changes on each re-render when defining components inside the
       render block. This leads to complete recreation of the current
       node and all its children. As a result the virtual DOM has to do
       extra unnecessary work and possible bugs are introduced.
  - Added `forbidDefaultForRequired` option with value `true` for
    `react/require-default-props` [53] rule (introduced in
    `v7.5.0` [54])
- eslint-plugin-react-hooks [55] - Bump minimum version from `v2.0.0` to
  `v4.2.0` [56].

>>> `@arcticicestudio/eslint-config-base`

- confusing-browser-globals [57] - Bumped minimum version from `v1.0.8`
  to `v1.0.10`.
- eslint-find-rules [33] - Bumped version from `v3.4.0` to
  `v3.6.1` [34].
- eslint-plugin-import [35] - Bumped minimum version from `v2.18.2` to
  `v2.22.1` [36].

>>> `@arcticicestudio/eslint-config-typescript`

- @typescript-eslint/eslint-plugin [58] - Bumped minimum version from
  `v2.0.0` to `v4.20.0` [59].
- @typescript-eslint/parser [60] - Bumped minimum version from `v2.0.0`
  to `v4.20.0` [59].
- typescript [61] - Bumped minimum version from `v3.5.3` to
  `v4.2.3` [62].

[1]: https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/#user-content-breaking-changes
[2]: https://eslint.org/docs/user-guide/migrating-to-7.0.0
[3]: eslint/eslint@v6.2.0....v7.23.0
[4]: https://eslint.org/docs/user-guide/migrating-to-7.0.0#lint-files-matched-by-overridesfiles-by-default
[5]: https://eslint.org/docs/user-guide/migrating-to-7.0.0#nodejscommonjs-rules-have-been-deprecated
[6]: https://eslint.org/docs/rules/callback-return
[7]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md
[8]: https://eslint.org/docs/rules/global-require
[9]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/global-require.md
[10]: https://eslint.org/docs/rules/handle-callback-err
[11]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/handle-callback-err.md
[12]: https://eslint.org/docs/rules/no-mixed-requires
[13]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-mixed-requires.md
[14]: https://eslint.org/docs/rules/no-new-require
[15]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-new-require.md
[16]: https://eslint.org/docs/rules/no-path-concat
[17]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-path-concat.md
[18]: https://eslint.org/docs/rules/no-process-env
[19]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-env.md
[20]: https://eslint.org/docs/rules/no-process-exit
[21]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-exit.md
[22]: https://eslint.org/docs/rules/no-restricted-modules
[23]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-restricted-modules.md
[24]: https://eslint.org/docs/rules/no-sync
[25]: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-sync.md
[26]: https://eslint.org/docs/user-guide/migrating-to-7.0.0#eslintrecommended-has-been-updated
[27]: https://eslint.org/docs/rules/no-dupe-else-if
[28]: https://eslint.org/docs/rules/no-import-assign
[29]: https://eslint.org/docs/rules/no-setter-return
[30]: https://github.com/prettier/eslint-config-prettier
[31]: prettier/eslint-config-prettier@v6.0.0...v8.1.0
[32]: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21
[33]: https://github.com/sarbbottam/eslint-find-rules
[34]: sarbbottam/eslint-find-rules@v3.4.0...v3.6.1
[35]: https://github.com/benmosher/eslint-plugin-import
[35]: https://github.com/benmosher/eslint-plugin-import
[36]: import-js/eslint-plugin-import@v2.18.2...v2.22.1
[37]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y
[38]: jsx-eslint/eslint-plugin-jsx-a11y@v6.2.3...v6.4.1
[39]: https://github.com/prettier/eslint-plugin-prettier
[40]: prettier/eslint-plugin-prettier@v3.1.0...v3.3.1
[41]: https://github.com/yannickcr/eslint-plugin-react
[42]: jsx-eslint/eslint-plugin-react@v7.14....v7.23.1
[43]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
[44]: https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#7150---2019-09-30
[45]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
[46]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
[47]: https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#7220---20201229
[48]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
[49]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
[50]: https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#790---2018-06-03
[51]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
[52]: https://github.com/facebook/react/blob/v16.13.1/packages/react-reconciler/src/ReactChildFiber.js#L407
[53]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
[54]: https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#750---2017-11-18
[55]: https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
[56]: https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/CHANGELOG.md#420
[57]: https://github.com/facebook/create-react-app/tree/master/packages/confusing-browser-globals
[58]: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
[59]: typescript-eslint/typescript-eslint@v2.0.0...v4.20.0
[60]: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
[61]: https://github.com/microsoft/TypeScript
[62]: microsoft/TypeScript@v3.5.3...v4.2.3

Co-authored-by: Sven Greb <[email protected]>

GH-31
  • Loading branch information
arcticicestudio committed Mar 31, 2021
1 parent e015dc0 commit 5f7a0d3
Show file tree
Hide file tree
Showing 10 changed files with 1,858 additions and 1,177 deletions.
12 changes: 6 additions & 6 deletions packages/@arcticicestudio/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
"test:unused-rules": "eslint-find-rules --unused --deprecated --no-error"
},
"dependencies": {
"confusing-browser-globals": "^1.0.8"
"confusing-browser-globals": "^1.0.10"
},
"devDependencies": {
"eslint": "^6.2.0",
"eslint-find-rules": "3.4.0",
"eslint-plugin-import": "^2.18.2"
"eslint": "^7.23.0",
"eslint-find-rules": "^3.6.1",
"eslint-plugin-import": "^2.22.1"
},
"peerDependencies": {
"eslint": "^6.2.0",
"eslint-plugin-import": "^2.18.2"
"eslint": "^7.23.0",
"eslint-plugin-import": "^2.22.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,10 @@ module.exports = {
node: true
},
rules: {
/**
* Require `return` statements after callbacks.
* @see https://eslint.org/docs/rules/callback-return
*/
"callback-return": "off",
/**
* Enforce `require()` on the top-level module scope.
* @see https://eslint.org/docs/rules/global-require
*/
"global-require": "error",
/**
* Enforce callback error handling.
* @see https://eslint.org/docs/rules/handle-callback-err
*/
"handle-callback-err": "off",
/**
* Disallow use of the `Buffer()` constructor.
* @see https://eslint.org/docs/rules/no-buffer-constructor
*/
"no-buffer-constructor": "error",
/**
* Disallow `require` calls to be mixed with regular variable declarations.
* @see https://eslint.org/docs/rules/no-mixed-requires
*/
"no-mixed-requires": ["off", false],
/**
* Disallow `new` operators with calls to `require`.
* @see https://eslint.org/docs/rules/no-new-require
*/
"no-new-require": "error",
/**
* Disallow string concatenation with `__dirname` and `__filename`.
* @see https://eslint.org/docs/rules/no-path-concat
*/
"no-path-concat": "error",
/**
* Disallow the use of `process.env`.
* @see https://eslint.org/docs/rules/no-process-env
*/
"no-process-env": "off",
/**
* Disallow the use of `process.exit()`.
* @see https://eslint.org/docs/rules/no-process-exit
*/
"no-process-exit": "off",
/**
* Disallow specified modules when loaded by `require`.
* @see https://eslint.org/docs/rules/no-restricted-modules
*/
"no-restricted-modules": "off",
/**
* Disallow synchronous methods.
* @see https://eslint.org/docs/rules/no-sync
*/
"no-sync": "off"
"no-buffer-constructor": "error"
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ module.exports = {
* @see https://eslint.org/docs/rules/no-dupe-args
*/
"no-dupe-args": "error",
/**
* Disallow chained `if-else-if` statements.
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-dupe-else-if
*/
"no-dupe-else-if": "error",
/**
* Disallow duplicate keys in object literals.
* @see https://eslint.org/docs/rules/no-dupe-keys
Expand Down Expand Up @@ -131,6 +137,12 @@ module.exports = {
* @see https://eslint.org/docs/rules/no-func-assign
*/
"no-func-assign": "error",
/**
* Disallow assigning to imported bindings.
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-import-assign
*/
"no-import-assign": "error",
/**
* Disallow variable or "function" declarations in nested blocks.
* @see https://eslint.org/docs/rules/no-inner-declarations
Expand Down Expand Up @@ -172,6 +184,12 @@ module.exports = {
* @see https://eslint.org/docs/rules/no-sparse-arrays
*/
"no-sparse-arrays": "error",
/**
* Disallow returning values from setters.
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-setter-return
*/
"no-setter-return": "error",
/**
* Disallow template literal placeholder syntax in regular strings.
* @see https://eslint.org/docs/rules/no-template-curly-in-string
Expand Down
8 changes: 7 additions & 1 deletion packages/@arcticicestudio/eslint-config-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ module.exports = {
/* Updated import plugin rules, settings and resolvers to include `.ts` and `.tsx` file extensions. */
"./rules/import/settings.js",
"./rules/import/style.js"
].map(require.resolve)
].map(require.resolve),
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: ["@arcticicestudio/eslint-config-typescript", "@arcticicestudio/eslint-config-typescript/prettier"]
}
]
};
26 changes: 13 additions & 13 deletions packages/@arcticicestudio/eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
"test:unused-rules": "eslint-find-rules --unused --deprecated --no-error"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^6.2.0",
"eslint-config-prettier": "^6.0.0",
"eslint-find-rules": "3.4.0",
"eslint-plugin-prettier": "^3.1.0",
"typescript": "^3.5.3"
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-find-rules": "3.6.1",
"eslint-plugin-prettier": "^3.3.1",
"typescript": "^4.2.3"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^6.2.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"typescript": "^3.5.3"
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"typescript": "^4.2.3"
}
}
30 changes: 15 additions & 15 deletions packages/@arcticicestudio/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
"@arcticicestudio/eslint-config-base": ">=0.7.0 <1.0.0"
},
"devDependencies": {
"eslint": "^6.2.0",
"eslint-config-prettier": "^6.0.0",
"eslint-find-rules": "3.4.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^2.0.0"
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-find-rules": "^3.6.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0"
},
"peerDependencies": {
"eslint": "^6.2.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^2.0.0"
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @see https://prettier.io
*/
module.exports = {
extends: ["prettier", "prettier/react"],
extends: ["prettier"],
plugins: ["prettier"],
rules: {
/**
Expand Down
10 changes: 9 additions & 1 deletion packages/@arcticicestudio/eslint-config/rules/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ module.exports = {
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
*/
"react/no-unknown-property": "error",
/**
* Prevent creating unstable components inside components.
* @since 0.9.0
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
*/
"react/no-unstable-nested-components": "error",
/**
* Prevent definitions of unused prop types.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
Expand Down Expand Up @@ -265,7 +271,7 @@ module.exports = {
* Enforce a `defaultProps` definition for every prop that is not a required prop.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
*/
"react/require-default-props": "error",
"react/require-default-props": ["error", { forbidDefaultForRequired: true }],
/**
* Enforce components to have a `shouldComponentUpdate` method.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
Expand All @@ -291,9 +297,11 @@ module.exports = {
"warn",
{
order: [
"static-variables",
"static-methods",
"instance-variables",
"lifecycle",
"/^handle.+$/",
"/^on.+$/",
"getters",
"setters",
Expand Down
24 changes: 22 additions & 2 deletions packages/@arcticicestudio/eslint-config/rules/react/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ module.exports = {
when: "multiline"
}
],
/**
* Do not require a new line after jsx elements and expressions.
* @since 0.9.0
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
*/
"react/jsx-newline": "off",
/**
* Prevent usage of .`bind()` and arrow functions in JSX props.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
Expand All @@ -130,6 +136,13 @@ module.exports = {
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
*/
"react/jsx-no-comment-textnodes": "error",
/**
* Prevent react contexts from taking non-stable values.
* @since 0.9.0
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
*/
"react/jsx-no-constructed-context-values": "error",

/**
* Prevent duplicate props in JSX.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
Expand All @@ -144,12 +157,18 @@ module.exports = {
* Prevent usage of unsafe `_blank` target.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
*/
"react/jsx-no-target-blank": "error",
"react/jsx-no-target-blank": ["error", { enforceDynamicLinks: "always" }],
/**
* Disallow undeclared variables in JSX.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
*/
"react/jsx-no-undef": "error",
/**
* Disallow unnecessary fragments in JSX.
* @since 0.9.0
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
*/
"react/jsx-no-useless-fragment": "error",
/**
* Limit to one expression per line in JSX.
* @see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
Expand Down Expand Up @@ -266,7 +285,8 @@ module.exports = {
"warn",
{
html: "enforce",
custom: "ignore"
custom: "ignore",
explicitSpread: "ignore"
}
]
}
Expand Down
Loading

0 comments on commit 5f7a0d3

Please sign in to comment.