diff --git a/.vscode/launch.json b/.vscode/launch.json index 2fa4db9b2..171c80066 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,9 +5,17 @@ "type": "node", "request": "launch", "name": "Start testing", - "program": "${workspaceFolder}/node_modules/.bin/mocha", - "args": ["${file}", "--watch"], + "program": "${workspaceFolder}/node_modules/.bin/vitest", + "args": ["run", "${file}", "--reporter=verbose"], + "console": "integratedTerminal" + }, + { + "type": "node", + "request": "launch", + "name": "Start testing (watch)", + "program": "${workspaceFolder}/node_modules/.bin/vitest", + "args": ["${file}", "--reporter=verbose"], "console": "integratedTerminal" } ] -} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d48439d99..fa7a29427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # eslint-plugin-vue +## 10.4.0 + +### Minor Changes + +- Added `ignoreParents` option to [`vue/no-deprecated-slot-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-attribute.html) ([#2784](https://github.com/vuejs/eslint-plugin-vue/pull/2784)) + +- Added new [`vue/no-negated-v-if-condition`](https://eslint.vuejs.org/rules/no-negated-v-if-condition.html) rule ([#2794](https://github.com/vuejs/eslint-plugin-vue/pull/2794)) + +- Added new [`vue/no-negated-condition`](https://eslint.vuejs.org/rules/no-negated-condition.html) rule ([#2795](https://github.com/vuejs/eslint-plugin-vue/pull/2795)) + +### Patch Changes + +- Resolved TypeScript compatibility issues introduced by 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)) + ## 10.3.0 ### Minor Changes diff --git a/docs/developer-guide/index.md b/docs/developer-guide/index.md index 2e1bb7da9..9bfc68007 100644 --- a/docs/developer-guide/index.md +++ b/docs/developer-guide/index.md @@ -8,6 +8,15 @@ If you think you’ve found a bug in ESLint, please [create a new issue](https:/ Please include as much detail as possible to help us properly address your issue. If we need to triage issues and constantly ask people for more detail, that’s time taken away from actually fixing issues. Help us be as efficient as possible by including a lot of detail in your issues. +## :seedling: Project Setup + +To develop locally, fork the eslint-plugin-vue repository and clone it in your local machine. Use the [npm](https://www.npmjs.com/) package manager to install and link dependencies and the LTS version of [Node.js](https://nodejs.org/). + +To develop and test the `eslint-plugin-vue` package: + +1. Run `npm install` in the project's root folder. +2. Run `npm test` to make sure everything is set up correctly. + ## :sparkles: Proposing a new rule or a rule change In order to add a new rule or a rule change, you should: diff --git a/docs/rules/index.md b/docs/rules/index.md index 6423ef365..26542db38 100644 --- a/docs/rules/index.md +++ b/docs/rules/index.md @@ -237,6 +237,7 @@ For example: | [vue/no-empty-component-block] | disallow the ` `, errors: [ - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 4, + column: 18, + endLine: 4, + endColumn: 18 + } ] }, { @@ -219,8 +240,22 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.', - 'Expected no line breaks before closing bracket, but 2 line breaks found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 3, + column: 15, + endLine: 4, + endColumn: 11 + }, + { + message: + 'Expected no line breaks before closing bracket, but 2 line breaks found.', + line: 4, + column: 17, + endLine: 6, + endColumn: 11 + } ] }, { @@ -246,7 +281,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 4, + column: 18, + endLine: 5, + endColumn: 13 + } ] }, { @@ -272,7 +314,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 4, + column: 18, + endLine: 4, + endColumn: 18 + } ] }, { @@ -297,8 +346,22 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.', - 'Expected no line breaks before closing bracket, but 1 line break found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 3, + column: 21, + endLine: 4, + endColumn: 11 + }, + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 5, + column: 16, + endLine: 6, + endColumn: 11 + } ] }, { @@ -329,8 +392,22 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.', - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 5, + column: 18, + endLine: 6, + endColumn: 13 + }, + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 7, + column: 16, + endLine: 7, + endColumn: 16 + } ] }, { @@ -359,8 +436,22 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected 1 line break before closing bracket, but no line breaks found.', - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 4, + column: 21, + endLine: 4, + endColumn: 21 + }, + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 5, + column: 16, + endLine: 5, + endColumn: 16 + } ] }, { @@ -474,42 +565,48 @@ tester.run('html-closing-bracket-newline', rule, { 'Expected 1 line break before closing bracket, but no line breaks found.', line: 2, column: 18, - endColumn: 18 + endColumn: 18, + endLine: 2 }, { message: 'Expected 1 line break before closing bracket, but no line breaks found.', line: 3, column: 19, - endColumn: 19 + endColumn: 19, + endLine: 3 }, { message: 'Expected 1 line break before closing bracket, but no line breaks found.', line: 4, column: 16, - endColumn: 16 + endColumn: 16, + endLine: 4 }, { message: 'Expected 1 line break before closing bracket, but no line breaks found.', line: 5, column: 17, - endColumn: 17 + endColumn: 17, + endLine: 5 }, { message: 'Expected 1 line break before closing bracket, but no line breaks found.', line: 6, column: 15, - endColumn: 15 + endColumn: 15, + endLine: 6 }, { message: 'Expected 1 line break before closing bracket, but no line breaks found.', line: 6, column: 23, - endColumn: 23 + endColumn: 23, + endLine: 6 } ] }, @@ -534,7 +631,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 3, + column: 18, + endLine: 4, + endColumn: 11 + } ] }, { @@ -560,7 +664,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 4, + column: 23, + endLine: 4, + endColumn: 23 + } ] }, { @@ -584,7 +695,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected 1 line break before closing bracket, but no line breaks found.' + { + message: + 'Expected 1 line break before closing bracket, but no line breaks found.', + line: 3, + column: 29, + endLine: 3, + endColumn: 29 + } ] }, { @@ -610,7 +728,14 @@ tester.run('html-closing-bracket-newline', rule, { } ], errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.' + { + message: + 'Expected no line breaks before closing bracket, but 1 line break found.', + line: 4, + column: 23, + endLine: 5, + endColumn: 11 + } ] } ] diff --git a/tests/lib/rules/html-closing-bracket-spacing.js b/tests/lib/rules/html-closing-bracket-spacing.js index 09e2702e0..26139b225 100644 --- a/tests/lib/rules/html-closing-bracket-spacing.js +++ b/tests/lib/rules/html-closing-bracket-spacing.js @@ -50,19 +50,22 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected no space before '>', but found.", line: 2, column: 7, - endColumn: 9 + endColumn: 9, + endLine: 2 }, { message: "Expected no space before '>', but found.", line: 3, column: 8, - endColumn: 10 + endColumn: 10, + endLine: 3 }, { message: "Expected a space before '/>', but not found.", line: 4, column: 7, - endColumn: 9 + endColumn: 9, + endLine: 4 } ] }, @@ -74,13 +77,15 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected no space before '>', but found.", line: 2, column: 11, - endColumn: 13 + endColumn: 13, + endLine: 2 }, { message: "Expected a space before '/>', but not found.", line: 3, column: 11, - endColumn: 13 + endColumn: 13, + endLine: 3 } ] }, @@ -93,13 +98,15 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected no space before '>', but found.", line: 2, column: 15, - endColumn: 17 + endColumn: 17, + endLine: 2 }, { message: "Expected a space before '/>', but not found.", line: 3, column: 15, - endColumn: 17 + endColumn: 17, + endLine: 3 } ] }, @@ -119,37 +126,43 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected no space before '>', but found.", line: 2, column: 18, - endColumn: 20 + endColumn: 20, + endLine: 2 }, { message: "Expected no space before '>', but found.", line: 2, column: 30, - endColumn: 32 + endColumn: 32, + endLine: 2 }, { message: "Expected no space before '>', but found.", line: 3, column: 16, - endColumn: 18 + endColumn: 18, + endLine: 3 }, { message: "Expected no space before '>', but found.", line: 3, column: 26, - endColumn: 28 + endColumn: 28, + endLine: 3 }, { message: "Expected no space before '>', but found.", line: 4, column: 15, - endColumn: 17 + endColumn: 17, + endLine: 4 }, { message: "Expected no space before '>', but found.", line: 4, column: 24, - endColumn: 26 + endColumn: 26, + endLine: 4 } ] }, @@ -168,19 +181,22 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected a space before '>', but not found.", line: 2, column: 7, - endColumn: 8 + endColumn: 8, + endLine: 2 }, { message: "Expected a space before '>', but not found.", line: 3, column: 8, - endColumn: 9 + endColumn: 9, + endLine: 3 }, { message: "Expected no space before '/>', but found.", line: 4, column: 7, - endColumn: 10 + endColumn: 10, + endLine: 4 } ] }, @@ -207,37 +223,43 @@ ruleTester.run('html-closing-bracket-spacing', rule, { message: "Expected a space before '>', but not found.", line: 2, column: 18, - endColumn: 19 + endColumn: 19, + endLine: 2 }, { message: "Expected a space before '>', but not found.", line: 2, column: 29, - endColumn: 30 + endColumn: 30, + endLine: 2 }, { message: "Expected a space before '>', but not found.", line: 3, column: 16, - endColumn: 17 + endColumn: 17, + endLine: 3 }, { message: "Expected a space before '>', but not found.", line: 3, column: 25, - endColumn: 26 + endColumn: 26, + endLine: 3 }, { message: "Expected a space before '>', but not found.", line: 4, column: 15, - endColumn: 16 + endColumn: 16, + endLine: 4 }, { message: "Expected a space before '>', but not found.", line: 4, column: 23, - endColumn: 24 + endColumn: 24, + endLine: 4 } ] } diff --git a/tests/lib/rules/html-comment-content-newline.js b/tests/lib/rules/html-comment-content-newline.js index 362e27adf..6d1c28279 100644 --- a/tests/lib/rules/html-comment-content-newline.js +++ b/tests/lib/rules/html-comment-content-newline.js @@ -264,13 +264,15 @@ tester.run('html-comment-content-newline', rule, { message: "Expected line break after ''.", line: 7, column: 20, - endColumn: 21 + endColumn: 21, + endLine: 7 } ] }, @@ -293,25 +295,29 @@ tester.run('html-comment-content-newline', rule, { message: "Expected line break after ''.", line: 3, column: 22, - endColumn: 22 + endColumn: 22, + endLine: 3 }, { message: "Expected line break after ''.", line: 4, column: 24, - endColumn: 26 + endColumn: 26, + endLine: 4 } ] }, @@ -363,13 +369,15 @@ comment message: "Expected line break after ''.", line: 3, column: 30, - endColumn: 38 + endColumn: 38, + endLine: 3 } ] }, @@ -383,8 +391,20 @@ comment output: null, options: ['always', { exceptions: ['+'] }], errors: [ - 'Expected line break after exception block.', - 'Expected line break before exception block.' + { + message: 'Expected line break after exception block.', + line: 3, + column: 31, + endLine: 3, + endColumn: 31 + }, + { + message: 'Expected line break before exception block.', + line: 3, + column: 38, + endLine: 3, + endColumn: 38 + } ] }, { @@ -396,8 +416,20 @@ comment output: null, options: ['always', { exceptions: ['*'] }], errors: [ - 'Expected line break after exception block.', - 'Expected line break before exception block.' + { + message: 'Expected line break after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, + { + message: 'Expected line break before exception block.', + line: 3, + column: 27, + endLine: 3, + endColumn: 27 + } ] }, { @@ -413,8 +445,20 @@ comment `, options: ['always', { exceptions: ['#+#-'] }], errors: [ - 'Expected line break after exception block.', - "Expected line break before '-->'." + { + message: 'Expected line break after exception block.', + line: 3, + column: 27, + endLine: 3, + endColumn: 27 + }, + { + message: "Expected line break before '-->'.", + line: 3, + column: 38, + endLine: 3, + endColumn: 38 + } ] }, { @@ -426,11 +470,19 @@ comment output: null, options: ['always', { exceptions: ['*', '++'] }], errors: [ - 'Expected line break after exception block.', + { + message: 'Expected line break after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, { message: 'Expected line break before exception block.', line: 3, - column: 27 + column: 27, + endLine: 3, + endColumn: 27 } ] }, @@ -443,11 +495,19 @@ comment output: null, options: ['always', { exceptions: ['*', '++'] }], errors: [ - 'Expected line break after exception block.', + { + message: 'Expected line break after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, { message: 'Expected line break before exception block.', line: 3, - column: 28 + column: 28, + endLine: 3, + endColumn: 28 } ] } diff --git a/tests/lib/rules/html-comment-content-spacing.js b/tests/lib/rules/html-comment-content-spacing.js index 1036555e8..754271d10 100644 --- a/tests/lib/rules/html-comment-content-spacing.js +++ b/tests/lib/rules/html-comment-content-spacing.js @@ -207,13 +207,15 @@ tester.run('html-comment-content-spacing', rule, { message: "Expected space after ''.", line: 3, column: 22, - endColumn: 22 + endColumn: 22, + endLine: 3 } ] }, @@ -234,13 +236,15 @@ tester.run('html-comment-content-spacing', rule, { message: "Unexpected space after ''.", line: 3, column: 23, - endColumn: 24 + endColumn: 24, + endLine: 3 } ] }, @@ -261,13 +265,15 @@ tester.run('html-comment-content-spacing', rule, { message: "Unexpected space after ''.", line: 3, column: 30, - endColumn: 38 + endColumn: 38, + endLine: 3 } ] }, @@ -281,8 +287,20 @@ tester.run('html-comment-content-spacing', rule, { output: null, options: ['always', { exceptions: ['+'] }], errors: [ - 'Expected space after exception block.', - 'Expected space before exception block.' + { + message: 'Expected space after exception block.', + line: 3, + column: 31, + endLine: 3, + endColumn: 31 + }, + { + message: 'Expected space before exception block.', + line: 3, + column: 38, + endLine: 3, + endColumn: 38 + } ] }, { @@ -294,8 +312,20 @@ tester.run('html-comment-content-spacing', rule, { output: null, options: ['always', { exceptions: ['*'] }], errors: [ - 'Expected space after exception block.', - 'Expected space before exception block.' + { + message: 'Expected space after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, + { + message: 'Expected space before exception block.', + line: 3, + column: 27, + endLine: 3, + endColumn: 27 + } ] }, { @@ -311,8 +341,20 @@ tester.run('html-comment-content-spacing', rule, { `, options: ['always', { exceptions: ['#+#-'] }], errors: [ - 'Expected space after exception block.', - "Expected space before '-->'." + { + message: 'Expected space after exception block.', + line: 3, + column: 27, + endLine: 3, + endColumn: 27 + }, + { + message: "Expected space before '-->'.", + line: 3, + column: 38, + endLine: 3, + endColumn: 38 + } ] }, { @@ -324,11 +366,19 @@ tester.run('html-comment-content-spacing', rule, { output: null, options: ['always', { exceptions: ['*', '++'] }], errors: [ - 'Expected space after exception block.', + { + message: 'Expected space after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, { message: 'Expected space before exception block.', line: 3, - column: 27 + column: 27, + endLine: 3, + endColumn: 27 } ] }, @@ -341,11 +391,19 @@ tester.run('html-comment-content-spacing', rule, { output: null, options: ['always', { exceptions: ['*', '++'] }], errors: [ - 'Expected space after exception block.', + { + message: 'Expected space after exception block.', + line: 3, + column: 20, + endLine: 3, + endColumn: 20 + }, { message: 'Expected space before exception block.', line: 3, - column: 28 + column: 28, + endLine: 3, + endColumn: 28 } ] } diff --git a/tests/lib/rules/html-comment-indent.js b/tests/lib/rules/html-comment-indent.js index 27c93af8e..f90f2cf4c 100644 --- a/tests/lib/rules/html-comment-indent.js +++ b/tests/lib/rules/html-comment-indent.js @@ -504,22 +504,34 @@ tester.run('html-comment-indent', rule, { { message: 'Expected relative indentation of 2 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 11 }, { message: 'Expected relative indentation of 2 spaces but found 4 spaces.', - line: 7 + line: 7, + column: 11, + endLine: 7, + endColumn: 15 }, { message: 'Expected relative indentation of 0 spaces but found 2 spaces.', - line: 12 + line: 12, + column: 11, + endLine: 12, + endColumn: 13 }, { message: 'Expected base point indentation of 10 spaces, but found 8 spaces.', - line: 14 + line: 14, + column: 1, + endLine: 14, + endColumn: 9 } ] }, @@ -544,12 +556,18 @@ tester.run('html-comment-indent', rule, { { message: 'Expected relative indentation of 2 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 11, + endLine: 4, + endColumn: 11 }, { message: 'Expected relative indentation of 2 spaces but found 4 spaces.', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 15 } ] }, @@ -575,15 +593,24 @@ comment --> errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected indentation of 0 spaces but found 2 spaces.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 3 } ] }, @@ -610,17 +637,26 @@ comment --> { message: 'Expected base point indentation of 2 spaces, but not found.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected base point indentation of 2 spaces, but not found.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected base point indentation of 2 spaces, but not found.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 1 } ] }, @@ -643,12 +679,18 @@ comment --> { message: 'Expected relative indentation of 2 spaces but found 1 space.', - line: 4 + line: 4, + column: 11, + endLine: 4, + endColumn: 12 }, { message: 'Expected relative indentation of 0 spaces but found 1 space.', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 12 } ] }, @@ -670,11 +712,17 @@ comment --> errors: [ { message: String.raw`Expected base point indentation of " \t \t \t ", but found 7 spaces.`, - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 13 }, { message: String.raw`Expected base point indentation of " \t \t \t ", but found 7 spaces.`, - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 11 } ] } diff --git a/tests/lib/rules/html-end-tags.js b/tests/lib/rules/html-end-tags.js index ce5979632..42e13dc99 100644 --- a/tests/lib/rules/html-end-tags.js +++ b/tests/lib/rules/html-end-tags.js @@ -80,13 +80,29 @@ tester.run('html-end-tags', rule, { filename: 'test.vue', code: '', output: '', - errors: ["'
' should have end tag."] + errors: [ + { + message: "'
' should have end tag.", + line: 1, + column: 11, + endLine: 1, + endColumn: 16 + } + ] }, { filename: 'test.vue', code: '', output: '', - errors: ["'

' should have end tag."] + errors: [ + { + message: "'

' should have end tag.", + line: 1, + column: 16, + endLine: 1, + endColumn: 19 + } + ] } ] }) diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js index 3a4c610cd..78c233f51 100644 --- a/tests/lib/rules/html-indent.js +++ b/tests/lib/rules/html-indent.js @@ -63,7 +63,10 @@ function loadPatterns(additionalValid, additionalInvalid) { message: `Expected indentation of ${line.indentSize} ${kind}${ line.indentSize === 1 ? '' : 's' } but found 0 ${kind}s.`, - line: line.number + 1 + line: line.number + 1, + column: 1, + endLine: line.number + 1, + endColumn: 1 } ) .filter(Boolean) @@ -447,7 +450,10 @@ tester.run( errors: [ { message: 'Expected indentation of 12 spaces but found 10 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 11 } ] }, @@ -472,7 +478,10 @@ tester.run( errors: [ { message: String.raw`Expected " " character, but found "\t" character.`, - line: 3 + line: 3, + column: 3, + endLine: 3, + endColumn: 4 } ] }, @@ -496,7 +505,10 @@ tester.run( errors: [ { message: String.raw`Expected "\t" character, but found " " character.`, - line: 3 + line: 3, + column: 2, + endLine: 3, + endColumn: 3 } ] }, @@ -527,27 +539,45 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 1 } ] }, @@ -576,11 +606,17 @@ tester.run( errors: [ { message: 'Expected indentation of 4 spaces but found 2 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 3 }, { message: 'Expected indentation of 4 spaces but found 2 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 3 } ] }, @@ -609,23 +645,38 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 1 } ] }, @@ -654,19 +705,31 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 1 } ] }, @@ -699,7 +762,10 @@ tester.run( errors: [ { message: 'Expected indentation of 4 spaces but found 8 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 9 } ] }, @@ -735,15 +801,24 @@ tester.run( errors: [ { message: 'Expected indentation of 8 spaces but found 6 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 7 }, { message: 'Expected indentation of 12 spaces but found 8 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 9 }, { message: 'Expected indentation of 12 spaces but found 8 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 9 } ] }, @@ -776,15 +851,24 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 } ] }, @@ -823,31 +907,52 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 8 + line: 8, + column: 1, + endLine: 8, + endColumn: 1 } ] }, @@ -886,31 +991,52 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 3 + line: 3, + column: 1, + endLine: 3, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 4 + line: 4, + column: 1, + endLine: 4, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 5 + line: 5, + column: 1, + endLine: 5, + endColumn: 1 }, { message: 'Expected indentation of 6 spaces but found 0 spaces.', - line: 6 + line: 6, + column: 1, + endLine: 6, + endColumn: 1 }, { message: 'Expected indentation of 4 spaces but found 0 spaces.', - line: 7 + line: 7, + column: 1, + endLine: 7, + endColumn: 1 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', - line: 8 + line: 8, + column: 1, + endLine: 8, + endColumn: 1 } ] }, @@ -932,7 +1058,10 @@ tester.run( errors: [ { message: String.raw`Expected "\t" character, but found " " character.`, - line: 2 + line: 2, + column: 2, + endLine: 2, + endColumn: 3 } ] }, @@ -951,7 +1080,10 @@ tester.run( errors: [ { message: 'Expected indentation of 2 spaces but found 4 spaces.', - line: 2 + line: 2, + column: 1, + endLine: 2, + endColumn: 5 } ] } diff --git a/tests/lib/rules/html-quotes.js b/tests/lib/rules/html-quotes.js index 1c57f0a26..f6931f552 100644 --- a/tests/lib/rules/html-quotes.js +++ b/tests/lib/rules/html-quotes.js @@ -82,101 +82,221 @@ tester.run('html-quotes', rule, { filename: 'test.vue', code: '', output: '', - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 25 + } + ] }, { filename: 'test.vue', code: "", output: '', - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 27 + } + ] }, { filename: 'test.vue', code: '', output: '', - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: "", output: '', - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 28 + } + ] }, { filename: 'test.vue', code: '', output: '', - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 32 + } + ] }, { filename: 'test.vue', code: '', output: '', options: ['double'], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 25 + } + ] }, { filename: 'test.vue', code: "", output: '', options: ['double'], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 27 + } + ] }, { filename: 'test.vue', code: '', output: '', options: ['double'], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: "", output: '', options: ['double'], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 28 + } + ] }, { filename: 'test.vue', code: '', output: '', options: ['double'], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 32 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single'], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 25 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single'], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 22, + endLine: 1, + endColumn: 27 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single'], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single'], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 28 + } + ] }, { filename: 'test.vue', code: "", output: "", options: ['single'], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 23, + endLine: 1, + endColumn: 32 + } + ] }, // avoidEscape { @@ -184,42 +304,90 @@ tester.run('html-quotes', rule, { code: "", output: '', options: ['double', { avoidEscape: true }], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single', { avoidEscape: true }], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['double', { avoidEscape: true }], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 28 + } + ] }, { filename: 'test.vue', code: "", output: '', options: ['single', { avoidEscape: true }], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 28 + } + ] }, { filename: 'test.vue', code: '', output: '', options: ['double', { avoidEscape: true }], - errors: ['Expected to be enclosed by double quotes.'] + errors: [ + { + message: 'Expected to be enclosed by double quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 32 + } + ] }, { filename: 'test.vue', code: '', output: "", options: ['single', { avoidEscape: true }], - errors: ['Expected to be enclosed by single quotes.'] + errors: [ + { + message: 'Expected to be enclosed by single quotes.', + line: 1, + column: 21, + endLine: 1, + endColumn: 32 + } + ] } ] }) diff --git a/tests/lib/rules/html-self-closing.js b/tests/lib/rules/html-self-closing.js index 0f0898b53..37991580a 100644 --- a/tests/lib/rules/html-self-closing.js +++ b/tests/lib/rules/html-self-closing.js @@ -90,27 +90,68 @@ tester.run('html-self-closing', rule, { { code: '', output: '', - errors: ['Require self-closing on HTML elements (

).'] + errors: [ + { + message: 'Require self-closing on HTML elements (
).', + line: 1, + column: 16, + endLine: 1, + endColumn: 22 + } + ] }, { code: '', output: '', - errors: ['Disallow self-closing on HTML void elements ().'] + errors: [ + { + message: 'Disallow self-closing on HTML void elements ().', + line: 1, + column: 15, + endLine: 1, + endColumn: 17 + } + ] }, { code: '', output: '', - errors: ['Require self-closing on Vue.js custom components ().'] + errors: [ + { + message: + 'Require self-closing on Vue.js custom components ().', + line: 1, + column: 19, + endLine: 1, + endColumn: 28 + } + ] }, { code: '', output: '', - errors: ['Require self-closing on SVG elements ().'] + errors: [ + { + message: 'Require self-closing on SVG elements ().', + line: 1, + column: 22, + endLine: 1, + endColumn: 29 + } + ] }, { code: '', output: '', - errors: ['Require self-closing on MathML elements ().'] + errors: [ + { + message: 'Require self-closing on MathML elements ().', + line: 1, + column: 25, + endLine: 1, + endColumn: 34 + } + ] }, // others @@ -130,7 +171,13 @@ tester.run('html-self-closing', rule, { `, options: [anyWith({ html: { normal: 'always' } })], errors: [ - { message: 'Require self-closing on HTML elements (
).', line: 2 } + { + message: 'Require self-closing on HTML elements (
).', + line: 2, + column: 8, + endLine: 2, + endColumn: 14 + } ] }, { @@ -149,7 +196,13 @@ tester.run('html-self-closing', rule, { `, options: [anyWith({ html: { normal: 'never' } })], errors: [ - { message: 'Disallow self-closing on HTML elements (
).', line: 3 } + { + message: 'Disallow self-closing on HTML elements (
).', + line: 3, + column: 7, + endLine: 3, + endColumn: 9 + } ] }, { @@ -170,7 +223,10 @@ tester.run('html-self-closing', rule, { errors: [ { message: 'Require self-closing on HTML void elements ().', - line: 4 + line: 4, + column: 3, + endLine: 4, + endColumn: 8 } ] }, @@ -192,7 +248,10 @@ tester.run('html-self-closing', rule, { errors: [ { message: 'Disallow self-closing on HTML void elements ().', - line: 5 + line: 5, + column: 7, + endLine: 5, + endColumn: 9 } ] }, @@ -215,7 +274,10 @@ tester.run('html-self-closing', rule, { { message: 'Require self-closing on Vue.js custom components ().', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 20 } ] }, @@ -238,7 +300,10 @@ tester.run('html-self-closing', rule, { { message: 'Disallow self-closing on Vue.js custom components ().', - line: 7 + line: 7, + column: 10, + endLine: 7, + endColumn: 12 } ] }, @@ -258,7 +323,13 @@ tester.run('html-self-closing', rule, { `, options: [anyWith({ svg: 'always' })], errors: [ - { message: 'Require self-closing on SVG elements ().', line: 8 } + { + message: 'Require self-closing on SVG elements ().', + line: 8, + column: 14, + endLine: 8, + endColumn: 21 + } ] }, { @@ -277,7 +348,13 @@ tester.run('html-self-closing', rule, { `, options: [anyWith({ svg: 'never' })], errors: [ - { message: 'Disallow self-closing on SVG elements ().', line: 9 } + { + message: 'Disallow self-closing on SVG elements ().', + line: 9, + column: 13, + endLine: 9, + endColumn: 15 + } ] }, { @@ -298,7 +375,10 @@ tester.run('html-self-closing', rule, { errors: [ { message: 'Require self-closing on MathML elements ().', - line: 10 + line: 10, + column: 17, + endLine: 10, + endColumn: 26 } ] }, @@ -320,7 +400,10 @@ tester.run('html-self-closing', rule, { errors: [ { message: 'Disallow self-closing on MathML elements ().', - line: 11 + line: 11, + column: 16, + endLine: 11, + endColumn: 18 } ] } diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index 81d907dae..0f7c71146 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -124,7 +124,11 @@ describe('jsx-uses-vars', () => { ` } ] - : null + : null, + line: 3, + column: 16, + endLine: 3, + endColumn: 29 } ] }, @@ -162,7 +166,11 @@ describe('jsx-uses-vars', () => { ` } ] - : null + : null, + line: 4, + column: 15, + endLine: 4, + endColumn: 22 } ] } diff --git a/tests/lib/rules/key-spacing.js b/tests/lib/rules/key-spacing.js index 0e13216dc..c8a5a9ddd 100644 --- a/tests/lib/rules/key-spacing.js +++ b/tests/lib/rules/key-spacing.js @@ -24,8 +24,20 @@ tester.run('key-spacing', rule, { code: '', output: '', errors: [ - "Extra space after key 'a'.", - "Missing space before value for key 'a'." + { + message: "Extra space after key 'a'.", + line: 1, + column: 25, + endLine: 1, + endColumn: 26 + }, + { + message: "Missing space before value for key 'a'.", + line: 1, + column: 27, + endLine: 1, + endColumn: 28 + } ] }, { @@ -33,8 +45,20 @@ tester.run('key-spacing', rule, { output: '', options: [{ beforeColon: true }], errors: [ - "Missing space after key 'a'.", - "Missing space before value for key 'a'." + { + message: "Missing space after key 'a'.", + line: 1, + column: 32, + endLine: 1, + endColumn: 33 + }, + { + message: "Missing space before value for key 'a'.", + line: 1, + column: 34, + endLine: 1, + endColumn: 35 + } ] } ] diff --git a/tests/lib/rules/keyword-spacing.js b/tests/lib/rules/keyword-spacing.js index 3bebe093e..3236a1fa1 100644 --- a/tests/lib/rules/keyword-spacing.js +++ b/tests/lib/rules/keyword-spacing.js @@ -68,23 +68,38 @@ tester.run('keyword-spacing', rule, { errors: [ { message: 'Expected space(s) after "if".', - line: 3 + line: 3, + column: 11, + endLine: 3, + endColumn: 13 }, { message: 'Expected space(s) before "else".', - line: 5 + line: 5, + column: 12, + endLine: 5, + endColumn: 16 }, { message: 'Expected space(s) after "if".', - line: 5 + line: 5, + column: 17, + endLine: 5, + endColumn: 19 }, { message: 'Expected space(s) before "else".', - line: 7 + line: 7, + column: 12, + endLine: 7, + endColumn: 16 }, { message: 'Expected space(s) after "else".', - line: 7 + line: 7, + column: 12, + endLine: 7, + endColumn: 16 } ] }, @@ -115,23 +130,38 @@ tester.run('keyword-spacing', rule, { errors: [ { message: 'Unexpected space(s) after "if".', - line: 3 + line: 3, + column: 13, + endLine: 3, + endColumn: 14 }, { message: 'Unexpected space(s) before "else".', - line: 5 + line: 5, + column: 12, + endLine: 5, + endColumn: 13 }, { message: 'Unexpected space(s) after "if".', - line: 5 + line: 5, + column: 20, + endLine: 5, + endColumn: 21 }, { message: 'Unexpected space(s) before "else".', - line: 7 + line: 7, + column: 12, + endLine: 7, + endColumn: 13 }, { message: 'Unexpected space(s) after "else".', - line: 7 + line: 7, + column: 17, + endLine: 7, + endColumn: 18 } ] }, @@ -145,7 +175,10 @@ tester.run('keyword-spacing', rule, { errors: [ { message: 'Expected space(s) after "return".', - line: 2 + line: 2, + column: 56, + endLine: 2, + endColumn: 62 } ] } diff --git a/tests/lib/rules/match-component-file-name.js b/tests/lib/rules/match-component-file-name.js index a006d2f3c..494c8455a 100644 --- a/tests/lib/rules/match-component-file-name.js +++ b/tests/lib/rules/match-component-file-name.js @@ -596,7 +596,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -624,7 +628,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -652,7 +660,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -680,7 +692,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -717,7 +733,11 @@ ruleTester.run('match-component-file-name', rule, { ` } - ] + ], + line: 4, + column: 19, + endLine: 4, + endColumn: 31 } ] }, @@ -752,7 +772,11 @@ ruleTester.run('match-component-file-name', rule, { ` } - ] + ], + line: 4, + column: 19, + endLine: 4, + endColumn: 31 } ] }, @@ -787,7 +811,11 @@ ruleTester.run('match-component-file-name', rule, { ` } - ] + ], + line: 4, + column: 19, + endLine: 4, + endColumn: 31 } ] }, @@ -817,7 +845,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -845,7 +877,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -873,7 +909,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -899,7 +939,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -925,7 +969,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -951,7 +999,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 29 } ] }, @@ -977,7 +1029,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 2, + column: 23, + endLine: 2, + endColumn: 35 } ] }, @@ -1003,7 +1059,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 2, + column: 23, + endLine: 2, + endColumn: 35 } ] }, @@ -1029,7 +1089,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 2, + column: 23, + endLine: 2, + endColumn: 35 } ] }, @@ -1055,7 +1119,11 @@ ruleTester.run('match-component-file-name', rule, { }) ` } - ] + ], + line: 2, + column: 23, + endLine: 2, + endColumn: 35 } ] }, @@ -1085,7 +1153,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 31 } ] }, @@ -1113,7 +1185,11 @@ ruleTester.run('match-component-file-name', rule, { } ` } - ] + ], + line: 3, + column: 17, + endLine: 3, + endColumn: 30 } ] }, @@ -1134,7 +1210,11 @@ ruleTester.run('match-component-file-name', rule, { desc: 'Rename component to match file name.', output: `` } - ] + ], + line: 1, + column: 37, + endLine: 1, + endColumn: 52 } ] } diff --git a/tests/lib/rules/match-component-import-name.js b/tests/lib/rules/match-component-import-name.js index a6ca5da07..be6f0a1aa 100644 --- a/tests/lib/rules/match-component-import-name.js +++ b/tests/lib/rules/match-component-import-name.js @@ -65,7 +65,9 @@ tester.run('match-component-import-name', rule, { message: 'Component alias InvalidExport should be one of: SomeRandomName, some-random-name.', line: 2, - column: 47 + column: 47, + endLine: 2, + endColumn: 76 } ] } diff --git a/tests/lib/rules/max-attributes-per-line.js b/tests/lib/rules/max-attributes-per-line.js index 7440b05cf..5b88f7857 100644 --- a/tests/lib/rules/max-attributes-per-line.js +++ b/tests/lib/rules/max-attributes-per-line.js @@ -44,43 +44,99 @@ ruleTester.run('max-attributes-per-line', rule, { code: ``, output: ``, - errors: ["'age' should be on a new line."] + errors: [ + { + message: "'age' should be on a new line.", + line: 1, + column: 38, + endLine: 1, + endColumn: 46 + } + ] }, { code: ``, output: ``, - errors: ["':age' should be on a new line."] + errors: [ + { + message: "':age' should be on a new line.", + line: 1, + column: 40, + endLine: 1, + endColumn: 55 + } + ] }, { code: ``, output: ``, - errors: ["'v-bind' should be on a new line."] + errors: [ + { + message: "'v-bind' should be on a new line.", + line: 1, + column: 33, + endLine: 1, + endColumn: 46 + } + ] }, { code: ``, output: ``, - errors: ["'@buy' should be on a new line."] + errors: [ + { + message: "'@buy' should be on a new line.", + line: 1, + column: 40, + endLine: 1, + endColumn: 57 + } + ] }, { code: ``, output: ``, - errors: ["'@click.stop' should be on a new line."] + errors: [ + { + message: "'@click.stop' should be on a new line.", + line: 1, + column: 40, + endLine: 1, + endColumn: 51 + } + ] }, { code: ``, output: ``, - errors: ["'v-if' should be on a new line."] + errors: [ + { + message: "'v-if' should be on a new line.", + line: 1, + column: 40, + endLine: 1, + endColumn: 56 + } + ] }, { code: ``, output: ``, - errors: ["'v-bind:age' should be on a new line."] + errors: [ + { + message: "'v-bind:age' should be on a new line.", + line: 1, + column: 41, + endLine: 1, + endColumn: 62 + } + ] }, { code: ``, @@ -91,7 +147,10 @@ job="Vet">`, { message: "'job' should be on a new line.", type: 'VAttribute', - line: 1 + line: 1, + column: 47, + endLine: 1, + endColumn: 56 } ] }, @@ -112,7 +171,10 @@ age="30" { message: "'age' should be on a new line.", type: 'VAttribute', - line: 2 + line: 2, + column: 25, + endLine: 2, + endColumn: 33 } ] }, @@ -133,7 +195,10 @@ age="30" { message: "'age' should be on a new line.", type: 'VAttribute', - line: 2 + line: 2, + column: 25, + endLine: 2, + endColumn: 33 } ] } diff --git a/tests/lib/rules/max-len.js b/tests/lib/rules/max-len.js index ac634ff75..d2df6e62a 100644 --- a/tests/lib/rules/max-len.js +++ b/tests/lib/rules/max-len.js @@ -311,11 +311,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -328,11 +330,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -346,11 +350,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 121. Maximum allowed is 120.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 121. Maximum allowed is 120.', - line: 3 + line: 3, + column: 1 } ] }, @@ -364,11 +370,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 121. Maximum allowed is 120.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -381,7 +389,8 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 121. Maximum allowed is 120.', - line: 2 + line: 2, + column: 1 } ] }, @@ -394,7 +403,8 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 121. Maximum allowed is 120.', - line: 2 + line: 2, + column: 1 } ] }, @@ -417,15 +427,18 @@ export default { name: 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooo errors: [ { message: 'This line has a length of 82. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 84. Maximum allowed is 80.', - line: 5 + line: 5, + column: 1 }, { message: 'This line has a length of 94. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 } ] }, @@ -453,43 +466,53 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 6 + line: 6, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 7 + line: 7, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 9 + line: 9, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 11 + line: 11, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 14 + line: 14, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 15 + line: 15, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 16 + line: 16, + column: 1 } ] }, @@ -516,43 +539,53 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 5 + line: 5, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 11 + line: 11, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 12 + line: 12, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 13 + line: 13, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 14 + line: 14, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 15 + line: 15, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 16 + line: 16, + column: 1 } ] }, @@ -581,7 +614,8 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 } ] }, @@ -609,7 +643,8 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 15 + line: 15, + column: 1 } ] }, @@ -638,19 +673,23 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 16 + line: 16, + column: 1 } ] }, @@ -678,19 +717,23 @@ var b /* comment */ // trailing comments ....................................... errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 5 + line: 5, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 13 + line: 13, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 15 + line: 15, + column: 1 } ] }, @@ -709,11 +752,13 @@ var a = 'https://www.example.com/long/long/long/long/long/long/long/long/long/lo errors: [ { message: 'This line has a length of 89. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 83. Maximum allowed is 80.', - line: 7 + line: 7, + column: 1 } ] }, @@ -731,11 +776,13 @@ var a = 'https://www.example.com/long/long/long/long/long/long/long/long/long/lo errors: [ { message: 'This line has a length of 83. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 89. Maximum allowed is 80.', - line: 6 + line: 6, + column: 1 } ] }, @@ -760,19 +807,23 @@ var a = 'str-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 6 + line: 6, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 13 + line: 13, + column: 1 } ] }, @@ -796,19 +847,23 @@ var a = 'str-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 6 + line: 6, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 9 + line: 9, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 11 + line: 11, + column: 1 } ] }, @@ -834,7 +889,8 @@ var a = 'str-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -859,7 +915,8 @@ var a = 'str-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 6 + line: 6, + column: 1 } ] }, @@ -882,19 +939,23 @@ var b = \`template-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooon errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 5 + line: 5, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 11 + line: 11, + column: 1 } ] }, @@ -916,19 +977,23 @@ var b = \`template-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooon errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 9 + line: 9, + column: 1 } ] }, @@ -952,11 +1017,13 @@ var b = \`template-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooon errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 10 + line: 10, + column: 1 } ] }, @@ -979,11 +1046,13 @@ var b = \`template-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooon errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 8 + line: 8, + column: 1 } ] }, @@ -1004,11 +1073,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 9 + line: 9, + column: 1 } ] }, @@ -1028,11 +1099,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 7 + line: 7, + column: 1 } ] }, @@ -1048,7 +1121,8 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -1066,11 +1140,13 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a length of 88. Maximum allowed is 80.', - line: 5 + line: 5, + column: 1 } ] }, @@ -1079,32 +1155,62 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b filename: 'test.vue', code: ``, options: [40], - errors: ['This line has a length of 41. Maximum allowed is 40.'] + errors: [ + { + message: 'This line has a length of 41. Maximum allowed is 40.', + line: 1, + column: 1 + } + ] }, { filename: 'test.vue', code: ``, options: [{ code: 40 }], - errors: ['This line has a length of 41. Maximum allowed is 40.'] + errors: [ + { + message: 'This line has a length of 41. Maximum allowed is 40.', + line: 1, + column: 1 + } + ] }, // tabWidth { filename: 'test.vue', code: ``, options: [40, 4], - errors: ['This line has a length of 45. Maximum allowed is 40.'] + errors: [ + { + message: 'This line has a length of 45. Maximum allowed is 40.', + line: 1, + column: 1 + } + ] }, { filename: 'test.vue', code: ``, options: [{ code: 40, tabWidth: 4 }], - errors: ['This line has a length of 45. Maximum allowed is 40.'] + errors: [ + { + message: 'This line has a length of 45. Maximum allowed is 40.', + line: 1, + column: 1 + } + ] }, { filename: 'test.vue', code: ``, options: [{ code: 40, tabWidth: 3 }], - errors: ['This line has a length of 44. Maximum allowed is 40.'] + errors: [ + { + message: 'This line has a length of 44. Maximum allowed is 40.', + line: 1, + column: 1 + } + ] }, // comments { @@ -1130,27 +1236,32 @@ var a; // 41 cols comment * { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 4 + line: 4, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 9 + line: 9, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 12 + line: 12, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 13 + line: 13, + column: 1 } ] }, @@ -1166,15 +1277,18 @@ var b = \`81 columns errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 } ] }, @@ -1189,11 +1303,13 @@ var b = \`81 columns errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 4 + line: 4, + column: 1 } ] }, @@ -1208,11 +1324,13 @@ var b = \`81 columns errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a length of 81. Maximum allowed is 80.', - line: 3 + line: 3, + column: 1 } ] }, @@ -1230,17 +1348,20 @@ var b = \`81 columns { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 2 + line: 2, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 3 + line: 3, + column: 1 }, { message: 'This line has a comment length of 41. Maximum allowed is 40.', - line: 4 + line: 4, + column: 1 } ] } diff --git a/tests/lib/rules/max-lines-per-block.js b/tests/lib/rules/max-lines-per-block.js index 2470586fb..415e0197f 100644 --- a/tests/lib/rules/max-lines-per-block.js +++ b/tests/lib/rules/max-lines-per-block.js @@ -59,7 +59,9 @@ tester.run('max-lines-per-block', rule, { { message: 'Block has too many lines (2). Maximum allowed is 1.', line: 2, - column: 7 + column: 7, + endLine: 5, + endColumn: 18 } ] }, @@ -76,7 +78,9 @@ tester.run('max-lines-per-block', rule, { { message: 'Block has too many lines (2). Maximum allowed is 1.', line: 2, - column: 7 + column: 7, + endLine: 6, + endColumn: 16 } ] } diff --git a/tests/lib/rules/max-props.js b/tests/lib/rules/max-props.js index 7d000f363..041a53f4c 100644 --- a/tests/lib/rules/max-props.js +++ b/tests/lib/rules/max-props.js @@ -137,7 +137,9 @@ tester.run('max-props', rule, { { message: 'Component has too many props (2). Maximum allowed is 1.', line: 3, - endLine: 3 + endLine: 3, + column: 7, + endColumn: 44 } ] }, @@ -158,7 +160,9 @@ tester.run('max-props', rule, { { message: 'Component has too many props (2). Maximum allowed is 1.', line: 4, - endLine: 7 + endLine: 7, + column: 9, + endColumn: 10 } ] }, @@ -180,7 +184,9 @@ tester.run('max-props', rule, { { message: 'Component has too many props (3). Maximum allowed is 2.', line: 3, - endLine: 3 + endLine: 3, + column: 7, + endColumn: 69 } ] }, @@ -201,7 +207,9 @@ tester.run('max-props', rule, { { message: 'Component has too many props (3). Maximum allowed is 2.', line: 3, - endLine: 3 + endLine: 3, + column: 7, + endColumn: 85 } ] }, @@ -230,7 +238,9 @@ tester.run('max-props', rule, { { message: 'Component has too many props (3). Maximum allowed is 2.', line: 3, - endLine: 11 + endLine: 11, + column: 7, + endColumn: 11 } ] } diff --git a/tests/lib/rules/max-template-depth.js b/tests/lib/rules/max-template-depth.js index 4ef9e95d1..b5fc4cb91 100644 --- a/tests/lib/rules/max-template-depth.js +++ b/tests/lib/rules/max-template-depth.js @@ -95,7 +95,10 @@ tester.run('max-template-depth', rule, { { message: 'Element is nested too deeply (depth of 4, maximum allowed is 3).', - line: 6 + line: 6, + column: 13, + endLine: 6, + endColumn: 20 } ] }, @@ -120,7 +123,10 @@ tester.run('max-template-depth', rule, { { message: 'Element is nested too deeply (depth of 4, maximum allowed is 3).', - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 19 } ] }, @@ -148,19 +154,25 @@ tester.run('max-template-depth', rule, { message: 'Element is nested too deeply (depth of 4, maximum allowed is 3).', line: 9, - endLine: 12 + endLine: 12, + column: 13, + endColumn: 11 }, { message: 'Element is nested too deeply (depth of 5, maximum allowed is 3).', line: 10, - endLine: 10 + endLine: 10, + column: 15, + endColumn: 22 }, { message: 'Element is nested too deeply (depth of 5, maximum allowed is 3).', line: 11, - endLine: 12 + endLine: 12, + column: 13, + endColumn: 11 } ] } diff --git a/tests/lib/rules/multi-word-component-names.js b/tests/lib/rules/multi-word-component-names.js index 70dc3fef3..8ad8865d8 100644 --- a/tests/lib/rules/multi-word-component-names.js +++ b/tests/lib/rules/multi-word-component-names.js @@ -230,7 +230,8 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "test" should always be multi-word.', - line: 1 + line: 1, + column: 1 } ] }, @@ -243,7 +244,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "test" should always be multi-word.', - line: 3 + line: 3, + column: 32, + endLine: 3, + endColumn: 38 } ] }, @@ -256,7 +260,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "test" should always be multi-word.', - line: 3 + line: 3, + column: 23, + endLine: 3, + endColumn: 29 } ] }, @@ -269,7 +276,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "invalid" should always be multi-word.', - line: 3 + line: 3, + column: 32, + endLine: 3, + endColumn: 41 } ] }, @@ -282,7 +292,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "invalid" should always be multi-word.', - line: 3 + line: 3, + column: 23, + endLine: 3, + endColumn: 32 } ] }, @@ -295,7 +308,8 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "invalid" should always be multi-word.', - line: 1 + line: 1, + column: 1 } ] }, @@ -308,7 +322,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "" should always be multi-word.', - line: 3 + line: 3, + column: 23, + endLine: 3, + endColumn: 25 } ] }, @@ -325,7 +342,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "Item" should always be multi-word.', - line: 4 + line: 4, + column: 15, + endLine: 4, + endColumn: 21 } ] }, @@ -338,7 +358,8 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "test" should always be multi-word.', - line: 1 + line: 1, + column: 1 } ] }, @@ -352,7 +373,10 @@ tester.run('multi-word-component-names', rule, { errors: [ { message: 'Component name "Single" should always be multi-word.', - line: 3 + line: 3, + column: 28, + endLine: 3, + endColumn: 36 } ] } diff --git a/tests/lib/rules/multiline-html-element-content-newline.js b/tests/lib/rules/multiline-html-element-content-newline.js index 36aa9cfe4..372d277fc 100644 --- a/tests/lib/rules/multiline-html-element-content-newline.js +++ b/tests/lib/rules/multiline-html-element-content-newline.js @@ -384,8 +384,22 @@ multiline
`, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 20, + endLine: 4, + endColumn: 20 + } ] }, { @@ -401,7 +415,14 @@ multiline content
`, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + } ] }, { @@ -417,7 +438,14 @@ multiline content
`, errors: [ - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 30, + endLine: 4, + endColumn: 30 + } ] }, // comments @@ -437,8 +465,22 @@ multiline content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 25, + endLine: 4, + endColumn: 25 + } ] }, { @@ -457,8 +499,22 @@ multiline content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 23, + endLine: 4, + endColumn: 23 + } ] }, // one error @@ -479,7 +535,14 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + } ] }, { @@ -499,7 +562,14 @@ content `, errors: [ - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 5, + column: 18, + endLine: 5, + endColumn: 18 + } ] }, // multi @@ -519,12 +589,54 @@ content `, errors: [ - 'Expected 1 line break after opening tag (``), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (``), but no line breaks found.', + line: 3, + column: 35, + endLine: 3, + endColumn: 35 + } ] }, // multi line breaks @@ -548,8 +660,22 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but 2 line breaks found.', - 'Expected 1 line break before closing tag (`
`), but 2 line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but 2 line breaks found.', + line: 3, + column: 16, + endLine: 5, + endColumn: 13 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but 2 line breaks found.', + line: 6, + column: 20, + endLine: 8, + endColumn: 11 + } ] }, // allowEmptyLines @@ -575,7 +701,14 @@ content `, options: [{ allowEmptyLines: true, ignoreWhenEmpty: false }], errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 8, + column: 27, + endLine: 8, + endColumn: 27 + } ] }, { @@ -607,8 +740,22 @@ content `, options: [{ allowEmptyLines: true }], errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 9, + column: 16, + endLine: 9, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 10, + column: 20, + endLine: 10, + endColumn: 20 + } ] }, // mustache @@ -628,8 +775,22 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 23, + endLine: 4, + endColumn: 23 + } ] }, // mix @@ -651,8 +812,22 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 3, + column: 16, + endLine: 3, + endColumn: 16 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 5, + column: 27, + endLine: 5, + endColumn: 27 + } ] }, // start tag @@ -672,8 +847,22 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 4, + column: 14, + endLine: 4, + endColumn: 14 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 21, + endLine: 4, + endColumn: 21 + } ] }, { @@ -692,8 +881,22 @@ content `, errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.', - 'Expected 1 line break before closing tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 4, + column: 18, + endLine: 4, + endColumn: 18 + }, + { + message: + 'Expected 1 line break before closing tag (`
`), but no line breaks found.', + line: 4, + column: 25, + endLine: 4, + endColumn: 25 + } ] }, { @@ -712,7 +915,14 @@ content `, options: [{ ignoreWhenEmpty: false }], errors: [ - 'Expected 1 line break after opening tag (`
`), but no line breaks found.' + { + message: + 'Expected 1 line break after opening tag (`
`), but no line breaks found.', + line: 4, + column: 14, + endLine: 4, + endColumn: 14 + } ] } ] diff --git a/tests/lib/rules/multiline-ternary.js b/tests/lib/rules/multiline-ternary.js index 87e3fe485..118cf6353 100644 --- a/tests/lib/rules/multiline-ternary.js +++ b/tests/lib/rules/multiline-ternary.js @@ -4,9 +4,8 @@ */ 'use strict' -const { RuleTester, ESLint } = require('../../eslint-compat') +const { RuleTester } = require('../../eslint-compat') const rule = require('../../../lib/rules/multiline-ternary') -const semver = require('semver') const tester = new RuleTester({ languageOptions: { @@ -80,8 +79,7 @@ tester.run('multiline-ternary', rule, {
`, - output: semver.gte(ESLint.version, '7.1.0') - ? ` + output: ` - ` - : null, + `, options: ['always-multiline'], errors: [ { message: 'Expected newline between consequent and alternate of ternary expression.', line: 5, - column: 15 + column: 15, + endLine: 5, + endColumn: 30 } ] }, @@ -113,23 +112,23 @@ tester.run('multiline-ternary', rule, {
`, - output: semver.gte(ESLint.version, '7.1.0') - ? ` + output: ` - ` - : null, + `, options: ['never'], errors: [ { message: 'Unexpected newline between test and consequent of ternary expression.', line: 4, - column: 21 + column: 21, + endLine: 4, + endColumn: 44 } ] }, @@ -143,8 +142,7 @@ tester.run('multiline-ternary', rule, {
`, - output: semver.gte(ESLint.version, '7.1.0') - ? ` + output: ` - ` - : null, + `, errors: [ { message: 'Expected newline between test and consequent of ternary expression.', line: 4, - column: 21 + column: 21, + endLine: 4, + endColumn: 44 }, { message: 'Expected newline between consequent and alternate of ternary expression.', line: 4, - column: 47 + column: 47, + endLine: 4, + endColumn: 62 } ] }, @@ -180,8 +181,7 @@ tester.run('multiline-ternary', rule, {
`, - output: semver.gte(ESLint.version, '7.1.0') - ? ` + output: ` - ` - : null, + `, errors: [ { message: 'Expected newline between test and consequent of ternary expression.', line: 4, - column: 21 + column: 21, + endLine: 4, + endColumn: 44 }, { message: 'Expected newline between consequent and alternate of ternary expression.', line: 4, - column: 47 + column: 47, + endLine: 4, + endColumn: 62 } ] }, @@ -220,8 +223,7 @@ tester.run('multiline-ternary', rule, { } `, - output: semver.gte(ESLint.version, '7.1.0') - ? ` + output: ` `, options: [{ ignore: ['/one/', '/^Two$/i', '/^my-.*/i'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['LinkList'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['/^Link/'] }] } ], invalid: [ @@ -86,7 +110,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 } ] }, @@ -106,7 +133,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 } ] }, @@ -126,7 +156,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 } ] }, @@ -146,7 +179,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 } ] }, @@ -166,7 +202,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 } ] }, @@ -185,23 +224,38 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 }, { message: '`slot` attributes are deprecated.', - line: 5 + line: 5, + column: 21, + endLine: 5, + endColumn: 25 }, { message: '`slot` attributes are deprecated.', - line: 6 + line: 6, + column: 21, + endLine: 6, + endColumn: 25 }, { message: '`slot` attributes are deprecated.', - line: 7 + line: 7, + column: 21, + endLine: 7, + endColumn: 25 }, { message: '`slot` attributes are deprecated.', - line: 8 + line: 8, + column: 21, + endLine: 8, + endColumn: 25 } ] }, @@ -221,7 +275,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 32 } ] }, @@ -236,7 +293,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -256,7 +316,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -271,7 +334,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -286,7 +352,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -301,7 +370,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -316,7 +388,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -336,7 +411,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -356,7 +434,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 18 } ] }, @@ -376,7 +457,10 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 19 } ] }, @@ -397,7 +481,15 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 21, + endLine: 4, + endColumn: 25 + } + ] }, { code: ` @@ -416,7 +508,15 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 21, + endLine: 4, + endColumn: 25 + } + ] }, { code: ` @@ -435,7 +535,15 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 21, + endLine: 4, + endColumn: 25 + } + ] }, { // https://github.com/vuejs/eslint-plugin-vue/issues/1499 @@ -470,11 +578,17 @@ tester.run('no-deprecated-slot-attribute', rule, { errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 25 }, { message: '`slot` attributes are deprecated.', - line: 9 + line: 9, + column: 23, + endLine: 9, + endColumn: 27 } ] }, @@ -502,8 +616,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 37, + endLine: 4, + endColumn: 41 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 37, + endLine: 7, + endColumn: 42 + } ] }, { @@ -520,8 +646,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, output: null, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 21, + endLine: 4, + endColumn: 25 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 21, + endLine: 7, + endColumn: 25 + } ] }, { @@ -548,8 +686,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 30, + endLine: 4, + endColumn: 34 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 28, + endLine: 7, + endColumn: 32 + } ] }, { @@ -566,8 +716,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, output: null, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 37, + endLine: 4, + endColumn: 42 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 37, + endLine: 7, + endColumn: 42 + } ] }, { @@ -594,8 +756,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 37, + endLine: 4, + endColumn: 42 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 37, + endLine: 7, + endColumn: 42 + } ] }, { @@ -622,8 +796,20 @@ tester.run('no-deprecated-slot-attribute', rule, { `, errors: [ - '`slot` attributes are deprecated.', - '`slot` attributes are deprecated.' + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 41, + endLine: 4, + endColumn: 46 + }, + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 37, + endLine: 7, + endColumn: 42 + } ] }, { @@ -654,7 +840,15 @@ tester.run('no-deprecated-slot-attribute', rule, { ignore: ['one'] } ], - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 7, + column: 16, + endLine: 7, + endColumn: 20 + } + ] }, { code: ` @@ -732,6 +926,90 @@ tester.run('no-deprecated-slot-attribute', rule, { } ] }, + { + code: ` + `, + output: ` + `, + options: [ + { + ignoreParents: ['my-component'] + } + ], + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 9, + column: 16, + endLine: 9, + endColumn: 20 + } + ] + }, + { + code: ` + `, + output: ` + `, + options: [ + { + ignoreParents: ['/component$/'] + } + ], + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 9, + column: 16, + endLine: 9, + endColumn: 20 + } + ] + }, { code: ` `, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 6, + column: 13, + endLine: 6, + endColumn: 18 + } + ] }, { code: ` @@ -768,7 +1054,15 @@ tester.run('no-deprecated-slot-attribute', rule, { `, output: null, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 4, + column: 16, + endLine: 4, + endColumn: 20 + } + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-slot-scope-attribute.js b/tests/lib/rules/no-deprecated-slot-scope-attribute.js index 078f004ef..7b9eb870b 100644 --- a/tests/lib/rules/no-deprecated-slot-scope-attribute.js +++ b/tests/lib/rules/no-deprecated-slot-scope-attribute.js @@ -66,7 +66,10 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 31 } ] }, @@ -86,7 +89,10 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 31 } ] }, @@ -106,7 +112,10 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 24 } ] }, @@ -121,7 +130,10 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 31 } ] }, @@ -136,7 +148,10 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 31 } ] }, @@ -150,7 +165,15 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { `, output: null, - errors: ['`slot-scope` are deprecated.'] + errors: [ + { + message: '`slot-scope` are deprecated.', + line: 4, + column: 37, + endLine: 4, + endColumn: 47 + } + ] }, { code: ` @@ -163,7 +186,15 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { `, output: null, - errors: ['`slot-scope` are deprecated.'] + errors: [ + { + message: '`slot-scope` are deprecated.', + line: 4, + column: 21, + endLine: 4, + endColumn: 31 + } + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-v-bind-sync.js b/tests/lib/rules/no-deprecated-v-bind-sync.js index 3d775d975..355d1a86c 100644 --- a/tests/lib/rules/no-deprecated-v-bind-sync.js +++ b/tests/lib/rules/no-deprecated-v-bind-sync.js @@ -37,7 +37,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: "", output: "", errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 45 + } ] }, { @@ -45,7 +52,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: "", output: "", errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 39 + } ] }, { @@ -53,7 +67,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: "", output: "", errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 54 + } ] }, { @@ -61,7 +82,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: "", output: "", errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 48 + } ] }, { @@ -69,7 +97,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: "", output: null, errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 41 + } ] }, { @@ -77,7 +112,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: '', output: null, errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 47 + } ] }, { @@ -85,7 +127,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { code: '', output: null, errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 24, + endLine: 1, + endColumn: 56 + } ] }, { @@ -94,7 +143,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 69 + } ] }, { @@ -103,7 +159,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 70 + } ] }, { @@ -112,7 +175,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 74 + } ] }, { @@ -121,7 +191,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 75 + } ] }, { @@ -130,7 +207,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 82 + } ] }, { @@ -139,7 +223,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 80 + } ] }, { @@ -148,7 +239,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 77 + } ] }, { @@ -157,7 +255,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 72 + } ] }, { @@ -166,7 +271,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 89 + } ] }, { @@ -175,7 +287,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 77 + } ] }, { @@ -184,7 +303,14 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { output: '', errors: [ - "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." + { + message: + "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead.", + line: 1, + column: 52, + endLine: 1, + endColumn: 78 + } ] } ] diff --git a/tests/lib/rules/no-negated-condition.js b/tests/lib/rules/no-negated-condition.js new file mode 100644 index 000000000..4a4d5e4c2 --- /dev/null +++ b/tests/lib/rules/no-negated-condition.js @@ -0,0 +1,166 @@ +/** + * @author Wayne Zhang + * See LICENSE file in root directory for full license. + */ +'use strict' + +const RuleTester = require('../../eslint-compat').RuleTester +const rule = require('../../../lib/rules/no-negated-condition') + +const tester = new RuleTester({ + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 2020, + sourceType: 'module' + } +}) + +tester.run('no-negated-condition', rule, { + valid: [ + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + } + ], + invalid: [ + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 3, + column: 22, + endLine: 3, + endColumn: 42 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 4, + column: 22, + endLine: 4, + endColumn: 51 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 4, + column: 21, + endLine: 4, + endColumn: 40 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 3, + column: 25, + endLine: 3, + endColumn: 48 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 3, + column: 22, + endLine: 3, + endColumn: 52 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 3, + column: 22, + endLine: 3, + endColumn: 52 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Unexpected negated condition.', + line: 4, + column: 20, + endLine: 4, + endColumn: 37 + } + ] + } + ] +}) diff --git a/tests/lib/rules/no-negated-v-if-condition.js b/tests/lib/rules/no-negated-v-if-condition.js new file mode 100644 index 000000000..ee60562ea --- /dev/null +++ b/tests/lib/rules/no-negated-v-if-condition.js @@ -0,0 +1,327 @@ +/** + * @author Wayne Zhang + * See LICENSE file in root directory for full license. + */ +'use strict' + +const RuleTester = require('../../eslint-compat').RuleTester +const rule = require('../../../lib/rules/no-negated-v-if-condition') + +const tester = new RuleTester({ + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 2020, + sourceType: 'module' + } +}) + +tester.run('no-negated-v-if-condition', rule, { + valid: [ + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + } + ], + invalid: [ + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 3, + column: 20, + endLine: 3, + endColumn: 24, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 3, + column: 20, + endLine: 3, + endColumn: 33, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 3, + column: 20, + endLine: 3, + endColumn: 26, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 3, + column: 20, + endLine: 3, + endColumn: 27, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 4, + column: 25, + endLine: 4, + endColumn: 29, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + messageId: 'negatedCondition', + line: 4, + column: 25, + endLine: 4, + endColumn: 27, + suggestions: [ + { + messageId: 'fixNegatedCondition', + output: ` + + ` + } + ] + } + ] + } + ] +}) diff --git a/tests/lib/rules/require-explicit-slots.js b/tests/lib/rules/require-explicit-slots.js index f99614119..afee739a6 100644 --- a/tests/lib/rules/require-explicit-slots.js +++ b/tests/lib/rules/require-explicit-slots.js @@ -6,6 +6,9 @@ const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/require-explicit-slots') +const { + getTypeScriptFixtureTestOptions +} = require('../../test-utils/typescript') const tester = new RuleTester({ languageOptions: { @@ -276,6 +279,21 @@ tester.run('require-explicit-slots', rule, { }) ` }, + { + filename: 'test.vue', + code: ` + + `, + ...getTypeScriptFixtureTestOptions() + }, { filename: 'test.vue', code: ` @@ -656,6 +674,28 @@ tester.run('require-explicit-slots', rule, { } ] }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Slots must be explicitly defined.', + line: 5, + column: 11 + } + ], + ...getTypeScriptFixtureTestOptions() + }, { // ignore attribute binding except string literal filename: 'test.vue', diff --git a/tests/lib/utils/regexp.js b/tests/lib/utils/regexp.js index 830fa2a11..e27a0596f 100644 --- a/tests/lib/utils/regexp.js +++ b/tests/lib/utils/regexp.js @@ -1,6 +1,10 @@ 'use strict' -const { escape, toRegExp } = require('../../../lib/utils/regexp') +const { + escape, + toRegExp, + toRegExpGroupMatcher +} = require('../../../lib/utils/regexp') const assert = require('assert') const ESCAPED = '\\^\\$\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\' @@ -35,4 +39,120 @@ describe('toRegExp()', () => { assert.deepEqual(toRegExp(`${/^bar/i}`), /^bar/i) assert.deepEqual(toRegExp(`${/[\sA-Z]+/u}`), /[\sA-Z]+/u) }) + + it('should handle simple patterns', () => { + const regex = toRegExp('foo') + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), false) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), false) + }) + + it('should handle simple patterns with added flags', () => { + const regex = toRegExp('foo', { add: 'i' }) + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), false) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), true) + }) + + it('should handle regexp patterns', () => { + const regex = toRegExp('/^foo/') + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), true) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), false) + }) + + it('should handle regexp patterns with attached flags', () => { + const regex = toRegExp('/^foo/i') + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), true) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), true) + }) + + it('should handle regexp patterns with added flags', () => { + const regex = toRegExp('/^foo/', { add: 'i' }) + assert.deepEqual(regex, /^foo/i) + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), true) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), true) + }) + + it('should handle regexp patterns with removed flags', () => { + const regex = toRegExp('/^foo/i', { remove: 'i' }) + assert.deepEqual(regex, /^foo/) + assert.strictEqual(regex.test('foo'), true) + assert.strictEqual(regex.test('bar'), false) + assert.strictEqual(regex.test('foobar'), true) + assert.strictEqual(regex.test('afoo'), false) + assert.strictEqual(regex.test('afoobar'), false) + assert.strictEqual(regex.test('Foo'), false) + }) +}) + +describe('toRegExpGroupMatcher()', () => { + it('should return a function missing input', () => { + const groupMatcher = toRegExpGroupMatcher() + assert.strictEqual(groupMatcher(''), false) + assert.strictEqual(groupMatcher('foo'), false) + assert.strictEqual(groupMatcher('bar'), false) + }) + + it('should return a function for empty array', () => { + const groupMatcher = toRegExpGroupMatcher([]) + assert.strictEqual(groupMatcher(''), false) + assert.strictEqual(groupMatcher('foo'), false) + assert.strictEqual(groupMatcher('bar'), false) + }) + + it('should return a function for single simple pattern', () => { + const groupMatcher = toRegExpGroupMatcher(['foo']) + assert.strictEqual(groupMatcher(''), false) + assert.strictEqual(groupMatcher('foo'), true) + assert.strictEqual(groupMatcher('foo', 'early'), true) + assert.strictEqual(groupMatcher('late', 'matches', 'foo'), true) + assert.strictEqual(groupMatcher('foobar'), false) + assert.strictEqual(groupMatcher('afoo', 'fooa', 'afooa', 'bar'), false) + }) + + it('should return a function for multiple simple patterns', () => { + const groupMatcher = toRegExpGroupMatcher(['foo', 'bar']) + assert.strictEqual(groupMatcher('foo'), true) + assert.strictEqual(groupMatcher('bar', 'early'), true) + assert.strictEqual(groupMatcher('late', 'matches', 'foo'), true) + assert.strictEqual(groupMatcher('foobar'), false) + assert.strictEqual(groupMatcher('afoo', 'fooa', 'afooa'), false) + }) + + it('should return a function for single regexp pattern', () => { + const groupMatcher = toRegExpGroupMatcher(['/^foo/g']) + assert.strictEqual(groupMatcher(''), false) + assert.strictEqual(groupMatcher('foo'), true) + assert.strictEqual(groupMatcher('fooa', 'early'), true) + assert.strictEqual(groupMatcher('late', 'matches', 'fooa'), true) + assert.strictEqual(groupMatcher('barfoo'), false) + assert.strictEqual(groupMatcher('afoo', 'afooa', 'bar'), false) + }) + + it('should return a function for multiple regexp patterns', () => { + const groupMatcher = toRegExpGroupMatcher(['/^foo/', '/bar$/gi']) + assert.strictEqual(groupMatcher('foo'), true) + assert.strictEqual(groupMatcher('Bar', 'early'), true) + assert.strictEqual(groupMatcher('late', 'matches', 'foo'), true) + assert.strictEqual(groupMatcher('barfoo'), false) + assert.strictEqual(groupMatcher('afoo', 'afooa', 'bara'), false) + }) }) diff --git a/tools/generate-typegen.mjs b/tools/generate-typegen.mjs index 5bcb325a5..1f3b4a129 100644 --- a/tools/generate-typegen.mjs +++ b/tools/generate-typegen.mjs @@ -2,8 +2,13 @@ import fs from 'node:fs/promises' import { pluginsToRulesDTS } from 'eslint-typegen/core' import plugin from '../lib/index.js' -const dts = await pluginsToRulesDTS({ - vue: plugin -}) +const dts = await pluginsToRulesDTS( + { + vue: plugin + }, + { + includeAugmentation: false + } +) await fs.writeFile('lib/eslint-typegen.d.ts', dts) diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 000000000..eeef751d6 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,32 @@ + +import { defineConfig } from 'vitest/config'; +export default defineConfig({ + test: { + include: [ + 'tests/lib/**/*.js', + 'tests/integrations/**/*.js' + ], + exclude: [ + '**/node_modules/**', + '**/dist/**', + 'tests/fixtures/**', + 'tests/integrations/flat-config/eslint.config.js', + 'tests/lib/rules/no-unsupported-features/utils.js' + ], + testTimeout: 60_000, + globals: true, + coverage: { + provider: 'v8', + include: ['lib/**/*.js'], + exclude: [ + 'tests/**', + 'dist/**', + 'tools/**', + 'node_modules/**' + ], + reporter: ['text', 'lcov', 'json-summary', 'html'], + all: true, + reportsDirectory: './coverage' + }, + }, +});