Repository: facebook/react
Pull request: [eprh] Remove hermes-parser


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.


Changed files:
filename: packages/eslint-plugin-react-hooks/package.json
patch: @@ -41,7 +41,6 @@
   "dependencies": {
     "@babel/core": "^7.24.4",
     "@babel/parser": "^7.24.4",
-    "hermes-parser": "^0.25.1",
     "zod": "^3.22.4",
     "zod-validation-error": "^3.0.3"
   },
@@ -50,14 +49,14 @@
     "@babel/preset-typescript": "^7.26.0",
     "@babel/types": "^7.19.0",
     "@tsconfig/strictest": "^2.0.5",
-    "@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
-    "@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
-    "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
-    "@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
     "@types/eslint": "^8.56.12",
     "@types/estree": "^1.0.6",
     "@types/estree-jsx": "^1.0.5",
     "@types/node": "^20.2.5",
+    "@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
+    "@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
+    "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
+    "@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
     "babel-eslint": "^10.0.3",
     "eslint-v7": "npm:eslint@^7.7.0",
     "eslint-v8": "npm:eslint@^8.57.1",

filename: packages/eslint-plugin-react-hooks/src/shared/RunReactCompiler.ts
patch: @@ -17,7 +17,6 @@ import BabelPluginReactCompiler, {
   LoggerEvent,
 } from 'babel-plugin-react-compiler';
 import type {SourceCode} from 'eslint';
-import * as HermesParser from 'hermes-parser';
 import {isDeepStrictEqual} from 'util';
 import type {ParseResult} from '@babel/parser';
 
@@ -78,7 +77,6 @@ function getFlowSuppressions(
   return results;
 }
 
-
 function runReactCompilerImpl({
   sourceCode,
   filename,
@@ -115,27 +113,14 @@ function runReactCompilerImpl({
   }
 
   let babelAST: ParseResult<File> | null = null;
-  if (filename.endsWith('.tsx') || filename.endsWith('.ts')) {
-    try {
-      babelAST = babelParse(sourceCode.text, {
-        sourceFilename: filename,
-        sourceType: 'unambiguous',
-        plugins: ['typescript', 'jsx'],
-      });
-    } catch {
-      /* empty */
-    }
-  } else {
-    try {
-      babelAST = HermesParser.parse(sourceCode.text, {
-        babel: true,
-        enableExperimentalComponentSyntax: true,
-        sourceFilename: filename,
-        sourceType: 'module',
-      });
-    } catch {
-      /* empty */
-    }
+  try {
+    babelAST = babelParse(sourceCode.text, {
+      sourceFilename: filename,
+      sourceType: 'unambiguous',
+      plugins: ['typescript', 'jsx'],
+    });
+  } catch (err: unknown) {
+    /* empty */
   }
 
   if (babelAST != null) {

filename: yarn.lock
patch: @@ -10190,11 +10190,6 @@ hermes-eslint@^0.32.0:
     hermes-estree "0.32.0"
     hermes-parser "0.32.0"
 
-hermes-estree@0.25.1:
-  version "0.25.1"
-  resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
-  integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
-
 hermes-estree@0.29.1:
   version "0.29.1"
   resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.29.1.tgz#043c7db076e0e8ef8c5f6ed23828d1ba463ebcc5"
@@ -10219,13 +10214,6 @@ hermes-parser@0.32.0, hermes-parser@^0.32.0:
   dependencies:
     hermes-estree "0.32.0"
 
-hermes-parser@^0.25.1:
-  version "0.25.1"
-  resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1"
-  integrity sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==
-  dependencies:
-    hermes-estree "0.25.1"
-
 homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1:
   version "1.0.3"
   resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"