|
1 | 1 | import path from "path";
|
2 | 2 | import assert from "assert";
|
3 | 3 | import plugin from "../../src/index";
|
4 |
| -import { getLegacyESLint } from "eslint-compat-utils/eslint"; |
| 4 | +import semver from "semver"; |
| 5 | +import { getLegacyESLint, getESLint } from "eslint-compat-utils/eslint"; |
5 | 6 |
|
6 |
| -// eslint-disable-next-line @typescript-eslint/naming-convention -- Class name |
7 |
| -const ESLint = getLegacyESLint(); |
8 | 7 | // -----------------------------------------------------------------------------
|
9 | 8 | // Tests
|
10 | 9 | // -----------------------------------------------------------------------------
|
11 | 10 |
|
12 |
| -const TEST_CWD = path.join(__dirname, "../fixtures/integrations/eslint-plugin"); |
| 11 | +const TEST_FIXTURES_ROOT = path.join( |
| 12 | + __dirname, |
| 13 | + "../fixtures/integrations/eslint-plugin", |
| 14 | +); |
13 | 15 |
|
14 | 16 | describe("Integration with eslint-plugin-json-schema-validator", () => {
|
15 |
| - it("should lint without errors", async () => { |
| 17 | + it("should lint without errors with legacy-config", async () => { |
| 18 | + // eslint-disable-next-line @typescript-eslint/naming-convention -- Class name |
| 19 | + const ESLint = getLegacyESLint(); |
16 | 20 | const engine = new ESLint({
|
17 |
| - cwd: TEST_CWD, |
| 21 | + cwd: path.join(TEST_FIXTURES_ROOT, "legacy-config-test01"), |
18 | 22 | extensions: [".js", ".json"],
|
19 | 23 | plugins: { "json-schema-validator": plugin as any },
|
20 | 24 | });
|
21 |
| - const results = await engine.lintFiles(["test01/src"]); |
| 25 | + const results = await engine.lintFiles(["src"]); |
| 26 | + assert.strictEqual(results.length, 2); |
| 27 | + assert.strictEqual( |
| 28 | + results.reduce((s, r) => s + r.errorCount, 0), |
| 29 | + 0, |
| 30 | + ); |
| 31 | + }); |
| 32 | + it("should lint without errors with flat-config", async () => { |
| 33 | + // eslint-disable-next-line @typescript-eslint/naming-convention -- Class name |
| 34 | + const ESLint = getESLint(); |
| 35 | + if (semver.satisfies(ESLint.version, "<7.0.0")) return; |
| 36 | + const engine = new ESLint({ |
| 37 | + cwd: path.join(TEST_FIXTURES_ROOT, "flat-config-test01"), |
| 38 | + // @ts-expect-error -- typing bug |
| 39 | + overrideConfigFile: true, |
| 40 | + // @ts-expect-error -- typing bug |
| 41 | + overrideConfig: plugin.configs["flat/recommended"], |
| 42 | + }); |
| 43 | + const results = await engine.lintFiles(["src"]); |
22 | 44 | assert.strictEqual(results.length, 2);
|
23 | 45 | assert.strictEqual(
|
24 | 46 | results.reduce((s, r) => s + r.errorCount, 0),
|
|
0 commit comments