Skip to content

Commit

Permalink
Eslint config: upgrade eslint-plugin-react to version 7.26.0
Browse files Browse the repository at this point in the history
This change updates `eslint-plugin-react` to the latest version 7.26.0
and workarounds `fbt` oddities discovered in the previous version (jsx-eslint/eslint-plugin-react#3080).
I added 2 fixtures to make sure `no-unused-vars` rule works as expected
with FBT.

Additionally, it removes unused suppression comments that were also fixed
in previous React plugin version (jsx-eslint/eslint-plugin-react#3063).

Changelog: https://github.com/yannickcr/eslint-plugin-react/blob/eeb0144f14aa972f533e2ef0b094f6742d63c492/CHANGELOG.md#7260---20210920

adeira-source-id: 97d82ba734142c6ba2e1c37e3ab006477659b77c
  • Loading branch information
mrtnzlml authored and adeira-github-bot committed Sep 23, 2021
1 parent 21b1d08 commit 3abe203
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,10 +1,11 @@
# Unreleased

- Rule `no-unused-vars` has been adjusted to take [`fbt`](https://facebook.github.io/fbt/) oddities into account. This reverts the version pin of `eslint-plugin-react` introduced in 6.5.1. For more details please visit: https://github.com/yannickcr/eslint-plugin-react/issues/3080
- New rule [`flowtype/no-duplicate-type-union-intersection-members`](https://github.com/gajus/eslint-plugin-flowtype/blob/1c1c009ba2a58b9660d43c43750396bef8d73904/.README/rules/no-duplicate-type-union-intersection-members.md) has been enabled (as warnings or errors in strict mode).

# 6.5.1

- Dependency `eslint-plugin-react` was temporarily pined to version 7.25.1 because of a new issue with FBT tags: https://github.com/yannickcr/eslint-plugin-react/issues/3080
- Dependency `eslint-plugin-react` has been temporarily pined to version 7.25.1 because of a new issue with FBT tags: https://github.com/yannickcr/eslint-plugin-react/issues/3080

# 6.5.0

Expand Down
@@ -0,0 +1,12 @@
// @flow strict

// eslint-disable-next-line no-unused-vars
const someUnusedVar = 42;

// eslint-disable-next-line no-unused-vars
function fact(n) {
if (n < 2) {
return 1;
}
return n * fact(n - 1);
}
@@ -0,0 +1,13 @@
/**
* This code should NOT report `no-unused-vars` error on FBT import, see:
* https://github.com/yannickcr/eslint-plugin-react/issues/3080
*
* @flow
*/

import fbt from 'fbt'; // eslint-disable-line import/no-extraneous-dependencies
import type { Node } from 'react';

export default function MyComponent(): Node {
return <fbt desc="…">test</fbt>;
}
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/index.test.js.snap
Expand Up @@ -625,6 +625,7 @@ Object {
"args": "after-used",
"argsIgnorePattern": "^_$",
"ignoreRestSiblings": true,
"varsIgnorePattern": "^fbt$",
},
],
"no-use-before-define": 0,
Expand Down Expand Up @@ -852,6 +853,7 @@ Object {
"ignoreStateless": true,
},
],
"react/no-namespace": 0,
"react/no-redundant-should-component-update": 2,
"react/no-render-return-value": 2,
"react/no-set-state": 0,
Expand Down
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/presets.test.js.snap
Expand Up @@ -379,6 +379,7 @@ Object {
"args": "after-used",
"argsIgnorePattern": "^_$",
"ignoreRestSiblings": true,
"varsIgnorePattern": "^fbt$",
},
],
"no-use-before-define": 0,
Expand Down Expand Up @@ -948,6 +949,7 @@ Object {
"ignoreStateless": true,
},
],
"react/no-namespace": 0,
"react/no-redundant-should-component-update": 2,
"react/no-render-return-value": 2,
"react/no-set-state": 0,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "7.25.1",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.11.0",
"eslint-plugin-relay": "^1.8.2",
Expand Down
1 change: 1 addition & 0 deletions src/presets/base.js
Expand Up @@ -165,6 +165,7 @@ module.exports = ({
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_$', // (_) => { … }
varsIgnorePattern: '^fbt$', // https://github.com/yannickcr/eslint-plugin-react/issues/3080
},
],
'no-use-before-define': OFF, // https://github.com/babel/babel-eslint/issues/485
Expand Down
1 change: 1 addition & 0 deletions src/presets/react.js
Expand Up @@ -78,6 +78,7 @@ module.exports = ({
'react/no-find-dom-node': ERROR,
'react/no-is-mounted': ERROR,
'react/no-multi-comp': [ERROR, { ignoreStateless: true }],
'react/no-namespace': OFF, // complains about `<fbt:param/>` and similar
'react/no-redundant-should-component-update': ERROR,
'react/no-render-return-value': ERROR,
'react/no-set-state': OFF,
Expand Down

0 comments on commit 3abe203

Please sign in to comment.