Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint upgrade to use hermes-eslint #25915

Merged
merged 11 commits into from Dec 20, 2022
Merged

Conversation

kassens
Copy link
Member

@kassens kassens commented Dec 19, 2022

Hermes parser is the preferred parser for Flow code going forward. We need to upgrade to this parser to support new Flow syntax like function this context type annotations or ObjectType['prop'] syntax.

Unfortunately, there's quite a few upgrades here to make it work somehow (dependencies between the changes)

  • Upgrade eslint to 8.* reverted this as the React eslint plugin tests depend on the older version and there's a yarn bug that prevents devDependencies and peerDependencies to different versions.
  • Remove eslint-config-fbjs preset dependency and inline the rules, imho this makes it a lot clearer what the rules are.
  • Remove the turned off jsx-a11y/* rules and it's dependency instead of inlining those from the fbjs config.
  • Update parser and dependency from babel-eslint to hermes-eslint.
  • ft-flow/no-unused-expressions rule replaces no-unused-expressions which now allows standalone type asserts, e.g. (foo: number);
  • Bunch of globals added to the eslint config
  • Disabled no-redeclare, seems like the eslint upgrade started making this more precise and warn against re-defined globals like __EXPERIMENTAL__ (in rollup scripts) or fetch (when importing fetch from node-fetch).
  • Minor lint fixes like duplicate keys in objects.

@kassens kassens requested review from sebmarkbage and acdlite Dec 19, 2022
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 19, 2022
@kassens kassens changed the title ESLint upgrade and use hermes-eslint ESLint upgrade to use hermes-eslint Dec 20, 2022
@@ -77,7 +79,7 @@ declare module 'react-test-renderer/shallow' {
static createRenderer(): ShallowRenderer;
getMountedInstance(): ReactTestInstance;
getRenderOutput<E: React$Element<any>>(): E;
getRenderOutput(): React$Element<any>;
getRenderOutput(): React$Element<any>; // eslint-disable-line ft-flow/no-dupe-keys
Copy link
Member

@gaearon gaearon Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this declaration for? can this line be deleted entirely?

Copy link
Member Author

@kassens kassens Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was method overloading, but looking at it again that doesn't seem to be the case. I'll try if flow passes when I remove this.

@kassens kassens merged commit 2b1fb91 into facebook:main Dec 20, 2022
37 checks passed
@kassens kassens deleted the eslint-upgrade branch Dec 20, 2022
github-actions bot pushed a commit that referenced this pull request Dec 20, 2022
Hermes parser is the preferred parser for Flow code going forward. We
need to upgrade to this parser to support new Flow syntax like function
`this` context type annotations or `ObjectType['prop']` syntax.

Unfortunately, there's quite a few upgrades here to make it work somehow
(dependencies between the changes)

- ~Upgrade `eslint` to `8.*`~ reverted this as the React eslint plugin
tests depend on the older version and there's a [yarn
bug](yarnpkg/yarn#6285) that prevents
`devDependencies` and `peerDependencies` to different versions.
- Remove `eslint-config-fbjs` preset dependency and inline the rules,
imho this makes it a lot clearer what the rules are.
- Remove the turned off `jsx-a11y/*` rules and it's dependency instead
of inlining those from the `fbjs` config.
- Update parser and dependency from `babel-eslint` to `hermes-eslint`.
- `ft-flow/no-unused-expressions` rule replaces `no-unused-expressions`
which now allows standalone type asserts, e.g. `(foo: number);`
- Bunch of globals added to the eslint config
- Disabled `no-redeclare`, seems like the eslint upgrade started making
this more precise and warn against re-defined globals like
`__EXPERIMENTAL__` (in rollup scripts) or `fetch` (when importing fetch
from node-fetch).
- Minor lint fixes like duplicate keys in objects.

DiffTrain build for [2b1fb91](2b1fb91)
[View git log for this commit](https://github.com/facebook/react/commits/2b1fb91a55deb9b7b60452cb57184c2f182a42fd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants