diff --git a/.changeset/great-ravens-happen.md b/.changeset/great-ravens-happen.md new file mode 100644 index 000000000..eea070fd5 --- /dev/null +++ b/.changeset/great-ravens-happen.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-vue": minor +--- + +Added [`@stylistic/eslint-plugin`](https://eslint.style/) as optional peer dependency diff --git a/.changeset/purple-lights-invite.md b/.changeset/purple-lights-invite.md new file mode 100644 index 000000000..80aa90b8d --- /dev/null +++ b/.changeset/purple-lights-invite.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-vue': minor +--- + +Added `ignorePattern` option to [`vue/no-v-html`](https://eslint.vuejs.org/rules/no-v-html.html) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 90bd33ad5..fede1a47a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -31,12 +31,6 @@ jobs: strategy: matrix: node: [18, 20, 21, 'lts/*'] - eslint: [9] - include: - # On old ESLint version - - node: 18 - eslint: 8 - runs-on: ubuntu-latest steps: - name: Checkout @@ -47,8 +41,23 @@ jobs: node-version: ${{ matrix.node }} - name: Install Packages run: npm install - - name: Install ESLint v${{ matrix.eslint }} - run: npm install --save-dev eslint@${{ matrix.eslint }} -f + - name: Test + run: npm test + + test-with-eslint-v8: + name: Test with ESLint v8 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js v18 + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install Packages + run: npm install + - name: Install ESLint v8 + run: npm install --save-dev eslint@8 --force - name: Test run: npm test @@ -63,7 +72,25 @@ jobs: - name: Install Packages run: npm install - name: Uninstall @stylistic/eslint-plugin - run: npm uninstall -D @stylistic/eslint-plugin + run: npm uninstall @stylistic/eslint-plugin + - name: Test + run: npm test + + test-with-old-eslint-stylistic: + name: Test with old ESLint Stylistic + strategy: + matrix: + stylistic: [2, 3, 4] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install + - name: Install @stylistic/eslint-plugin v${{ matrix.stylistic }} + run: npm install -D @stylistic/eslint-plugin@${{ matrix.stylistic }} --force - name: Test run: npm test @@ -77,7 +104,7 @@ jobs: uses: actions/setup-node@v4 - name: Install Packages run: npm install - - name: Install @typescript-eslint/parser@7 - run: npm install -D @typescript-eslint/parser@7 -f + - name: Install @typescript-eslint/parser v7 + run: npm install -D @typescript-eslint/parser@7 --force - name: Test run: npm test diff --git a/.vscode/settings.json b/.vscode/settings.json index f80681b66..8c7be0b23 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,6 @@ { "editor.tabSize": 2, - "eslint.experimental.useFlatConfig": true, - "eslint.validate": ["javascript", "javascriptreact", "vue", "json", "jsonc"], + "eslint.validate": ["javascript", "javascriptreact", "vue", "json", "jsonc", "markdown"], "typescript.tsdk": "./node_modules/typescript/lib", "vetur.validation.script": false, "[typescript]": { diff --git a/CHANGELOG.md b/CHANGELOG.md index fa7a29427..71932ee19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ ### Patch Changes -- Resolved TypeScript compatibility issues introduced by eslint-typegen ([#2790](https://github.com/vuejs/eslint-plugin-vue/pull/2790)) +- Resolved TypeScript compatibility issues introduced by [eslint-typegen](https://github.com/antfu/eslint-typegen) ([#2790](https://github.com/vuejs/eslint-plugin-vue/pull/2790)) - Fixed inconsistent quotes in [`vue/block-lang`](https://eslint.vuejs.org/rules/block-lang.html) error messages ([#2805](https://github.com/vuejs/eslint-plugin-vue/pull/2805)) diff --git a/README.md b/README.md index bdeb5e167..01bc6b687 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ Contributing is welcome! See the [ESLint Vue Plugin Developer Guide](https://esl Be sure to read the [official ESLint guide](https://eslint.org/docs/developer-guide/working-with-rules) before you start writing a new rule. -To see what an abstract syntax tree (AST) of your code looks like, you may use [AST Explorer](https://astexplorer.net). After opening [AST Explorer](https://astexplorer.net), select `Vue` as the syntax and `vue-eslint-parser` as the parser. +To see what an abstract syntax tree (AST) of your code looks like, you may use [AST Explorer](https://astexplorer.net). After opening [AST Explorer](https://astexplorer.net), select `Vue` as the syntax and [`vue-eslint-parser`](https://github.com/vuejs/vue-eslint-parser) as the parser. The default JavaScript parser must be replaced because [Vue.js single file components](https://vuejs.org/guide/scaling-up/sfc.html) are not plain JavaScript, but a custom file format. [`vue-eslint-parser`](https://github.com/vuejs/vue-eslint-parser) is a replacement parser that generates an enhanced AST with nodes that represent specific parts of the template syntax, as well as the contents of the ` `, - errors: ['Set "inheritAttrs" to false.'] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 2, + column: 37, + endLine: 2, + endColumn: 43 + } + ] }, { filename: 'test.vue', @@ -184,7 +200,10 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { errors: [ { message: 'Set "inheritAttrs" to false.', - line: 7 + line: 7, + column: 30, + endLine: 7, + endColumn: 36 } ] }, @@ -199,7 +218,10 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { errors: [ { message: 'Set "inheritAttrs" to false.', - line: 5 + line: 5, + column: 30, + endLine: 5, + endColumn: 36 } ] }, @@ -207,7 +229,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { filename: 'test.vue', code: ``, options: [{ checkMultiRootNodes: true }], - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 1, + column: 24, + endLine: 1, + endColumn: 30 + } + ] }, { filename: 'test.vue', @@ -219,7 +249,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { `, options: [{ checkMultiRootNodes: true }], - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] }, // condition group as a single root node { @@ -231,7 +269,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
`, - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] }, { filename: 'test.vue', @@ -243,7 +289,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
`, - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] }, { filename: 'test.vue', @@ -253,7 +307,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
`, - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] }, { filename: 'test.vue', @@ -262,7 +324,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, {
`, - errors: [{ message: 'Set "inheritAttrs" to false.' }] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] } ] }) diff --git a/tests/lib/rules/no-duplicate-attributes.js b/tests/lib/rules/no-duplicate-attributes.js index ddb82db16..48dedf509 100644 --- a/tests/lib/rules/no-duplicate-attributes.js +++ b/tests/lib/rules/no-duplicate-attributes.js @@ -62,36 +62,84 @@ tester.run('no-duplicate-attributes', rule, { { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'foo'."] + errors: [ + { + message: "Duplicate attribute 'foo'.", + line: 1, + column: 25, + endLine: 1, + endColumn: 35 + } + ] }, { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'foo'."] + errors: [ + { + message: "Duplicate attribute 'foo'.", + line: 1, + column: 25, + endLine: 1, + endColumn: 29 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistStyle: false }], - errors: ["Duplicate attribute 'style'."] + errors: [ + { + message: "Duplicate attribute 'style'.", + line: 1, + column: 27, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistClass: false }], - errors: ["Duplicate attribute 'class'."] + errors: [ + { + message: "Duplicate attribute 'class'.", + line: 1, + column: 27, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistStyle: false }], - errors: ["Duplicate attribute 'style'."] + errors: [ + { + message: "Duplicate attribute 'style'.", + line: 1, + column: 28, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistClass: false }], - errors: ["Duplicate attribute 'class'."] + errors: [ + { + message: "Duplicate attribute 'class'.", + line: 1, + column: 28, + endLine: 1, + endColumn: 33 + } + ] } ] }) diff --git a/tests/lib/rules/no-empty-component-block.js b/tests/lib/rules/no-empty-component-block.js index 0a014099a..87ad2dd66 100644 --- a/tests/lib/rules/no-empty-component-block.js +++ b/tests/lib/rules/no-empty-component-block.js @@ -30,7 +30,11 @@ tester.run('no-empty-component-block', rule, { output: '', errors: [ { - message: '`