From 2e569f749eeb09c5797199ce3904080ef0da2199 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 23:13:07 +0900 Subject: [PATCH] fix(deps): update dependency eslint-compat-utils to ^0.2.0 (#183) * fix(deps): update dependency eslint-compat-utils to ^0.2.0 * Create lucky-bananas-roll.md * fix * fix * fix --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Yosuke Ota --- .changeset/lucky-bananas-roll.md | 5 +++++ .github/workflows/NodeCI.yml | 12 ++++++++++++ package.json | 2 +- tests/src/eslint-plugin.ts | 4 ++-- tests/src/rules-without-vue-eslint-parser.ts | 14 +++++++++----- tests/src/rules/array-bracket-newline.ts | 11 +++++++---- tests/src/rules/array-bracket-spacing.ts | 11 +++++++---- tests/src/rules/array-element-newline.ts | 11 +++++++---- tests/src/rules/comma-style.ts | 11 +++++++---- tests/src/rules/indent.ts | 11 +++++++---- tests/src/rules/inline-table-curly-spacing.ts | 11 +++++++---- tests/src/rules/key-spacing.ts | 11 +++++++---- tests/src/rules/keys-order.ts | 11 +++++++---- tests/src/rules/no-mixed-type-in-array.ts | 11 +++++++---- tests/src/rules/no-non-decimal-integer.ts | 11 +++++++---- tests/src/rules/no-space-dots.ts | 11 +++++++---- tests/src/rules/no-unreadable-number-separator.ts | 11 +++++++---- tests/src/rules/padding-line-between-pairs.ts | 11 +++++++---- tests/src/rules/padding-line-between-tables.ts | 11 +++++++---- tests/src/rules/precision-of-fractional-seconds.ts | 11 +++++++---- tests/src/rules/precision-of-integer.ts | 11 +++++++---- tests/src/rules/quoted-keys.ts | 11 +++++++---- tests/src/rules/space-eq-sign.ts | 11 +++++++---- tests/src/rules/spaced-comment.ts | 11 +++++++---- tests/src/rules/table-bracket-spacing.ts | 11 +++++++---- tests/src/rules/tables-order.ts | 11 +++++++---- .../src/rules/vue-custom-block/no-parsing-error.ts | 11 +++++++---- tests/src/test-lib/eslint-compat.ts | 8 ++++++++ tests/utils/utils.ts | 12 ++++++++---- tools/new-rule.ts | 9 ++++++--- tsconfig.json | 2 +- 31 files changed, 206 insertions(+), 104 deletions(-) create mode 100644 .changeset/lucky-bananas-roll.md create mode 100644 tests/src/test-lib/eslint-compat.ts diff --git a/.changeset/lucky-bananas-roll.md b/.changeset/lucky-bananas-roll.md new file mode 100644 index 00000000..54f3b330 --- /dev/null +++ b/.changeset/lucky-bananas-roll.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-toml": minor +--- + +fix(deps): update dependency eslint-compat-utils to ^0.2.0 diff --git a/.github/workflows/NodeCI.yml b/.github/workflows/NodeCI.yml index 5cbf3c5a..65a4169f 100644 --- a/.github/workflows/NodeCI.yml +++ b/.github/workflows/NodeCI.yml @@ -31,6 +31,18 @@ jobs: run: npm install - name: Test run: npm test + test-with-eslint9: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - name: Install Target Packages + run: |+ + npm i -D eslint@^9.0.0-0 -f + npx rimraf node_modules + npm install -f + - name: Test + run: npm test test-with-eslint6: runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index bd908c81..a939caac 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ }, "dependencies": { "debug": "^4.1.1", - "eslint-compat-utils": "^0.1.2", + "eslint-compat-utils": "^0.2.0", "lodash": "^4.17.19", "toml-eslint-parser": "^0.9.0" }, diff --git a/tests/src/eslint-plugin.ts b/tests/src/eslint-plugin.ts index 31461991..13ede001 100644 --- a/tests/src/eslint-plugin.ts +++ b/tests/src/eslint-plugin.ts @@ -1,10 +1,10 @@ import path from "path"; import assert from "assert"; -import { getESLint } from "eslint-compat-utils"; +import { getLegacyESLint } from "eslint-compat-utils/eslint"; import plugin from "../../src/index"; // eslint-disable-next-line @typescript-eslint/naming-convention -- Class name -const ESLint = getESLint(); +const ESLint = getLegacyESLint(); // ----------------------------------------------------------------------------- // Tests diff --git a/tests/src/rules-without-vue-eslint-parser.ts b/tests/src/rules-without-vue-eslint-parser.ts index 7dc03802..04e9ce52 100644 --- a/tests/src/rules-without-vue-eslint-parser.ts +++ b/tests/src/rules-without-vue-eslint-parser.ts @@ -1,7 +1,9 @@ -import { Linter } from "eslint"; +import { getLinter } from "eslint-compat-utils/linter"; import plugin from "../../src/index"; import assert from "assert"; const rules = plugin.rules; +// eslint-disable-next-line @typescript-eslint/naming-convention -- class name +const Linter = getLinter(); describe("Don't crash even if without toml-eslint-parser.", () => { const code = "{a:[1,2,3,4]}"; @@ -11,13 +13,15 @@ describe("Don't crash even if without toml-eslint-parser.", () => { it(ruleId, () => { const linter = new Linter(); - const config: Linter.Config = { - parserOptions: { ecmaVersion: 2015 }, + const config = { + languageOptions: { ecmaVersion: 2015 }, + plugins: { + toml: plugin, + }, rules: { [ruleId]: "error", }, - }; - linter.defineRule(ruleId, rules[key] as any); + } as any; const resultJs = linter.verifyAndFix(code, config, "test.js"); assert.strictEqual(resultJs.messages.length, 0); }); diff --git a/tests/src/rules/array-bracket-newline.ts b/tests/src/rules/array-bracket-newline.ts index 330c3156..00428a01 100644 --- a/tests/src/rules/array-bracket-newline.ts +++ b/tests/src/rules/array-bracket-newline.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/array-bracket-newline"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/array-bracket-spacing.ts b/tests/src/rules/array-bracket-spacing.ts index e82e0df1..b5fa2e00 100644 --- a/tests/src/rules/array-bracket-spacing.ts +++ b/tests/src/rules/array-bracket-spacing.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/array-bracket-spacing"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/array-element-newline.ts b/tests/src/rules/array-element-newline.ts index 5007734b..96fcc926 100644 --- a/tests/src/rules/array-element-newline.ts +++ b/tests/src/rules/array-element-newline.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/array-element-newline"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/comma-style.ts b/tests/src/rules/comma-style.ts index c942c895..0cb5d916 100644 --- a/tests/src/rules/comma-style.ts +++ b/tests/src/rules/comma-style.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/comma-style"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/indent.ts b/tests/src/rules/indent.ts index c3b592e7..aa6f69dd 100644 --- a/tests/src/rules/indent.ts +++ b/tests/src/rules/indent.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/indent"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/inline-table-curly-spacing.ts b/tests/src/rules/inline-table-curly-spacing.ts index a0df6700..51ddb1d3 100644 --- a/tests/src/rules/inline-table-curly-spacing.ts +++ b/tests/src/rules/inline-table-curly-spacing.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/inline-table-curly-spacing"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/key-spacing.ts b/tests/src/rules/key-spacing.ts index a7fbd9e4..9b837972 100644 --- a/tests/src/rules/key-spacing.ts +++ b/tests/src/rules/key-spacing.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/key-spacing"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/keys-order.ts b/tests/src/rules/keys-order.ts index 75059749..a36e3130 100644 --- a/tests/src/rules/keys-order.ts +++ b/tests/src/rules/keys-order.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/keys-order"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/no-mixed-type-in-array.ts b/tests/src/rules/no-mixed-type-in-array.ts index adf52051..21cb1a43 100644 --- a/tests/src/rules/no-mixed-type-in-array.ts +++ b/tests/src/rules/no-mixed-type-in-array.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/no-mixed-type-in-array"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/no-non-decimal-integer.ts b/tests/src/rules/no-non-decimal-integer.ts index 2faff656..454a34ad 100644 --- a/tests/src/rules/no-non-decimal-integer.ts +++ b/tests/src/rules/no-non-decimal-integer.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/no-non-decimal-integer"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/no-space-dots.ts b/tests/src/rules/no-space-dots.ts index 7a7dfb7e..1557023a 100644 --- a/tests/src/rules/no-space-dots.ts +++ b/tests/src/rules/no-space-dots.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/no-space-dots"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/no-unreadable-number-separator.ts b/tests/src/rules/no-unreadable-number-separator.ts index 58467e28..755d8d86 100644 --- a/tests/src/rules/no-unreadable-number-separator.ts +++ b/tests/src/rules/no-unreadable-number-separator.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/no-unreadable-number-separator"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/padding-line-between-pairs.ts b/tests/src/rules/padding-line-between-pairs.ts index 3a020669..661c3e8c 100644 --- a/tests/src/rules/padding-line-between-pairs.ts +++ b/tests/src/rules/padding-line-between-pairs.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/padding-line-between-pairs"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/padding-line-between-tables.ts b/tests/src/rules/padding-line-between-tables.ts index 079752ee..02c38a47 100644 --- a/tests/src/rules/padding-line-between-tables.ts +++ b/tests/src/rules/padding-line-between-tables.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/padding-line-between-tables"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/precision-of-fractional-seconds.ts b/tests/src/rules/precision-of-fractional-seconds.ts index e57d0679..d05e2618 100644 --- a/tests/src/rules/precision-of-fractional-seconds.ts +++ b/tests/src/rules/precision-of-fractional-seconds.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/precision-of-fractional-seconds"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/precision-of-integer.ts b/tests/src/rules/precision-of-integer.ts index 16eb8966..4f40bd5b 100644 --- a/tests/src/rules/precision-of-integer.ts +++ b/tests/src/rules/precision-of-integer.ts @@ -1,14 +1,17 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule, { maxBitToMaxValues, } from "../../../src/rules/precision-of-integer"; import { loadTestCases } from "../../utils/utils"; import assert from "assert"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/quoted-keys.ts b/tests/src/rules/quoted-keys.ts index 36bcb72b..981374c7 100644 --- a/tests/src/rules/quoted-keys.ts +++ b/tests/src/rules/quoted-keys.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/quoted-keys"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/space-eq-sign.ts b/tests/src/rules/space-eq-sign.ts index 70c132f7..6a0bc01e 100644 --- a/tests/src/rules/space-eq-sign.ts +++ b/tests/src/rules/space-eq-sign.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/space-eq-sign"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/spaced-comment.ts b/tests/src/rules/spaced-comment.ts index fde3c0fd..319d8a38 100644 --- a/tests/src/rules/spaced-comment.ts +++ b/tests/src/rules/spaced-comment.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/spaced-comment"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/table-bracket-spacing.ts b/tests/src/rules/table-bracket-spacing.ts index 8cadd307..501d7f74 100644 --- a/tests/src/rules/table-bracket-spacing.ts +++ b/tests/src/rules/table-bracket-spacing.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/table-bracket-spacing"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/tables-order.ts b/tests/src/rules/tables-order.ts index eb52b892..b0c14454 100644 --- a/tests/src/rules/tables-order.ts +++ b/tests/src/rules/tables-order.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../test-lib/eslint-compat"; import rule from "../../../src/rules/tables-order"; import { loadTestCases } from "../../utils/utils"; +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: tomlParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/rules/vue-custom-block/no-parsing-error.ts b/tests/src/rules/vue-custom-block/no-parsing-error.ts index a99aa14d..9d6f95a2 100644 --- a/tests/src/rules/vue-custom-block/no-parsing-error.ts +++ b/tests/src/rules/vue-custom-block/no-parsing-error.ts @@ -1,11 +1,14 @@ -import { RuleTester } from "eslint"; +import { RuleTester } from "../../test-lib/eslint-compat"; import rule from "../../../../src/rules/vue-custom-block/no-parsing-error"; import { loadTestCases } from "../../../utils/utils"; +import * as vueParser from "vue-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("yaml-eslint-parser"), - parserOptions: { - tomlVersion: "next", + languageOptions: { + parser: vueParser, + parserOptions: { + tomlVersion: "next", + }, }, }); diff --git a/tests/src/test-lib/eslint-compat.ts b/tests/src/test-lib/eslint-compat.ts new file mode 100644 index 00000000..3e9418c9 --- /dev/null +++ b/tests/src/test-lib/eslint-compat.ts @@ -0,0 +1,8 @@ +import { getRuleTester } from "eslint-compat-utils/rule-tester"; +import { getLegacyESLint } from "eslint-compat-utils/eslint"; + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Class name +export const RuleTester = getRuleTester(); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Class name +export const LegacyESLint = getLegacyESLint(); diff --git a/tests/utils/utils.ts b/tests/utils/utils.ts index 8cd20441..30923398 100644 --- a/tests/utils/utils.ts +++ b/tests/utils/utils.ts @@ -195,11 +195,15 @@ function writeFixtures( rules: { [ruleName]: ["error", ...(config.options || [])], }, - parser: isToml(inputFile) ? "toml-eslint-parser" : "vue-eslint-parser", + ...({ + languageOptions: { + parser: isToml(inputFile) ? tomlESLintParser : vueESLintParser, + parserOptions: { tomlVersion: "next" }, + }, + } as any), settings: { toml: { indent: 8 }, }, - parserOptions: { tomlVersion: "next" }, }, config.filename, ); @@ -272,7 +276,7 @@ function getConfig(ruleName: string, inputFile: string) { ? `# ${filename}\n${code0}` : `\n${code0}`; return Object.assign( - isVue(inputFile) ? { parser: require.resolve("vue-eslint-parser") } : {}, + isVue(inputFile) ? { languageOptions: { parser: vueESLintParser } } : {}, config, { code, filename }, ); @@ -296,7 +300,7 @@ function getConfig(ruleName: string, inputFile: string) { } return Object.assign( - isVue(inputFile) ? { parser: require.resolve("vue-eslint-parser") } : {}, + isVue(inputFile) ? { languageOptions: { parser: vueESLintParser } } : {}, config, { code, filename }, ); diff --git a/tools/new-rule.ts b/tools/new-rule.ts index 76f72bb9..4a4ef986 100644 --- a/tools/new-rule.ts +++ b/tools/new-rule.ts @@ -65,15 +65,18 @@ export default createRule("${ruleId}", { ); fs.writeFileSync( testFile, - `import { RuleTester } from "eslint" + `import { RuleTester } from "../test-lib/eslint-compat" import rule from "../../../src/rules/${ruleId}" import { loadTestCases } from "../../utils/utils" +import * as tomlParser from "toml-eslint-parser"; const tester = new RuleTester({ - parser: require.resolve("toml-eslint-parser"), + languageOptions: { + parser: tomlParser, parserOptions: { - tomlVersion: "next", + tomlVersion: "next", }, + }, }) tester.run("${ruleId}", rule as any, loadTestCases("${ruleId}")) diff --git a/tsconfig.json b/tsconfig.json index 73fa59d1..39ead25e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es2015", - "module": "commonjs", + "module": "node16", "lib": ["es2020"], "allowJs": true, "checkJs": true,