Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency eslint-compat-utils to ^0.2.0 #292

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-bugs-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-jsonc": minor
---

fix(deps): update dependency eslint-compat-utils to ^0.2.0
13 changes: 13 additions & 0 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ jobs:
npm install
- name: Test
run: npm test
test-with-eslint9:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- name: Install Target Packages
run: |+
npm i -D eslint@^9.0.0-0 --legacy-peer-deps
npx rimraf node_modules
npm install --legacy-peer-deps
- name: Test
run: npm test
test-with-eslint7:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"homepage": "https://ota-meshi.github.io/eslint-plugin-jsonc/",
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"eslint-compat-utils": "^0.1.2",
"eslint-compat-utils": "^0.2.0",
"espree": "^9.6.1",
"graphemer": "^1.4.0",
"jsonc-eslint-parser": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/indent/vue-sfc-01.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- {"parser": "vue-eslint-parser"} -->
<!-- { "languageOptions": {"parser": "vue-eslint-parser"} } -->
<i18n>
{
"key": "value"
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/as-parser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import assert from "assert";
import plugin from "../../lib/index";
import { getESLint } from "eslint-compat-utils";
const ESLint = getESLint();
import { getLegacyESLint } from "eslint-compat-utils/eslint";
const ESLint = getLegacyESLint();

// -----------------------------------------------------------------------------
// Tests
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/auto-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from "path";
import fs from "fs";
import assert from "assert";
import plugin from "../../lib/index";
import { getESLint } from "eslint-compat-utils";
const ESLint = getESLint();
import { getLegacyESLint } from "eslint-compat-utils/eslint";
const ESLint = getLegacyESLint();

// -----------------------------------------------------------------------------
// Tests
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/eslint-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import assert from "assert";
import plugin from "../../lib/index";
import { getESLint } from "eslint-compat-utils";
const ESLint = getESLint();
import { getLegacyESLint } from "eslint-compat-utils/eslint";
const ESLint = getLegacyESLint();

// -----------------------------------------------------------------------------
// Tests
Expand Down
14 changes: 11 additions & 3 deletions tests/lib/rules/array-bracket-newline.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/array-bracket-newline";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run("array-bracket-newline", rule as any, {
Expand All @@ -28,13 +32,17 @@ tester.run("array-bracket-newline", rule as any, {
filename: "test.vue",
code: `<i18n>[1,\n2]</i18n><custom-block lang="json">[\n1\n]</custom-block>`,
output: `<i18n>[\n1,\n2\n]</i18n><custom-block lang="json">[1]</custom-block>`,
parser: require.resolve("vue-eslint-parser"),
errors: [
"A linebreak is required after '['.",
"A linebreak is required before ']'.",
"There should be no linebreak after '['.",
"There should be no linebreak before ']'.",
],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
],
});
14 changes: 11 additions & 3 deletions tests/lib/rules/array-bracket-spacing.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/array-bracket-spacing";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run("array-bracket-spacing", rule as any, {
Expand Down Expand Up @@ -210,13 +214,17 @@ tester.run("array-bracket-spacing", rule as any, {
filename: "test.vue",
code: `<i18n>[ 1, 2 ]</i18n><custom-block lang="jsonc">[ 1 ]</custom-block>`,
output: `<i18n>[1, 2]</i18n><custom-block lang="jsonc">[1]</custom-block>`,
parser: require.resolve("vue-eslint-parser"),
errors: [
"There should be no space after '['.",
"There should be no space before ']'.",
"There should be no space after '['.",
"There should be no space before ']'.",
],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
{
code: "[ ]",
Expand Down
14 changes: 11 additions & 3 deletions tests/lib/rules/array-element-newline.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/array-element-newline";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run("array-element-newline", rule as any, {
Expand Down Expand Up @@ -30,13 +34,17 @@ tester.run("array-element-newline", rule as any, {
3]</i18n><custom-block lang="json5">[1,
2,
3]</custom-block>`,
parser: require.resolve("vue-eslint-parser"),
errors: [
"There should be a linebreak after this element.",
"There should be a linebreak after this element.",
"There should be a linebreak after this element.",
"There should be a linebreak after this element.",
],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
],
});
26 changes: 20 additions & 6 deletions tests/lib/rules/auto.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import path from "path";
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/auto";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
parserOptions: {
languageOptions: {
parser: jsonParser,
ecmaVersion: 2020,
},
});
Expand All @@ -21,7 +23,11 @@ tester.run("auto", rule as any, {
"foo": "bar"
}
</i18n>`,
parser: require.resolve("vue-eslint-parser"),
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
{
filename: path.join(ROOT_DIR, "test03", "test.json"),
Expand Down Expand Up @@ -75,7 +81,6 @@ tester.run("auto", rule as any, {
"bar": 2,
"foo": 3}
</block>`,
parser: require.resolve("vue-eslint-parser"),
errors: [
"[jsonc/indent] Expected indentation of 4 spaces but found 0.",
"[jsonc/indent] Expected indentation of 0 spaces but found 4.",
Expand All @@ -99,6 +104,11 @@ tester.run("auto", rule as any, {
"[jsonc/no-dupe-keys] Duplicate key 'foo'.",
"[jsonc/object-curly-spacing] There should be no space before '}'.",
],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
{
filename: path.join(ROOT_DIR, "test02", "sfc.vue"),
Expand All @@ -114,11 +124,15 @@ tester.run("auto", rule as any, {
"foo": "bar"
}
</i18n>`,
parser: require.resolve("vue-eslint-parser"),
errors: [
"[jsonc/indent] Expected indentation of 4 spaces but found 0.",
"[jsonc/indent] Expected indentation of 0 spaces but found 4.",
],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
],
});
14 changes: 11 additions & 3 deletions tests/lib/rules/comma-dangle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/comma-dangle";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run("comma-dangle", rule as any, {
Expand All @@ -23,8 +27,12 @@ tester.run("comma-dangle", rule as any, {
filename: "test.vue",
code: `<i18n>{"key": "value",}</i18n><custom-block>{"key": "value",}</custom-block>`,
output: `<i18n>{"key": "value"}</i18n><custom-block>{"key": "value",}</custom-block>`,
parser: require.resolve("vue-eslint-parser"),
errors: ["Unexpected trailing comma."],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
],
});
14 changes: 11 additions & 3 deletions tests/lib/rules/comma-style.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/comma-style";
import * as jsonParser from "jsonc-eslint-parser";
import * as vueParser from "vue-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run("comma-style", rule as any, {
Expand Down Expand Up @@ -70,8 +74,12 @@ tester.run("comma-style", rule as any, {
, "b": 2
}
}</custom-block>`,
parser: require.resolve("vue-eslint-parser"),
errors: ["',' should be placed last.", "',' should be placed last."],
...({
languageOptions: {
parser: vueParser,
},
} as any),
},
],
});
28 changes: 19 additions & 9 deletions tests/lib/rules/indent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import fs from "fs";
import path from "path";
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import type { RuleTester as ESLintRuleTester } from "eslint";
import rule from "../../../lib/rules/indent";
import * as jsonParser from "jsonc-eslint-parser";

// ------------------------------------------------------------------------------
// Helpers
Expand All @@ -22,8 +24,8 @@ const FIXTURE_ROOT = path.resolve(__dirname, "../../fixtures/indent/");
*
*/
function loadPatterns(
additionalValid: RuleTester.ValidTestCase[],
additionalInvalid: RuleTester.InvalidTestCase[],
additionalValid: ESLintRuleTester.ValidTestCase[],
additionalInvalid: ESLintRuleTester.InvalidTestCase[],
) {
const valid = fs.readdirSync(FIXTURE_ROOT).map((filename) => {
const code0 = fs.readFileSync(path.join(FIXTURE_ROOT, filename), "utf8");
Expand All @@ -33,12 +35,18 @@ function loadPatterns(
const baseObj = JSON.parse(
/^(?:\/\*|<!--)(.+?)(?:\*\/|-->)/u.exec(code0)![1],
);
if ("parser" in baseObj) {
baseObj.parser = require.resolve(baseObj.parser);
baseObj.languageOptions ??= {};
if ("parser" in baseObj.languageOptions) {
// eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore
baseObj.languageOptions.parser = require(baseObj.languageOptions.parser);
}
if ("parserOptions" in baseObj && "parser" in baseObj.parserOptions) {
baseObj.parserOptions.parser = require.resolve(
baseObj.parserOptions.parser,
if (
baseObj.languageOptions.parserOptions &&
"parser" in baseObj.languageOptions.parserOptions
) {
// eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore
baseObj.languageOptions.parserOptions.parser = require(
baseObj.languageOptions.parserOptions.parser,
);
}
return Object.assign(baseObj, { code, filename });
Expand Down Expand Up @@ -104,7 +112,9 @@ function unIndent(strings: TemplateStringsArray) {
}

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
languageOptions: {
parser: jsonParser,
},
});

tester.run(
Expand Down
7 changes: 4 additions & 3 deletions tests/lib/rules/key-name-casing.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { RuleTester } from "eslint";
import { RuleTester } from "../test-lib/eslint-compat";
import rule from "../../../lib/rules/key-name-casing";
import * as jsonParser from "jsonc-eslint-parser";

const tester = new RuleTester({
parser: require.resolve("jsonc-eslint-parser"),
parserOptions: {
languageOptions: {
parser: jsonParser,
ecmaVersion: 2020,
},
});
Expand Down
Loading
Loading