Skip to content

Commit 60a08c3

Browse files
test: fix
1 parent 6f26349 commit 60a08c3

File tree

6 files changed

+45
-39
lines changed

6 files changed

+45
-39
lines changed

src/linter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ async function linter(key, options, compilation) {
184184
/** @type {ESLint} */
185185
let eslint;
186186

187-
/** @type {(files: string|string[]) => Promise<LintResult[]>} */
187+
/** @type {(files: string | string[]) => Promise<LintResult[]>} */
188188
let lintFiles;
189189

190190
/** @type {() => Promise<void>} */

test/config-for-tests/.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
module.exports = {
2-
root: true,
2+
ignorePatterns: ["**/ignore.js"],
33
globals: {
44
__dirname: "readonly",
55
__filename: "readonly",
66
exports: "writable",
77
module: "readonly",
88
require: "readonly",
9+
console: "readonly",
910
},
1011
parserOptions: {
1112
ecmaVersion: 2018,
1213
env: {
14+
browser: true,
1315
node: true,
1416
es6: true,
1517
},

test/eslintignore.test.js renamed to test/ignore.test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
import eslint from "eslint";
12
import ESLintError from "../src/ESLintError";
2-
33
import pack from "./utils/pack";
44

55
describe("eslintignore", () => {
66
it("should ignores files present in .eslintignore", async () => {
7-
const compiler = pack("ignore", {
8-
ignore: true,
9-
ignorePatterns: ["**/ignore.js"],
10-
});
7+
const pluginConfig =
8+
Number.parseFloat(eslint.ESLint.version) >= 9
9+
? {
10+
ignore: true,
11+
ignorePatterns: ["**/ignore.js"],
12+
}
13+
: {
14+
ignore: true,
15+
};
16+
17+
const compiler = pack("ignore", pluginConfig);
1118

1219
const stats = await compiler.runAsync();
1320
expect(stats.hasWarnings()).toBe(false);

test/multiple-instances.test.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { join } from "node:path";
2-
2+
import eslint from "eslint";
33
import ESLintPlugin from "../src";
4-
54
import pack from "./utils/pack";
65

6+
const configType =
7+
Number.parseFloat(eslint.ESLint.version) >= 9 ? "flat" : "eslintrc";
8+
const config =
9+
Number.parseFloat(eslint.ESLint.version) >= 9
10+
? join(__dirname, "./config-for-tests/eslint.config.mjs")
11+
: join(__dirname, "./config-for-tests/.eslintrc.js");
12+
713
describe("multiple instances", () => {
814
it("should don't fail", async () => {
915
const compiler = pack(
@@ -12,18 +18,14 @@ describe("multiple instances", () => {
1218
{
1319
plugins: [
1420
new ESLintPlugin({
15-
overrideConfigFile: join(
16-
__dirname,
17-
"./config-for-tests/eslint.config.mjs",
18-
),
21+
configType,
22+
overrideConfigFile: config,
1923
ignore: false,
2024
exclude: "error.js",
2125
}),
2226
new ESLintPlugin({
23-
overrideConfigFile: join(
24-
__dirname,
25-
"./config-for-tests/eslint.config.mjs",
26-
),
27+
configType,
28+
overrideConfigFile: config,
2729
ignore: false,
2830
exclude: "error.js",
2931
}),
@@ -43,18 +45,14 @@ describe("multiple instances", () => {
4345
{
4446
plugins: [
4547
new ESLintPlugin({
46-
overrideConfigFile: join(
47-
__dirname,
48-
"./config-for-tests/eslint.config.mjs",
49-
),
48+
configType,
49+
overrideConfigFile: config,
5050
ignore: false,
5151
exclude: "good.js",
5252
}),
5353
new ESLintPlugin({
54-
overrideConfigFile: join(
55-
__dirname,
56-
"./config-for-tests/eslint.config.mjs",
57-
),
54+
configType,
55+
overrideConfigFile: config,
5856
ignore: false,
5957
exclude: "error.js",
6058
}),
@@ -72,18 +70,14 @@ describe("multiple instances", () => {
7270
{
7371
plugins: [
7472
new ESLintPlugin({
75-
overrideConfigFile: join(
76-
__dirname,
77-
"./config-for-tests/eslint.config.mjs",
78-
),
73+
configType,
74+
overrideConfigFile: config,
7975
ignore: false,
8076
exclude: "error.js",
8177
}),
8278
new ESLintPlugin({
83-
overrideConfigFile: join(
84-
__dirname,
85-
"./config-for-tests/eslint.config.mjs",
86-
),
79+
configType,
80+
overrideConfigFile: config,
8781
ignore: false,
8882
exclude: "good.js",
8983
}),

test/threads.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env jest */
22
import { join } from "node:path";
3-
3+
import eslint from "eslint";
44
import { loadESLint, loadESLintThreaded } from "../src/getESLint";
55

66
describe("Threading", () => {
@@ -23,11 +23,12 @@ describe("Threading", () => {
2323
it("threaded should lint files", async () => {
2424
const threaded = await loadESLintThreaded("bar", 1, {
2525
ignore: false,
26-
configType: "flat",
27-
overrideConfigFile: join(
28-
__dirname,
29-
"./config-for-tests/eslint.config.mjs",
30-
),
26+
configType:
27+
Number.parseFloat(eslint.ESLint.version) >= 9 ? "flat" : "eslintrc",
28+
overrideConfigFile:
29+
Number.parseFloat(eslint.ESLint.version) >= 9
30+
? join(__dirname, "./config-for-tests/eslint.config.mjs")
31+
: join(__dirname, "./config-for-tests/.eslintrc.js"),
3132
});
3233
try {
3334
const [good, bad] = await Promise.all([

test/utils/conf.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default (entry, pluginConf = {}, webpackConf = {}) => {
1515
},
1616
plugins: [
1717
new ESLintPlugin({
18+
// Do not cache for tests
19+
cache: false,
1820
configType:
1921
Number.parseFloat(eslint.ESLint.version) >= 9 ? "flat" : "eslintrc",
2022
overrideConfigFile:

0 commit comments

Comments
 (0)