Skip to content

Commit

Permalink
[Tests] use re-exported RuleTester
Browse files Browse the repository at this point in the history
This reduces the diff in #2996.
  • Loading branch information
G-Rath authored and ljharb committed Sep 25, 2024
1 parent 61f02a2 commit 3fbe10f
Show file tree
Hide file tree
Showing 46 changed files with 48 additions and 51 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
- [Docs] [`no-relative-packages`]: fix typo ([#3066], thanks [@joshuaobrien])
- [Performance] [`no-cycle`]: dont scc for each linted file ([#3068], thanks [@soryy708])
- [Docs] [`no-cycle`]: add `disableScc` to docs ([#3070], thanks [@soryy708])
- [Tests] use re-exported `RuleTester` ([#3071], thanks [@G-Rath])

## [2.30.0] - 2024-09-02

Expand Down Expand Up @@ -1143,6 +1144,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#3071]: https://github.com/import-js/eslint-plugin-import/pull/3071
[#3070]: https://github.com/import-js/eslint-plugin-import/pull/3070
[#3068]: https://github.com/import-js/eslint-plugin-import/pull/3068
[#3066]: https://github.com/import-js/eslint-plugin-import/pull/3066
Expand Down
2 changes: 2 additions & 0 deletions tests/src/rule-tester.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function withoutAutofixOutput(test) {
return { ...test, output: test.code };
}

export { RuleTester } from 'eslint';
2 changes: 1 addition & 1 deletion tests/src/rules/consistent-type-specifier-style.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import { test, parsers, tsVersionSatisfies, eslintVersionSatisfies, typescriptEslintParserSatisfies } from '../utils';

const rule = require('rules/consistent-type-specifier-style');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/default.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { test, testVersion, SYNTAX_CASES, getTSParsers, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import semver from 'semver';
import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json';

Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/dynamic-import-chunkname.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SYNTAX_CASES, getTSParsers, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import semver from 'semver';

const rule = require('rules/dynamic-import-chunkname');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, testFilePath, SYNTAX_CASES, getTSParsers, testVersion } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';
import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/exports-last.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/exports-last';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/extensions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/extensions';
import { getTSParsers, test, testFilePath, parsers } from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/first.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, getTSParsers, testVersion } from '../utils';
import fs from 'fs';
import path from 'path';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/first');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/group-exports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/group-exports';
import { resolve } from 'path';
import { default as babelPresetFlow } from 'babel-preset-flow';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/max-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, getTSParsers, parsers } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/max-dependencies');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/named.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, SYNTAX_CASES, getTSParsers, testFilePath, testVersion, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import path from 'path';

import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/namespace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, SYNTAX_CASES, getTSParsers, testVersion, testFilePath, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';

const ruleTester = new RuleTester({ env: { es6: true } });
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';
import semver from 'semver';
import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-absolute-path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-absolute-path');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-amd.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-anonymous-default-export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, testVersion, SYNTAX_CASES } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-anonymous-default-export');
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/no-commonjs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-cycle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parsers, test as _test, testFilePath, testVersion as _testVersion } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-default-export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parsers, test, testVersion } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-default-export');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-deprecated.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, SYNTAX_CASES, getTSParsers } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-deprecated');
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/no-duplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as path from 'path';
import { test as testUtil, getNonDefaultParsers, parsers, tsVersionSatisfies, typescriptEslintParserSatisfies } from '../utils';
import jsxConfig from '../../../config/react';

import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';
import flatMap from 'array.prototype.flatmap';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-dynamic-require.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parsers, test, testVersion } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-empty-named-blocks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parsers, test } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-empty-named-blocks');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import typescriptConfig from '../../../config/typescript';
import path from 'path';
import fs from 'fs';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-import-module-exports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

import { eslintVersionSatisfies, test, testVersion } from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-internal-modules.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import flatMap from 'array.prototype.flatmap';
import rule from 'rules/no-internal-modules';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-mutable-exports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parsers, test, testVersion } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/no-mutable-exports';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, testVersion, SYNTAX_CASES } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/no-named-as-default-member';

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, testVersion, SYNTAX_CASES, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-named-as-default');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-named-default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, testVersion, SYNTAX_CASES, parsers } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-named-default');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-named-export.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import { parsers, test, testVersion } from '../utils';

const ruleTester = new RuleTester();
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/no-namespace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';
import { test } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
const isCore = require('is-core-module');

const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-relative-packages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/no-relative-packages';
import { normalize } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-relative-parent-imports.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/no-relative-parent-imports';
import { parsers, test as _test, testFilePath } from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-restricted-paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import rule from 'rules/no-restricted-paths';

import { getTSParsers, test, testFilePath } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-self-import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, testFilePath } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-self-import');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unassigned-import.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from '../utils';
import * as path from 'path';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-unassigned-import');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unresolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getTSParsers, test, SYNTAX_CASES, testVersion, parsers } from '../utils

import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-unresolved');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, testVersion, testFilePath, getTSParsers, parsers } from '../utils
import jsxConfig from '../../../config/react';
import typescriptConfig from '../../../config/typescript';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import fs from 'fs';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-useless-path-segments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parsers, test } from '../utils';
import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';

const ruleTester = new RuleTester();
const rule = require('rules/no-useless-path-segments');
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-webpack-loader-syntax.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, getTSParsers, parsers } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import semver from 'semver';

const ruleTester = new RuleTester();
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test, getTSParsers, getNonDefaultParsers, testFilePath, parsers } from '../utils';

import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import eslintPkg from 'eslint/package.json';
import semver from 'semver';
import flatMap from 'array.prototype.flatmap';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, testVersion, getNonDefaultParsers, parsers } from '../utils';

import { RuleTester } from 'eslint';
import { RuleTester } from '../rule-tester';
import semver from 'semver';
import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json';

Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/unambiguous.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RuleTester } from 'eslint';
import { withoutAutofixOutput } from '../rule-tester';
import { RuleTester, withoutAutofixOutput } from '../rule-tester';
import { parsers } from '../utils';

const ruleTester = new RuleTester();
Expand Down

0 comments on commit 3fbe10f

Please sign in to comment.