Skip to content

Commit 5261b0f

Browse files
committed
test(eslint-plugin-react-hooks):
Update unit tests to use v8 rule tester for compiler tests
1 parent a7b80a7 commit 5261b0f

File tree

4 files changed

+70
-5
lines changed

4 files changed

+70
-5
lines changed

packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {ErrorSeverity} from 'babel-plugin-react-compiler';
99
import {RuleTester as ESLintTester} from 'eslint';
1010
import ReactCompilerRule from '../src/rules/ReactCompiler';
1111

12+
const ESLintTesterV8 = require('eslint-v8').RuleTester;
13+
const ESLintTesterV9 = require('eslint-v9').RuleTester;
14+
1215
/**
1316
* A string template tag that removes padding from the left side of multi-line strings
1417
* @param {Array} strings array of code strings (only one expected)
@@ -277,12 +280,12 @@ const tests: CompilerTestCases = {
277280
],
278281
};
279282

280-
const eslintTester = new ESLintTester({
283+
const eslintTester = new ESLintTesterV8({
281284
parser: require.resolve('hermes-eslint'),
282285
parserOptions: {
283286
ecmaVersion: 2015,
284287
sourceType: 'module',
285288
enableExperimentalComponentSyntax: true,
286289
},
287290
});
288-
eslintTester.run('react-compiler', ReactCompilerRule, tests);
291+
eslintTester.run('react-compiler - eslint: v8', ReactCompilerRule, tests);

packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import {RuleTester} from 'eslint';
99
import ReactCompilerRule from '../src/rules/ReactCompiler';
1010

11+
const ESLintTesterV8 = require('eslint-v8').RuleTester;
12+
const ESLintTesterV9 = require('eslint-v9').RuleTester;
13+
1114
/**
1215
* A string template tag that removes padding from the left side of multi-line strings
1316
* @param {Array} strings array of code strings (only one expected)
@@ -70,7 +73,7 @@ const tests: CompilerTestCases = {
7073
],
7174
};
7275

73-
const eslintTester = new RuleTester({
74-
parser: require.resolve('@typescript-eslint/parser'),
76+
const eslintTester = new ESLintTesterV8({
77+
parser: require.resolve('@typescript-eslint/parser-v5'),
7578
});
76-
eslintTester.run('react-compiler', ReactCompilerRule, tests);
79+
eslintTester.run('react-compiler - eslint: v8', ReactCompilerRule, tests);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@types/node": "^20.2.5",
6262
"babel-eslint": "^10.0.3",
6363
"eslint-v7": "npm:eslint@^7.7.0",
64+
"eslint-v8": "npm:eslint@^8.57.1",
6465
"eslint-v9": "npm:eslint@^9.0.0",
6566
"jest": "^29.5.0",
6667
"typescript": "^5.4.3"

yarn.lock

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,11 @@
22512251
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
22522252
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
22532253

2254+
"@eslint/js@8.57.1":
2255+
version "8.57.1"
2256+
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2"
2257+
integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==
2258+
22542259
"@eslint/js@9.0.0":
22552260
version "9.0.0"
22562261
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.0.0.tgz#1a9e4b4c96d8c7886e0110ed310a0135144a1691"
@@ -2314,6 +2319,15 @@
23142319
debug "^4.3.1"
23152320
minimatch "^3.0.5"
23162321

2322+
"@humanwhocodes/config-array@^0.13.0":
2323+
version "0.13.0"
2324+
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.13.0.tgz#fb907624df3256d04b9aa2df50d7aa97ec648748"
2325+
integrity sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==
2326+
dependencies:
2327+
"@humanwhocodes/object-schema" "^2.0.3"
2328+
debug "^4.3.1"
2329+
minimatch "^3.0.5"
2330+
23172331
"@humanwhocodes/config-array@^0.5.0":
23182332
version "0.5.0"
23192333
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9"
@@ -7509,6 +7523,50 @@ eslint-utils@^2.0.0, eslint-utils@^2.1.0:
75097523
text-table "^0.2.0"
75107524
v8-compile-cache "^2.0.3"
75117525

7526+
"eslint-v8@npm:eslint@^8.57.1":
7527+
version "8.57.1"
7528+
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.1.tgz#7df109654aba7e3bbe5c8eae533c5e461d3c6ca9"
7529+
integrity sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==
7530+
dependencies:
7531+
"@eslint-community/eslint-utils" "^4.2.0"
7532+
"@eslint-community/regexpp" "^4.6.1"
7533+
"@eslint/eslintrc" "^2.1.4"
7534+
"@eslint/js" "8.57.1"
7535+
"@humanwhocodes/config-array" "^0.13.0"
7536+
"@humanwhocodes/module-importer" "^1.0.1"
7537+
"@nodelib/fs.walk" "^1.2.8"
7538+
"@ungap/structured-clone" "^1.2.0"
7539+
ajv "^6.12.4"
7540+
chalk "^4.0.0"
7541+
cross-spawn "^7.0.2"
7542+
debug "^4.3.2"
7543+
doctrine "^3.0.0"
7544+
escape-string-regexp "^4.0.0"
7545+
eslint-scope "^7.2.2"
7546+
eslint-visitor-keys "^3.4.3"
7547+
espree "^9.6.1"
7548+
esquery "^1.4.2"
7549+
esutils "^2.0.2"
7550+
fast-deep-equal "^3.1.3"
7551+
file-entry-cache "^6.0.1"
7552+
find-up "^5.0.0"
7553+
glob-parent "^6.0.2"
7554+
globals "^13.19.0"
7555+
graphemer "^1.4.0"
7556+
ignore "^5.2.0"
7557+
imurmurhash "^0.1.4"
7558+
is-glob "^4.0.0"
7559+
is-path-inside "^3.0.3"
7560+
js-yaml "^4.1.0"
7561+
json-stable-stringify-without-jsonify "^1.0.1"
7562+
levn "^0.4.1"
7563+
lodash.merge "^4.6.2"
7564+
minimatch "^3.1.2"
7565+
natural-compare "^1.4.0"
7566+
optionator "^0.9.3"
7567+
strip-ansi "^6.0.1"
7568+
text-table "^0.2.0"
7569+
75127570
"eslint-v9@npm:eslint@^9.0.0":
75137571
version "9.0.0"
75147572
resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.0.0.tgz#6270548758e390343f78c8afd030566d86927d40"

0 commit comments

Comments
 (0)