Skip to content

Commit

Permalink
test(eslint-plugin-react-hooks): Run with TS parsers >= 2.x (#19792)
Browse files Browse the repository at this point in the history
* test(eslint-plugin-react-hooks): Run with TS parsers >= 2.x

* name test suites for each parser
  • Loading branch information
eps1lon committed Sep 10, 2020
1 parent cd75f93 commit ed4fdfc
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7962,22 +7962,46 @@ if (!process.env.CI) {
testsTypescript.invalid = testsTypescript.invalid.filter(predicate);
}

const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
};

new ESLintTester({
parser: require.resolve('babel-eslint'),
parserOptions,
}).run('react-hooks', ReactHooksESLintRule, tests);

new ESLintTester({
parser: require.resolve('@babel/eslint-parser'),
parserOptions,
}).run('react-hooks', ReactHooksESLintRule, tests);
describe('react-hooks', () => {
const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
};

new ESLintTester({
parser: require.resolve('@typescript-eslint/parser'),
parserOptions,
}).run('react-hooks', ReactHooksESLintRule, testsTypescript);
new ESLintTester({
parser: require.resolve('babel-eslint'),
parserOptions,
}).run('parser: babel-eslint', ReactHooksESLintRule, tests);

new ESLintTester({
parser: require.resolve('@babel/eslint-parser'),
parserOptions,
}).run('parser: @babel/eslint-parser', ReactHooksESLintRule, tests);

new ESLintTester({
parser: require.resolve('@typescript-eslint/parser-v2'),
parserOptions,
}).run(
'parser: @typescript-eslint/parser@2.x',
ReactHooksESLintRule,
testsTypescript
);

new ESLintTester({
parser: require.resolve('@typescript-eslint/parser-v3'),
parserOptions,
}).run(
'parser: @typescript-eslint/parser@3.x',
ReactHooksESLintRule,
testsTypescript
);

new ESLintTester({
parser: require.resolve('@typescript-eslint/parser-v4'),
parserOptions,
}).run(
'parser: @typescript-eslint/parser@4.x',
ReactHooksESLintRule,
testsTypescript
);
});
4 changes: 3 additions & 1 deletion packages/eslint-plugin-react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
},
"devDependencies": {
"@typescript-eslint/parser": "^2.26.0"
"@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"
}
}
Loading

0 comments on commit ed4fdfc

Please sign in to comment.