diff --git a/compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts b/compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
index 17ae5bdcba..1a5b44b93b 100644
--- a/compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
+++ b/compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
@@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
-import BabelESLintParser from "@babel/eslint-parser";
import { RuleTester as ESLintTester } from "eslint";
+import * as HermesEslintParser from "hermes-eslint";
import ReactForgetDiagnostics from "../src/rules/ReactForgetDiagnostics";
/**
@@ -121,9 +121,9 @@ const tests: ForgetTestCases = {
};
const eslintTester = new ESLintTester({
- parser: BabelESLintParser,
+ parser: HermesEslintParser,
parserOptions: {
- ecmaVersion: 6,
+ ecmaVersion: 2015,
sourceType: "module",
},
});
diff --git a/compiler/packages/eslint-plugin-react-forget/package.json b/compiler/packages/eslint-plugin-react-forget/package.json
index 1595fc49c6..1e942e7dc5 100644
--- a/compiler/packages/eslint-plugin-react-forget/package.json
+++ b/compiler/packages/eslint-plugin-react-forget/package.json
@@ -17,10 +17,9 @@
"@babel/core": "^7.19.1",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"babel-plugin-react-forget": "*",
- "hermes-parser": "^0.15.0"
+ "hermes-parser": "^0.17.1"
},
"devDependencies": {
- "@babel/eslint-parser": "^7.19.1",
"@babel/preset-env": "^7.22.4",
"@babel/preset-typescript": "^7.18.6",
"@babel/types": "^7.19.0",
@@ -34,6 +33,7 @@
"eslint-doc-generator": "^1.0.0",
"eslint-plugin-eslint-plugin": "^5.0.0",
"eslint-plugin-node": "^11.1.0",
+ "hermes-eslint": "^0.17.1",
"jest": "^29.5.0",
"npm-run-all": "^4.1.5",
"rollup": "^3.28.1"
diff --git a/compiler/packages/eslint-plugin-react-forget/src/types/hermes-eslint.d.ts b/compiler/packages/eslint-plugin-react-forget/src/types/hermes-eslint.d.ts
new file mode 100644
index 0000000000..539daf7142
--- /dev/null
+++ b/compiler/packages/eslint-plugin-react-forget/src/types/hermes-eslint.d.ts
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+// v0.17.1
+declare module "hermes-eslint" {
+ // https://fburl.com/2vikhmaa
+ type ParseForESLintOptions = {
+ /**
+ * Whether the whole script is executed under node.js environment.
+ * When enabled, the scope manager adds a function scope immediately following the global scope.
+ * Defaults to `false`.
+ */
+ globalReturn: boolean;
+
+ /**
+ * The identifier that's used for JSX Element creation (after transpilation).
+ * This should not be a member expression - just the root identifier (i.e. use "React" instead of "React.createElement").
+ *
+ * To use the new global JSX transform function, you can explicitly set this to `null`.
+ *
+ * Defaults to `"React"`.
+ */
+ jsxPragma: string | null;
+
+ /**
+ * The identifier that's used for JSX fragment elements (after transpilation).
+ * If `null`, assumes transpilation will always use a member on `jsxFactory` (i.e. React.Fragment).
+ * This should not be a member expression - just the root identifier (i.e. use "h" instead of "h.Fragment").
+ * Defaults to `null`.
+ */
+ jsxFragmentName: string | null;
+
+ /**
+ * The source type of the script.
+ */
+ sourceType: "script" | "module";
+
+ /**
+ * Ignore JSX elements when adding references to the module-level `React` variable.
+ * FBT is JSX that's transformed to non-JSX and thus references differently
+ *
+ * https://facebook.github.io/fbt/
+ */
+ fbt: boolean;
+
+ /**
+ * Support experimental component syntax
+ *
+ * Defaults to `true`.
+ */
+ enableExperimentalComponentSyntax?: boolean;
+ };
+ export function parse(code: string, options?: Partial);
+}
diff --git a/compiler/packages/eslint-plugin-react-forget/src/types/hermes-parser.d.ts b/compiler/packages/eslint-plugin-react-forget/src/types/hermes-parser.d.ts
index 535c15880e..40771d183c 100644
--- a/compiler/packages/eslint-plugin-react-forget/src/types/hermes-parser.d.ts
+++ b/compiler/packages/eslint-plugin-react-forget/src/types/hermes-parser.d.ts
@@ -5,15 +5,16 @@
* LICENSE file in the root directory of this source tree.
*/
-// v0.12.1
+// v0.17.1
declare module "hermes-parser" {
type HermesParserOptions = {
- babel: boolean;
- allowReturnOutsideFunction: boolean;
- flow: "all" | "detect";
- sourceFilename: string | null;
- sourceType: "module" | "script" | "unambiguous";
- tokens: boolean;
+ allowReturnOutsideFunction?: boolean;
+ babel?: boolean;
+ flow?: "all" | "detect";
+ enableExperimentalComponentSyntax?: boolean;
+ sourceFilename?: string;
+ sourceType?: "module" | "script" | "unambiguous";
+ tokens?: boolean;
};
export function parse(code: string, options: Partial);
}
diff --git a/compiler/packages/eslint-plugin-react-forget/tsconfig.json b/compiler/packages/eslint-plugin-react-forget/tsconfig.json
index d828475d46..2283ca0ec9 100644
--- a/compiler/packages/eslint-plugin-react-forget/tsconfig.json
+++ b/compiler/packages/eslint-plugin-react-forget/tsconfig.json
@@ -4,6 +4,9 @@
"rootDir": "../",
"noEmit": true,
"jsx": "react-jsxdev",
+ "paths": {
+ "*": ["./src/types/*"]
+ },
// weaken strictness from preset
"importsNotUsedAsValues": "remove",
@@ -15,6 +18,6 @@
"noUnusedLocals": false,
"sourceMap": false
},
- "exclude": ["node_modules"],
+ "exclude": ["node_modules", "./src/types/*"],
"include": ["src/**/*.ts"]
}
diff --git a/compiler/yarn.lock b/compiler/yarn.lock
index 4775305740..746613e781 100644
--- a/compiler/yarn.lock
+++ b/compiler/yarn.lock
@@ -95,15 +95,6 @@
json5 "^2.2.2"
semver "^6.3.1"
-"@babel/eslint-parser@^7.19.1":
- version "7.21.8"
- resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.21.8.tgz#59fb6fc4f3b017ab86987c076226ceef7b2b2ef2"
- integrity sha512-HLhI+2q+BP3sf78mFUZNCGc10KEmoUqtUT1OCdMZsN+qr4qFeLUod62/zAnF3jNQstwyasDkZnVXwfK2Bml7MQ==
- dependencies:
- "@nicolo-ribaudo/eslint-scope-5-internals" "5.1.1-v1"
- eslint-visitor-keys "^2.1.0"
- semver "^6.3.0"
-
"@babel/generator@7.2.0", "@babel/generator@^7.0.0", "@babel/generator@^7.1.6", "@babel/generator@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.2.0.tgz#eaf3821fa0301d9d4aef88e63d4bcc19b73ba16c"
@@ -2559,13 +2550,6 @@
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz#4a3e2a206251abc729339ba85f60bc0433c2865d"
integrity sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==
-"@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1":
- version "5.1.1-v1"
- resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz#dbf733a965ca47b1973177dc0bb6c889edcfb129"
- integrity sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==
- dependencies:
- eslint-scope "5.1.1"
-
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -5683,7 +5667,7 @@ eslint-visitor-keys@^1.1.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
-eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0:
+eslint-visitor-keys@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
@@ -6719,21 +6703,30 @@ hermes-eslint@^0.14.0:
hermes-estree "0.14.0"
hermes-parser "0.14.0"
+hermes-eslint@^0.17.1:
+ version "0.17.1"
+ resolved "https://registry.yarnpkg.com/hermes-eslint/-/hermes-eslint-0.17.1.tgz#e5e43091082dc53a060e0b002324e68943104b71"
+ integrity sha512-g3z4L84pHKrBMRtbfifalpbNbNear0cEygAe+geCmCj1GUrqQu+RDeBZOYERHv0HOq0aDxjTZhj3m4fD/YVUwg==
+ dependencies:
+ esrecurse "^4.3.0"
+ hermes-estree "0.17.1"
+ hermes-parser "0.17.1"
+
hermes-estree@0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.14.0.tgz#c663eea1400980802283338a09d0087c448729e7"
integrity sha512-L6M67+0/eSEbt6Ha2XOBFXL++7MR34EOJMgm+j7YCaI4L/jZqrVAg6zYQKzbs1ZCFDLvEQpOgLlapTX4gpFriA==
-hermes-estree@0.15.0:
- version "0.15.0"
- resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.15.0.tgz#e32f6210ab18c7b705bdcb375f7700f2db15d6ba"
- integrity sha512-lLYvAd+6BnOqWdnNbP/Q8xfl8LOGw4wVjfrNd9Gt8eoFzhNBRVD95n4l2ksfMVOoxuVyegs85g83KS9QOsxbVQ==
-
hermes-estree@0.15.1:
version "0.15.1"
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.15.1.tgz#d06d4ddf87e91857b0130a083a9d7696d7aec61f"
integrity sha512-XrQH+GATG/8DYbzlrVs6Vf/EDxLhYEHXvzt/Xve4b/NXXpsNLDN8bdBEKp5z0XeOMoL1XMEexxIIf1a5bH6kYA==
+hermes-estree@0.17.1:
+ version "0.17.1"
+ resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.17.1.tgz#902806a900c185720424ffcf958027821d23c051"
+ integrity sha512-EdUJms+eRE40OQxysFlPr1mPpvUbbMi7uDAKlScBw8o3tQY22BZ5yx56OYyp1bVaBm+7Cjc3NQz24sJEFXkPxg==
+
hermes-parser@0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.14.0.tgz#edb2e7172fce996d2c8bbba250d140b70cc1aaaf"
@@ -6748,12 +6741,12 @@ hermes-parser@0.15.1, hermes-parser@^0.15.1:
dependencies:
hermes-estree "0.15.1"
-hermes-parser@^0.15.0:
- version "0.15.0"
- resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.15.0.tgz#f611a297c2a2dbbfbce8af8543242254f604c382"
- integrity sha512-Q1uks5rjZlE9RjMMjSUCkGrEIPI5pKJILeCtK1VmTj7U4pf3wVPoo+cxfu+s4cBAPy2JzikIIdCZgBoR6x7U1Q==
+hermes-parser@0.17.1, hermes-parser@^0.17.1:
+ version "0.17.1"
+ resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.17.1.tgz#8b5cbaff235fed28487812ad718f9c7182d0db0f"
+ integrity sha512-yErtFLMEL6490fFJPurNn23OI2ciGAtaUfKUg9VPdcde9CmItCjOVQkJt1Xzawv5kuRzeIx0RE2E2Q9TbIgdzA==
dependencies:
- hermes-estree "0.15.0"
+ hermes-estree "0.17.1"
hmac-drbg@^1.0.1:
version "1.0.1"