forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eslint: Use new hermes-eslint parser, instead of @babel/eslint-parser
This is "the recommended parser for use for linting with Flow code" ( https://www.npmjs.com/package/hermes-eslint ) and it's the one most recommended in Flow's guide to enabling Flow enums, which we'd like to do soon: https://flow.org/en/docs/enums/enabling-enums/ Since that Flow-enums guide says "Upgrade hermes-parser to at least version 0.4.8", add a `resolutions` line to guarantee that. The hermes-eslint code seems to live here on GitHub: https://github.com/facebook/hermes/tree/main/tools/hermes-parser/js/hermes-eslint With this parser, it will be possible (once we enable Flow enums, coming up) to define a Flow enum without getting an ESLint error like Parsing error: Unexpected token, expected "{" . The new parsing also gives better feedback on existing code. We fix a new warning and a new error in this commit: - A warning "'V' is defined but never used" on the type param V at src/generics.js:175:54. Sure enough, V isn't used; remove it. - The eslint-disable for no-use-before-define, at src/presence/__tests__/heartbeat-test.js:49:5, isn't suppressing any error and can be removed. Yep, the use isn't before the definition; remove the eslint-disable. Finally, repeal a few now-redundant ESLint rules, with comments. For posterity, here's the full error output that I abbreviated in a comment on ft-flow/define-flow-type: Running lint... Oops! Something went wrong! :( ESLint: 8.17.0 TypeError: globalScope.__defineGeneric is not a function Occurred while linting /Users/chrisbobbe/dev/zulip-mobile/src/api/modelTypes.js:53 Rule: "ft-flow/define-flow-type" at makeDefined (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint-plugin-ft-flow/dist/rules/defineFlowType.js:21:21) at GenericTypeAnnotation (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint-plugin-ft-flow/dist/rules/defineFlowType.js:67:9) at ruleErrorHandler (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/linter.js:1114:28) at /Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/safe-emitter.js:45:58 at Array.forEach (<anonymous>) at Object.emit (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/safe-emitter.js:45:38) at NodeEventGenerator.applySelector (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/node-event-generator.js:297:26) at NodeEventGenerator.applySelectors (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/node-event-generator.js:326:22) at NodeEventGenerator.enterNode (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/node-event-generator.js:340:14) at CodePathAnalyzer.enterNode (/Users/chrisbobbe/dev/zulip-mobile/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
- Loading branch information
1 parent
16d1182
commit 3b76083
Showing
7 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
parser: "@babel/eslint-parser" | ||
parser: hermes-eslint | ||
plugins: | ||
- ft-flow | ||
rules: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6006,10 +6006,26 @@ hermes-engine@~0.9.0: | |
resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.9.0.tgz#84d9cfe84e8f6b1b2020d6e71b350cec84ed982f" | ||
integrity sha512-r7U+Y4P2Qg/igFVZN+DpT7JFfXUn1MM4dFne8aW+cCrF6RRymof+VqrUHs1kl07j8h8V2CNesU19RKgWbr3qPw== | ||
|
||
[email protected]: | ||
version "0.4.7" | ||
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.4.7.tgz#410f5129d57183784d205a0538e6fbdcf614c9ea" | ||
integrity sha512-jc+zCtXbtwTiXoMAoXOHepxAaGVFIp89wwE9qcdwnMd/uGVEtPoY8FaFSsx0ThPvyKirdR2EsIIDVrpbSXz1Ag== | ||
hermes-eslint@^0.9.0: | ||
version "0.9.0" | ||
resolved "https://registry.yarnpkg.com/hermes-eslint/-/hermes-eslint-0.9.0.tgz#f1423abe3dfd959257430d61a9bccd4700b59e09" | ||
integrity sha512-rlkK51UpGwo0ZWg8hu8DVICth7RfGSvaEJzFflos8bDOYm/d842/J3IXi0lB9R9waOp4VGGSc8VDmh+a9p2Q2w== | ||
dependencies: | ||
esrecurse "^4.3.0" | ||
hermes-estree "0.9.0" | ||
hermes-parser "0.9.0" | ||
|
||
[email protected]: | ||
version "0.9.0" | ||
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.9.0.tgz#026e0abe6db1dcf50a81a79014b779a83db3b814" | ||
integrity sha512-5DZ7Y0CbHVk8zPqgRCvqp8iw+P05svnQDI1aJFjdqCfXJ/1CZ+8aYpGlhJ29zCG5SE5duGTzSxogAYYI4QqXqw== | ||
|
||
[email protected], [email protected], hermes-parser@>=0.4.8: | ||
version "0.9.0" | ||
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.9.0.tgz#ede3044d50479c61843cef5bbdcea83933d4e4ec" | ||
integrity sha512-IcvJIlAn+9tpHkP+HTsxWKrIdQPp0gvGrrQmxlL4XnNS+Oh6R/Fpxbcoflm2kY3zgQjEvxZxLiK/2+k3/5wsrw== | ||
dependencies: | ||
hermes-estree "0.9.0" | ||
|
||
hermes-profile-transformer@^0.0.6: | ||
version "0.0.6" | ||
|