Skip to content

Commit 71753ac

Browse files
authored
[eprh] Remove hermes-parser (facebook#34719)
We will be focusing eslint-plugin-react-hooks as the primary OSS-only package for our lint plugin. eslint-plugin-react-compiler will remain as a Meta only package as some limitations of our internal infra require us to use packages that aren't widely adopted by the rest of the industry. This PR removes `hermes-parser`, which was meant to support parsing Flow syntax.
1 parent f24d3bb commit 71753ac

File tree

3 files changed

+12
-40
lines changed

3 files changed

+12
-40
lines changed

packages/eslint-plugin-react-hooks/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"dependencies": {
4242
"@babel/core": "^7.24.4",
4343
"@babel/parser": "^7.24.4",
44-
"hermes-parser": "^0.25.1",
4544
"zod": "^3.22.4",
4645
"zod-validation-error": "^3.0.3"
4746
},
@@ -50,14 +49,14 @@
5049
"@babel/preset-typescript": "^7.26.0",
5150
"@babel/types": "^7.19.0",
5251
"@tsconfig/strictest": "^2.0.5",
53-
"@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
54-
"@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
55-
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
56-
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
5752
"@types/eslint": "^8.56.12",
5853
"@types/estree": "^1.0.6",
5954
"@types/estree-jsx": "^1.0.5",
6055
"@types/node": "^20.2.5",
56+
"@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
57+
"@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
58+
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
59+
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
6160
"babel-eslint": "^10.0.3",
6261
"eslint-v7": "npm:eslint@^7.7.0",
6362
"eslint-v8": "npm:eslint@^8.57.1",

packages/eslint-plugin-react-hooks/src/shared/RunReactCompiler.ts

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import BabelPluginReactCompiler, {
1717
LoggerEvent,
1818
} from 'babel-plugin-react-compiler';
1919
import type {SourceCode} from 'eslint';
20-
import * as HermesParser from 'hermes-parser';
2120
import {isDeepStrictEqual} from 'util';
2221
import type {ParseResult} from '@babel/parser';
2322

@@ -78,7 +77,6 @@ function getFlowSuppressions(
7877
return results;
7978
}
8079

81-
8280
function runReactCompilerImpl({
8381
sourceCode,
8482
filename,
@@ -115,27 +113,14 @@ function runReactCompilerImpl({
115113
}
116114

117115
let babelAST: ParseResult<File> | null = null;
118-
if (filename.endsWith('.tsx') || filename.endsWith('.ts')) {
119-
try {
120-
babelAST = babelParse(sourceCode.text, {
121-
sourceFilename: filename,
122-
sourceType: 'unambiguous',
123-
plugins: ['typescript', 'jsx'],
124-
});
125-
} catch {
126-
/* empty */
127-
}
128-
} else {
129-
try {
130-
babelAST = HermesParser.parse(sourceCode.text, {
131-
babel: true,
132-
enableExperimentalComponentSyntax: true,
133-
sourceFilename: filename,
134-
sourceType: 'module',
135-
});
136-
} catch {
137-
/* empty */
138-
}
116+
try {
117+
babelAST = babelParse(sourceCode.text, {
118+
sourceFilename: filename,
119+
sourceType: 'unambiguous',
120+
plugins: ['typescript', 'jsx'],
121+
});
122+
} catch (err: unknown) {
123+
/* empty */
139124
}
140125

141126
if (babelAST != null) {

yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10190,11 +10190,6 @@ hermes-eslint@^0.32.0:
1019010190
hermes-estree "0.32.0"
1019110191
hermes-parser "0.32.0"
1019210192

10193-
10194-
version "0.25.1"
10195-
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
10196-
integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
10197-
1019810193
1019910194
version "0.29.1"
1020010195
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.29.1.tgz#043c7db076e0e8ef8c5f6ed23828d1ba463ebcc5"
@@ -10219,13 +10214,6 @@ [email protected], hermes-parser@^0.32.0:
1021910214
dependencies:
1022010215
hermes-estree "0.32.0"
1022110216

10222-
hermes-parser@^0.25.1:
10223-
version "0.25.1"
10224-
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1"
10225-
integrity sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==
10226-
dependencies:
10227-
hermes-estree "0.25.1"
10228-
1022910217
homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1:
1023010218
version "1.0.3"
1023110219
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"

0 commit comments

Comments
 (0)