@samitouri / QOS-React-2 / commits / a74982d660

[eslint] Update hermes-parser, add hermes-eslint

Lauren Tan committed Nov 3, 2023 at 11:49 UTC a74982d660b1143baee3af1ec98cd9b613e36799
6 files changed +95 -40
compiler/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
+3 -3
@@ -5,8 +5,8 @@
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 -import BabelESLintParser from "@babel/eslint-parser";
8 import { RuleTester as ESLintTester } from "eslint";
9 +import * as HermesEslintParser from "hermes-eslint";
10 import ReactForgetDiagnostics from "../src/rules/ReactForgetDiagnostics";
11
12 /**
@@ -121,9 +121,9 @@ const tests: ForgetTestCases = {
121 };
122
123 const eslintTester = new ESLintTester({
124 - parser: BabelESLintParser,
124 + parser: HermesEslintParser,
125 parserOptions: {
126 - ecmaVersion: 6,
126 + ecmaVersion: 2015,
127 sourceType: "module",
128 },
129 });
compiler/packages/eslint-plugin-react-forget/package.json
+2 -2
@@ -17,10 +17,9 @@
17 "@babel/core": "^7.19.1",
18 "@babel/plugin-proposal-private-methods": "^7.18.6",
19 "babel-plugin-react-forget": "*",
20 - "hermes-parser": "^0.15.0"
20 + "hermes-parser": "^0.17.1"
21 },
22 "devDependencies": {
23 - "@babel/eslint-parser": "^7.19.1",
23 "@babel/preset-env": "^7.22.4",
24 "@babel/preset-typescript": "^7.18.6",
25 "@babel/types": "^7.19.0",
@@ -34,6 +33,7 @@
33 "eslint-doc-generator": "^1.0.0",
34 "eslint-plugin-eslint-plugin": "^5.0.0",
35 "eslint-plugin-node": "^11.1.0",
36 + "hermes-eslint": "^0.17.1",
37 "jest": "^29.5.0",
38 "npm-run-all": "^4.1.5",
39 "rollup": "^3.28.1"
compiler/packages/eslint-plugin-react-forget/src/types/hermes-eslint.d.ts new
+58
@@ -0,0 +1,58 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +// v0.17.1
9 +declare module "hermes-eslint" {
10 + // https://fburl.com/2vikhmaa
11 + type ParseForESLintOptions = {
12 + /**
13 + * Whether the whole script is executed under node.js environment.
14 + * When enabled, the scope manager adds a function scope immediately following the global scope.
15 + * Defaults to `false`.
16 + */
17 + globalReturn: boolean;
18 +
19 + /**
20 + * The identifier that's used for JSX Element creation (after transpilation).
21 + * This should not be a member expression - just the root identifier (i.e. use "React" instead of "React.createElement").
22 + *
23 + * To use the new global JSX transform function, you can explicitly set this to `null`.
24 + *
25 + * Defaults to `"React"`.
26 + */
27 + jsxPragma: string | null;
28 +
29 + /**
30 + * The identifier that's used for JSX fragment elements (after transpilation).
31 + * If `null`, assumes transpilation will always use a member on `jsxFactory` (i.e. React.Fragment).
32 + * This should not be a member expression - just the root identifier (i.e. use "h" instead of "h.Fragment").
33 + * Defaults to `null`.
34 + */
35 + jsxFragmentName: string | null;
36 +
37 + /**
38 + * The source type of the script.
39 + */
40 + sourceType: "script" | "module";
41 +
42 + /**
43 + * Ignore <fbt /> JSX elements when adding references to the module-level `React` variable.
44 + * FBT is JSX that's transformed to non-JSX and thus references differently
45 + *
46 + * https://facebook.github.io/fbt/
47 + */
48 + fbt: boolean;
49 +
50 + /**
51 + * Support experimental component syntax
52 + *
53 + * Defaults to `true`.
54 + */
55 + enableExperimentalComponentSyntax?: boolean;
56 + };
57 + export function parse(code: string, options?: Partial<ParseForESLintOptions>);
58 +}
compiler/packages/eslint-plugin-react-forget/src/types/hermes-parser.d.ts
+8 -7
@@ -5,15 +5,16 @@
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 -// v0.12.1
8 +// v0.17.1
9 declare module "hermes-parser" {
10 type HermesParserOptions = {
11 - babel: boolean;
12 - allowReturnOutsideFunction: boolean;
13 - flow: "all" | "detect";
14 - sourceFilename: string | null;
15 - sourceType: "module" | "script" | "unambiguous";
16 - tokens: boolean;
11 + allowReturnOutsideFunction?: boolean;
12 + babel?: boolean;
13 + flow?: "all" | "detect";
14 + enableExperimentalComponentSyntax?: boolean;
15 + sourceFilename?: string;
16 + sourceType?: "module" | "script" | "unambiguous";
17 + tokens?: boolean;
18 };
19 export function parse(code: string, options: Partial<HermesParserOptions>);
20 }
compiler/packages/eslint-plugin-react-forget/tsconfig.json
+4 -1
@@ -4,6 +4,9 @@
4 "rootDir": "../",
5 "noEmit": true,
6 "jsx": "react-jsxdev",
7 + "paths": {
8 + "*": ["./src/types/*"]
9 + },
10
11 // weaken strictness from preset
12 "importsNotUsedAsValues": "remove",
@@ -15,6 +18,6 @@
18 "noUnusedLocals": false,
19 "sourceMap": false
20 },
18 - "exclude": ["node_modules"],
21 + "exclude": ["node_modules", "./src/types/*"],
22 "include": ["src/**/*.ts"]
23 }
compiler/yarn.lock
+20 -27
@@ -95,15 +95,6 @@
95 json5 "^2.2.2"
96 semver "^6.3.1"
97
98 -"@babel/eslint-parser@^7.19.1":
99 - version "7.21.8"
100 - resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.21.8.tgz#59fb6fc4f3b017ab86987c076226ceef7b2b2ef2"
101 - integrity sha512-HLhI+2q+BP3sf78mFUZNCGc10KEmoUqtUT1OCdMZsN+qr4qFeLUod62/zAnF3jNQstwyasDkZnVXwfK2Bml7MQ==
102 - dependencies:
103 - "@nicolo-ribaudo/eslint-scope-5-internals" "5.1.1-v1"
104 - eslint-visitor-keys "^2.1.0"
105 - semver "^6.3.0"
106 -
98 "@babel/generator@7.2.0", "@babel/generator@^7.0.0", "@babel/generator@^7.1.6", "@babel/generator@^7.2.0":
99 version "7.2.0"
100 resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.2.0.tgz#eaf3821fa0301d9d4aef88e63d4bcc19b73ba16c"
@@ -2559,13 +2550,6 @@
2550 resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz#4a3e2a206251abc729339ba85f60bc0433c2865d"
2551 integrity sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==
2552
2562 -"@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1":
2563 - version "5.1.1-v1"
2564 - resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz#dbf733a965ca47b1973177dc0bb6c889edcfb129"
2565 - integrity sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==
2566 - dependencies:
2567 - eslint-scope "5.1.1"
2568 -
2553 "@nodelib/fs.scandir@2.1.5":
2554 version "2.1.5"
2555 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:
5667 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
5668 integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
5669
5686 -eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0:
5670 +eslint-visitor-keys@^2.0.0:
5671 version "2.1.0"
5672 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
5673 integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
@@ -6719,21 +6703,30 @@ hermes-eslint@^0.14.0:
6703 hermes-estree "0.14.0"
6704 hermes-parser "0.14.0"
6705
6706 +hermes-eslint@^0.17.1:
6707 + version "0.17.1"
6708 + resolved "https://registry.yarnpkg.com/hermes-eslint/-/hermes-eslint-0.17.1.tgz#e5e43091082dc53a060e0b002324e68943104b71"
6709 + integrity sha512-g3z4L84pHKrBMRtbfifalpbNbNear0cEygAe+geCmCj1GUrqQu+RDeBZOYERHv0HOq0aDxjTZhj3m4fD/YVUwg==
6710 + dependencies:
6711 + esrecurse "^4.3.0"
6712 + hermes-estree "0.17.1"
6713 + hermes-parser "0.17.1"
6714 +
6715 hermes-estree@0.14.0:
6716 version "0.14.0"
6717 resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.14.0.tgz#c663eea1400980802283338a09d0087c448729e7"
6718 integrity sha512-L6M67+0/eSEbt6Ha2XOBFXL++7MR34EOJMgm+j7YCaI4L/jZqrVAg6zYQKzbs1ZCFDLvEQpOgLlapTX4gpFriA==
6719
6727 -hermes-estree@0.15.0:
6728 - version "0.15.0"
6729 - resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.15.0.tgz#e32f6210ab18c7b705bdcb375f7700f2db15d6ba"
6730 - integrity sha512-lLYvAd+6BnOqWdnNbP/Q8xfl8LOGw4wVjfrNd9Gt8eoFzhNBRVD95n4l2ksfMVOoxuVyegs85g83KS9QOsxbVQ==
6731 -
6720 hermes-estree@0.15.1:
6721 version "0.15.1"
6722 resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.15.1.tgz#d06d4ddf87e91857b0130a083a9d7696d7aec61f"
6723 integrity sha512-XrQH+GATG/8DYbzlrVs6Vf/EDxLhYEHXvzt/Xve4b/NXXpsNLDN8bdBEKp5z0XeOMoL1XMEexxIIf1a5bH6kYA==
6724
6725 +hermes-estree@0.17.1:
6726 + version "0.17.1"
6727 + resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.17.1.tgz#902806a900c185720424ffcf958027821d23c051"
6728 + integrity sha512-EdUJms+eRE40OQxysFlPr1mPpvUbbMi7uDAKlScBw8o3tQY22BZ5yx56OYyp1bVaBm+7Cjc3NQz24sJEFXkPxg==
6729 +
6730 hermes-parser@0.14.0:
6731 version "0.14.0"
6732 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:
6741 dependencies:
6742 hermes-estree "0.15.1"
6743
6751 -hermes-parser@^0.15.0:
6752 - version "0.15.0"
6753 - resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.15.0.tgz#f611a297c2a2dbbfbce8af8543242254f604c382"
6754 - integrity sha512-Q1uks5rjZlE9RjMMjSUCkGrEIPI5pKJILeCtK1VmTj7U4pf3wVPoo+cxfu+s4cBAPy2JzikIIdCZgBoR6x7U1Q==
6744 +hermes-parser@0.17.1, hermes-parser@^0.17.1:
6745 + version "0.17.1"
6746 + resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.17.1.tgz#8b5cbaff235fed28487812ad718f9c7182d0db0f"
6747 + integrity sha512-yErtFLMEL6490fFJPurNn23OI2ciGAtaUfKUg9VPdcde9CmItCjOVQkJt1Xzawv5kuRzeIx0RE2E2Q9TbIgdzA==
6748 dependencies:
6756 - hermes-estree "0.15.0"
6749 + hermes-estree "0.17.1"
6750
6751 hmac-drbg@^1.0.1:
6752 version "1.0.1"