diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 000000000..e5b6d8d6a --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 000000000..43b72b358 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://unpkg.com/@changesets/config/schema.json", + "changelog": [ + "@svitejs/changesets-changelog-github-compact", + { + "repo": "vuejs/eslint-plugin-vue" + } + ], + "commit": false, + "linked": [], + "access": "public", + "baseBranch": "master", + "bumpVersionsWithWorkspaceProtocolOnly": true, + "ignore": [] +} diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 57aa5876d..90bd33ad5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -46,7 +46,7 @@ jobs: with: node-version: ${{ matrix.node }} - name: Install Packages - run: npm install -f + run: npm install - name: Install ESLint v${{ matrix.eslint }} run: npm install --save-dev eslint@${{ matrix.eslint }} -f - name: Test @@ -61,8 +61,23 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 - name: Install Packages - run: npm install -f + run: npm install - name: Uninstall @stylistic/eslint-plugin run: npm uninstall -D @stylistic/eslint-plugin - name: Test run: npm test + + test-with-typescript-eslint-v7: + name: Test with typescript-eslint v7 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install + - name: Install @typescript-eslint/parser@7 + run: npm install -D @typescript-eslint/parser@7 -f + - name: Test + run: npm test diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 000000000..3653780d5 --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + push: + branches: + - master + +permissions: {} + +jobs: + release: + # prevents this action from running on forks + if: github.repository == 'vuejs/eslint-plugin-vue' + permissions: + contents: write # to create release (changesets/action) + pull-requests: write # to create pull request (changesets/action) + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + - name: Install Dependencies + run: npm install + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + version: npm run changeset:version + publish: npm run changeset:publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/check-for-resources-update.yml b/.github/workflows/check-for-resources-update.yml index 613125fc3..31f881b1d 100644 --- a/.github/workflows/check-for-resources-update.yml +++ b/.github/workflows/check-for-resources-update.yml @@ -5,12 +5,13 @@ on: - cron: 0 0 * * 0 # At 00:00 on Sunday, see https://crontab.guru/#0_0_*_*_0 permissions: - contents: write - pull-requests: write + contents: write + pull-requests: write jobs: check-for-resources-update: runs-on: ubuntu-latest + if: ${{ github.repository == 'vuejs/eslint-plugin-vue' }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 797d0cbcd..d6fadf92c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,9 @@ yarn.lock yarn-error.log /docs/.vitepress/dist -/docs/.vitepress/build-system/shim/eslint.mjs -/docs/.vitepress/build-system/shim/assert.mjs +/docs/.vitepress/build-system/shim/vue-eslint-parser.mjs +/docs/.vitepress/build-system/shim/@typescript-eslint/parser.mjs /docs/.vitepress/.temp /docs/.vitepress/cache typings/eslint/lib/rules +eslint-typegen.d.ts diff --git a/.markdownlintignore b/.markdownlintignore index 3c3629e64..e7becf85b 100644 --- a/.markdownlintignore +++ b/.markdownlintignore @@ -1 +1,2 @@ node_modules +CHANGELOG.md 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 new file mode 100644 index 000000000..fa7a29427 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,45 @@ +# 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 + +- Added [`@typescript-eslint/parser`](https://typescript-eslint.io/packages/parser) as an optional peer dependency ([#2775](https://github.com/vuejs/eslint-plugin-vue/pull/2775)) + +- Add TypeScript IntelliSense support via [eslint-typegen](https://github.com/antfu/eslint-typegen) ([#2770](https://github.com/vuejs/eslint-plugin-vue/pull/2770)) + +- [`vue/no-deprecated-slot-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-attribute.html) `ignore` option now supports regex patterns ([#2773](https://github.com/vuejs/eslint-plugin-vue/pull/2773)) + +### Patch Changes + +- Fixed false negatives when using typescript-eslint v8 in [`vue/script-indent`](https://eslint.vuejs.org/rules/script-indent.html) rule ([#2775](https://github.com/vuejs/eslint-plugin-vue/pull/2775)) + +- Update resources ([#2752](https://github.com/vuejs/eslint-plugin-vue/pull/2752)) + +- [`vue/no-restricted-html-elements`](https://eslint.vuejs.org/rules/no-restricted-html-elements.html) now also checks SVG and MathML elements ([#2755](https://github.com/vuejs/eslint-plugin-vue/pull/2755)) + +## 10.2.0 + +### Minor Changes + +- [vue/no-restricted-html-elements](https://eslint.vuejs.org/rules/no-restricted-html-elements.html) now accepts multiple elements in each entry. ([#2750](https://github.com/vuejs/eslint-plugin-vue/pull/2750)) + +### Patch Changes + +- Updates resources ([#2747](https://github.com/vuejs/eslint-plugin-vue/pull/2747)) diff --git a/README.md b/README.md index 95e0c08be..bdeb5e167 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM version](https://img.shields.io/npm/v/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) -[![CircleCI](https://img.shields.io/circleci/project/github/vuejs/eslint-plugin-vue/master.svg?style=flat)](https://circleci.com/gh/vuejs/eslint-plugin-vue) +[![CI](https://img.shields.io/github/actions/workflow/status/vuejs/eslint-plugin-vue/CI.yml?style=flat&label=CI)](https://github.com/vuejs/eslint-plugin-vue/actions/workflows/CI.yml) [![License](https://img.shields.io/github/license/vuejs/eslint-plugin-vue.svg?style=flat)](https://github.com/vuejs/eslint-plugin-vue/blob/master/LICENSE) > Official ESLint plugin for Vue.js diff --git a/docs/.vitepress/build-system/build.mts b/docs/.vitepress/build-system/build.mts index 9dce53faf..edda69143 100644 --- a/docs/.vitepress/build-system/build.mts +++ b/docs/.vitepress/build-system/build.mts @@ -9,14 +9,38 @@ import { fileURLToPath } from 'url' const dirname = path.dirname(fileURLToPath(import.meta.url)) build( - path.join(dirname, './src/eslint.mjs'), - path.join(dirname, './shim/eslint.mjs'), - ['path', 'assert', 'util', 'esquery'] + path.join( + dirname, + '../../../node_modules/@typescript-eslint/parser/dist/index.js' + ), + path.join(dirname, './shim/@typescript-eslint/parser.mjs'), + [ + 'util', + 'node:util', + 'path', + 'node:path', + 'fs', + 'node:fs', + 'semver', + 'fast-glob', + 'debug' + ] ) + build( - path.join(dirname, '../../../node_modules/assert'), - path.join(dirname, './shim/assert.mjs'), - ['path'] + path.join(dirname, '../../../node_modules/vue-eslint-parser/index.js'), + path.join(dirname, './shim/vue-eslint-parser.mjs'), + [ + 'path', + 'debug', + 'semver', + 'assert', + 'module', + 'events', + 'esquery', + 'fs', + 'eslint' + ] ) function build(input: string, out: string, injects: string[] = []) { @@ -42,16 +66,22 @@ function bundle(entryPoint: string, externals: string[]) { } function transform(code: string, injects: string[]) { + const normalizeInjects = [ + ...new Set(injects.map((inject) => inject.replace(/^node:/u, ''))) + ] const newCode = code.replace(/"[a-z]+" = "[a-z]+";/u, '') return ` -${injects +${normalizeInjects .map( (inject) => - `import $inject_${inject.replace(/-/gu, '_')}$ from '${inject}';` + `import $inject_${inject.replace(/[\-:]/gu, '_')}$ from '${inject}';` ) .join('\n')} const $_injects_$ = {${injects - .map((inject) => `${inject.replace(/-/gu, '_')}:$inject_${inject}$`) + .map( + (inject) => + `"${inject}":$inject_${inject.replace(/^node:/u, '').replace(/[\-:]/gu, '_')}$` + ) .join(',\n')}}; function require(module, ...args) { return $_injects_$[module] || {} diff --git a/docs/.vitepress/build-system/shim/globby.mjs b/docs/.vitepress/build-system/shim/empty.mjs similarity index 100% rename from docs/.vitepress/build-system/shim/globby.mjs rename to docs/.vitepress/build-system/shim/empty.mjs diff --git a/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs b/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs deleted file mode 100644 index 0db0b01c2..000000000 --- a/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs +++ /dev/null @@ -1,3 +0,0 @@ -export default { - /* empty */ -} diff --git a/docs/.vitepress/build-system/shim/esquery.mjs b/docs/.vitepress/build-system/shim/esquery.mjs deleted file mode 100644 index 5652b09f1..000000000 --- a/docs/.vitepress/build-system/shim/esquery.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import esquery from '../../../../node_modules/esquery/dist/esquery.esm.js' - -export const { parse, match, traverse, matches, query } = esquery - -export { default } from '../../../../node_modules/esquery/dist/esquery.esm.js' diff --git a/docs/.vitepress/build-system/shim/path.mjs b/docs/.vitepress/build-system/shim/path.mjs deleted file mode 100644 index 544792b00..000000000 --- a/docs/.vitepress/build-system/shim/path.mjs +++ /dev/null @@ -1,38 +0,0 @@ -// @ts-nocheck -export const sep = '/' -export function basename(path, ext) { - const b = (/[^\/]*$/u.exec(path) || [''])[0] - return ext && b.endsWith(ext) ? b.slice(0, -ext.length) : b -} -export function extname(path) { - return (/[^.\/]*$/u.exec(path) || [''])[0] -} -export function isAbsolute() { - return false -} -export function join(...args) { - return args.length > 0 ? normalize(args.join('/')) : '.' -} - -function normalize(path) { - const result = [] - for (const part of path.replace(/\/+/gu, '/').split('/')) { - if (part === '..') { - if (result[0] && result[0] !== '..' && result[0] !== '.') result.shift() - } else if (part === '.' && result.length > 0) { - // noop - } else { - result.unshift(part) - } - } - return result.reverse().join('/') -} -const posix = { - sep, - basename, - extname, - isAbsolute, - join -} -posix.posix = posix -export default posix diff --git a/docs/.vitepress/build-system/src/eslint.mjs b/docs/.vitepress/build-system/src/eslint.mjs deleted file mode 100644 index ed193b58b..000000000 --- a/docs/.vitepress/build-system/src/eslint.mjs +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-nocheck -/* eslint-disable unicorn/prefer-export-from -- exporting as named and default is less duplication without `export…from` */ - -import { Linter } from '../../../../node_modules/eslint/lib/linter/linter.js' -import SourceCode from '../../../../node_modules/eslint/lib/source-code/source-code.js' - -export { Linter, SourceCode } -export default { Linter, SourceCode } diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index afa635d7e..7d198d588 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitepress' import path from 'pathe' import { fileURLToPath } from 'url' import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin.mjs' +import eslint4b, { requireESLintUseAtYourOwnRisk4b } from 'vite-plugin-eslint4b' // Pre-build cjs packages that cannot be bundled well. import './build-system/build.mjs' @@ -142,24 +143,30 @@ export default async () => { vite: { publicDir: path.resolve(dirname, './public'), - plugins: [vitePluginRequireResolve(), viteCommonjs()], + plugins: [ + vitePluginRequireResolve(), + viteCommonjs(), + eslint4b() as any, + requireESLintUseAtYourOwnRisk4b() + ], resolve: { alias: { - 'eslint/use-at-your-own-risk': path.join( + 'vue-eslint-parser': path.join( + dirname, + './build-system/shim/vue-eslint-parser.mjs' + ), + '@typescript-eslint/parser': path.join( dirname, - './build-system/shim/eslint/use-at-your-own-risk.mjs' + './build-system/shim/@typescript-eslint/parser.mjs' ), - eslint: path.join(dirname, './build-system/shim/eslint.mjs'), - assert: path.join(dirname, './build-system/shim/assert.mjs'), - path: path.join(dirname, './build-system/shim/path.mjs'), tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'), - esquery: path.join(dirname, './build-system/shim/esquery.mjs'), - globby: path.join(dirname, './build-system/shim/globby.mjs') + globby: path.join(dirname, './build-system/shim/empty.mjs'), + 'fast-glob': path.join(dirname, './build-system/shim/empty.mjs'), + module: path.join(dirname, './build-system/shim/empty.mjs') } }, define: { - 'process.env.NODE_DEBUG': 'false', 'require.cache': '{}' } }, diff --git a/docs/.vitepress/theme/components/eslint-code-block.vue b/docs/.vitepress/theme/components/eslint-code-block.vue index 77d4fd7cf..12cd1ff8b 100644 --- a/docs/.vitepress/theme/components/eslint-code-block.vue +++ b/docs/.vitepress/theme/components/eslint-code-block.vue @@ -8,8 +8,6 @@ class="eslint-code-block" :filename="filename" :language="language" - :preprocess="preprocess" - :postprocess="postprocess" dark :format="format" :fix="fix" @@ -20,8 +18,6 @@ +``` + + + +The rule applies to both JavaScript and TypeScript props: + + + +```vue + +``` + + + +## :wrench: Options + +```js +{ + "vue/define-props-destructuring": ["error", { + "destructure": "always" | "never" + }] +} +``` + +- `destructure` - Sets the destructuring preference for props + - `"always"` (default) - Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring + - `"never"` - Requires using a variable to store props and prohibits destructuring + +### `"destructure": "never"` + + + +```vue + +``` + + + +## :books: Further Reading + +- [Reactive Props Destructure](https://vuejs.org/guide/components/props.html#reactive-props-destructure) + +## :rocket: Version + +This rule was introduced in eslint-plugin-vue v10.1.0 + +## :mag: Implementation + +- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/define-props-destructuring.js) +- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/define-props-destructuring.js) diff --git a/docs/rules/eqeqeq.md b/docs/rules/eqeqeq.md index 392deff7f..fb0133251 100644 --- a/docs/rules/eqeqeq.md +++ b/docs/rules/eqeqeq.md @@ -11,6 +11,7 @@ since: v5.2.0 > Require the use of `===` and `!==` in ``, 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: [{ allowlist: ['@@'] }] + }, + // regex + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\d+/g`] }] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\$\w+/`] }] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\d+/`, 'foo'] }] } ], invalid: [ @@ -316,6 +342,40 @@ tester.run('no-bare-strings-in-template', rule, { endColumn: 34 } ] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/^\d+$/g`] }], + errors: [ + { + messageId: 'unexpected', + line: 3, + column: 13, + endLine: 3, + endColumn: 37 + } + ] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\d+/`, 'foo'] }], + errors: [ + { + messageId: 'unexpected', + line: 3, + column: 13, + endLine: 3, + endColumn: 22 + } + ] } ] }) diff --git a/tests/lib/rules/no-boolean-default.js b/tests/lib/rules/no-boolean-default.js index 98524760c..c3132a5fd 100644 --- a/tests/lib/rules/no-boolean-default.js +++ b/tests/lib/rules/no-boolean-default.js @@ -358,7 +358,10 @@ ruleTester.run('no-boolean-default', rule, { errors: [ { message: 'Boolean prop should only be defaulted to false.', - line: 6 + line: 6, + column: 24, + endLine: 6, + endColumn: 28 } ] }, @@ -378,7 +381,10 @@ ruleTester.run('no-boolean-default', rule, { errors: [ { message: 'Boolean prop should only be defaulted to false.', - line: 6 + line: 6, + column: 24, + endLine: 6, + endColumn: 28 } ] }, @@ -399,7 +405,10 @@ ruleTester.run('no-boolean-default', rule, { { message: 'Boolean prop should not set a default (Vue defaults it to false).', - line: 6 + line: 6, + column: 24, + endLine: 6, + endColumn: 29 } ] }, @@ -420,7 +429,10 @@ ruleTester.run('no-boolean-default', rule, { { message: 'Boolean prop should not set a default (Vue defaults it to false).', - line: 6 + line: 6, + column: 24, + endLine: 6, + endColumn: 28 } ] }, @@ -441,7 +453,10 @@ ruleTester.run('no-boolean-default', rule, { { message: 'Boolean prop should not set a default (Vue defaults it to false).', - line: 6 + line: 6, + column: 20, + endLine: 6, + endColumn: 25 } ] }, @@ -462,7 +477,10 @@ ruleTester.run('no-boolean-default', rule, { errors: [ { message: 'Boolean prop should only be defaulted to false.', - line: 6 + line: 6, + column: 20, + endLine: 6, + endColumn: 24 } ] }, @@ -494,7 +512,10 @@ ruleTester.run('no-boolean-default', rule, { { message: 'Boolean prop should not set a default (Vue defaults it to false).', - line: 7 + line: 7, + column: 14, + endLine: 7, + endColumn: 19 } ] }, @@ -520,7 +541,10 @@ ruleTester.run('no-boolean-default', rule, { errors: [ { message: 'Boolean prop should only be defaulted to false.', - line: 7 + line: 7, + column: 14, + endLine: 7, + endColumn: 18 } ] } @@ -539,7 +563,10 @@ ruleTester.run('no-boolean-default', rule, { { message: 'Boolean prop should not set a default (Vue defaults it to false).', - line: 3 + line: 3, + column: 20, + endLine: 3, + endColumn: 25 } ] }, @@ -557,7 +584,10 @@ ruleTester.run('no-boolean-default', rule, { errors: [ { message: 'Boolean prop should only be defaulted to false.', - line: 3 + line: 3, + column: 20, + endLine: 3, + endColumn: 24 } ] } diff --git a/tests/lib/rules/no-child-content.js b/tests/lib/rules/no-child-content.js index 1be1e3c07..d991559b3 100644 --- a/tests/lib/rules/no-child-content.js +++ b/tests/lib/rules/no-child-content.js @@ -74,7 +74,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-html directive.', + line: 1, column: 29, + endLine: 1, endColumn: 32, suggestions: [ { @@ -93,7 +95,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-html directive.', + line: 1, column: 29, + endLine: 1, endColumn: 38, suggestions: [ { @@ -112,7 +116,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-html directive.', + line: 1, column: 29, + endLine: 1, endColumn: 37, suggestions: [ { @@ -131,7 +137,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-html directive.', + line: 1, column: 29, + endLine: 1, endColumn: 41, suggestions: [ { @@ -183,7 +191,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-text directive.', + line: 1, column: 29, + endLine: 1, endColumn: 32, suggestions: [ { @@ -203,7 +213,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-t directive.', + line: 1, column: 26, + endLine: 1, endColumn: 29, suggestions: [ { @@ -223,7 +235,9 @@ ruleTester.run('no-child-content', rule, { { message: 'Child content is disallowed because it will be overwritten by the v-html directive.', + line: 1, column: 29, + endLine: 1, endColumn: 32, suggestions: [ { diff --git a/tests/lib/rules/no-computed-properties-in-data.js b/tests/lib/rules/no-computed-properties-in-data.js index 769731804..9eb32e973 100644 --- a/tests/lib/rules/no-computed-properties-in-data.js +++ b/tests/lib/rules/no-computed-properties-in-data.js @@ -97,7 +97,9 @@ tester.run('no-computed-properties-in-data', rule, { message: 'The computed property cannot be used in `data()` because it is before initialization.', line: 5, - column: 23 + column: 23, + endLine: 5, + endColumn: 31 } ] }, @@ -122,7 +124,9 @@ tester.run('no-computed-properties-in-data', rule, { message: 'The computed property cannot be used in `data()` because it is before initialization.', line: 6, - column: 23 + column: 23, + endLine: 6, + endColumn: 29 } ] } diff --git a/tests/lib/rules/no-console.js b/tests/lib/rules/no-console.js index 1ff32feeb..f9df6ede7 100644 --- a/tests/lib/rules/no-console.js +++ b/tests/lib/rules/no-console.js @@ -76,7 +76,9 @@ tester.run('no-console', rule, { { message: 'Unexpected console statement.', line: 3, - column: 25 + column: 25, + endLine: 3, + endColumn: 32 } ] }, @@ -91,12 +93,16 @@ tester.run('no-console', rule, { { message: 'Unexpected console statement.', line: 3, - column: 23 + column: 23, + endLine: 3, + endColumn: 30 }, { message: 'Unexpected console statement.', line: 3, - column: 39 + column: 39, + endLine: 3, + endColumn: 46 } ] }, @@ -111,7 +117,9 @@ tester.run('no-console', rule, { { message: 'Unexpected console statement.', line: 3, - column: 31 + column: 31, + endLine: 3, + endColumn: 38 } ] }, @@ -128,7 +136,9 @@ tester.run('no-console', rule, { { message: 'Unexpected console statement.', line: 3, - column: 25 + column: 25, + endLine: 3, + endColumn: 32 } ] } diff --git a/tests/lib/rules/no-constant-condition.js b/tests/lib/rules/no-constant-condition.js index 8d25479f8..489944a11 100644 --- a/tests/lib/rules/no-constant-condition.js +++ b/tests/lib/rules/no-constant-condition.js @@ -24,7 +24,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'UnaryExpression', + line: 1, column: 31, + endLine: 1, endColumn: 33 } ] @@ -35,7 +37,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'Literal', + line: 1, column: 36, + endLine: 1, endColumn: 40 } ] @@ -46,7 +50,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'Literal', + line: 1, column: 31, + endLine: 1, endColumn: 32 } ] @@ -57,7 +63,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'ObjectExpression', + line: 1, column: 33, + endLine: 1, endColumn: 35 } ] @@ -68,7 +76,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'BinaryExpression', + line: 1, column: 31, + endLine: 1, endColumn: 36 } ] @@ -79,7 +89,9 @@ tester.run('no-constant-condition', rule, { { messageId: 'unexpected', type: 'LogicalExpression', + line: 1, column: 31, + endLine: 1, endColumn: 37 } ] diff --git a/tests/lib/rules/no-custom-modifiers-on-v-model.js b/tests/lib/rules/no-custom-modifiers-on-v-model.js index 88d269ebf..156f42e4e 100644 --- a/tests/lib/rules/no-custom-modifiers-on-v-model.js +++ b/tests/lib/rules/no-custom-modifiers-on-v-model.js @@ -51,12 +51,28 @@ ruleTester.run('no-custom-modifiers-on-v-model', rule, { { filename: 'test.vue', code: '', - errors: ["'v-model' directives don't support the modifier 'aaa'."] + errors: [ + { + message: "'v-model' directives don't support the modifier 'aaa'.", + line: 1, + column: 24, + endLine: 1, + endColumn: 50 + } + ] }, { filename: 'test.vue', code: '', - errors: ["'v-model' directives don't support the modifier 'aaa'."] + errors: [ + { + message: "'v-model' directives don't support the modifier 'aaa'.", + line: 1, + column: 24, + endLine: 1, + endColumn: 41 + } + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-data-object-declaration.js b/tests/lib/rules/no-deprecated-data-object-declaration.js index 648e1de24..b7395304d 100644 --- a/tests/lib/rules/no-deprecated-data-object-declaration.js +++ b/tests/lib/rules/no-deprecated-data-object-declaration.js @@ -155,7 +155,10 @@ return { { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 4 + line: 4, + column: 11, + endLine: 6, + endColumn: 12 } ] }, @@ -182,7 +185,10 @@ return { { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 3 + line: 3, + column: 11, + endLine: 5, + endColumn: 12 } ] }, @@ -209,7 +215,10 @@ return { { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 3 + line: 3, + column: 11, + endLine: 5, + endColumn: 12 } ] }, @@ -236,7 +245,10 @@ return (/*b*/{ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 3 + line: 3, + column: 11, + endLine: 5, + endColumn: 13 } ] }, @@ -263,7 +275,10 @@ return { { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 3 + line: 3, + column: 11, + endLine: 5, + endColumn: 12 } ] }, @@ -290,7 +305,10 @@ return { { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", - line: 3 + line: 3, + column: 11, + endLine: 5, + endColumn: 12 } ] } diff --git a/tests/lib/rules/no-deprecated-delete-set.js b/tests/lib/rules/no-deprecated-delete-set.js index a38b6ecea..a2dae8fa7 100644 --- a/tests/lib/rules/no-deprecated-delete-set.js +++ b/tests/lib/rules/no-deprecated-delete-set.js @@ -135,11 +135,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 4 + line: 4, + column: 18, + endLine: 4, + endColumn: 22 }, { messageId: 'deprecated', - line: 5 + line: 5, + column: 18, + endLine: 5, + endColumn: 25 } ] }, @@ -157,11 +163,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 5 + line: 5, + column: 16, + endLine: 5, + endColumn: 20 }, { messageId: 'deprecated', - line: 6 + line: 6, + column: 16, + endLine: 6, + endColumn: 23 } ] }, @@ -176,8 +188,20 @@ tester.run('no-deprecated-delete-set', rule, { }) `, errors: [ - { messageId: 'deprecated', line: 4 }, - { messageId: 'deprecated', line: 5 } + { + messageId: 'deprecated', + line: 4, + column: 19, + endLine: 4, + endColumn: 23 + }, + { + messageId: 'deprecated', + line: 5, + column: 19, + endLine: 5, + endColumn: 26 + } ] }, { @@ -193,8 +217,20 @@ tester.run('no-deprecated-delete-set', rule, { `, errors: [ - { messageId: 'deprecated', line: 5 }, - { messageId: 'deprecated', line: 6 } + { + messageId: 'deprecated', + line: 5, + column: 20, + endLine: 5, + endColumn: 24 + }, + { + messageId: 'deprecated', + line: 6, + column: 20, + endLine: 6, + endColumn: 27 + } ] }, // from vue @@ -211,11 +247,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 4 + line: 4, + column: 17, + endLine: 4, + endColumn: 20 }, { messageId: 'deprecated', - line: 5 + line: 5, + column: 17, + endLine: 5, + endColumn: 23 } ] }, @@ -235,11 +277,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 6 + line: 6, + column: 15, + endLine: 6, + endColumn: 18 }, { messageId: 'deprecated', - line: 7 + line: 7, + column: 15, + endLine: 7, + endColumn: 18 } ] }, @@ -256,11 +304,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 14 }, { messageId: 'deprecated', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 14 } ] }, @@ -277,11 +331,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 12 }, { messageId: 'deprecated', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 12 } ] }, @@ -301,11 +361,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 6 + line: 6, + column: 15, + endLine: 6, + endColumn: 18 }, { messageId: 'deprecated', - line: 7 + line: 7, + column: 15, + endLine: 7, + endColumn: 18 } ] }, @@ -325,11 +391,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 6 + line: 6, + column: 15, + endLine: 6, + endColumn: 16 }, { messageId: 'deprecated', - line: 7 + line: 7, + column: 15, + endLine: 7, + endColumn: 16 } ] }, @@ -346,11 +418,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 14 }, { messageId: 'deprecated', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 14 } ] }, @@ -367,11 +445,17 @@ tester.run('no-deprecated-delete-set', rule, { errors: [ { messageId: 'deprecated', - line: 5 + line: 5, + column: 11, + endLine: 5, + endColumn: 16 }, { messageId: 'deprecated', - line: 6 + line: 6, + column: 11, + endLine: 6, + endColumn: 16 } ] } diff --git a/tests/lib/rules/no-deprecated-destroyed-lifecycle.js b/tests/lib/rules/no-deprecated-destroyed-lifecycle.js index a956b37ed..5f7e93dc1 100644 --- a/tests/lib/rules/no-deprecated-destroyed-lifecycle.js +++ b/tests/lib/rules/no-deprecated-destroyed-lifecycle.js @@ -118,12 +118,18 @@ ruleTester.run('no-deprecated-destroyed-lifecycle', rule, { { message: 'The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead.', - line: 4 + line: 4, + column: 9, + endLine: 4, + endColumn: 22 }, { message: 'The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead.', - line: 5 + line: 5, + column: 9, + endLine: 5, + endColumn: 18 } ] }, @@ -149,12 +155,18 @@ ruleTester.run('no-deprecated-destroyed-lifecycle', rule, { { message: 'The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead.', - line: 4 + line: 4, + column: 9, + endLine: 4, + endColumn: 22 }, { message: 'The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead.', - line: 5 + line: 5, + column: 9, + endLine: 5, + endColumn: 18 } ] }, @@ -198,12 +210,18 @@ ruleTester.run('no-deprecated-destroyed-lifecycle', rule, { { message: 'The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead.', - line: 12 + line: 12, + column: 9, + endLine: 12, + endColumn: 22 }, { message: 'The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead.', - line: 13 + line: 13, + column: 9, + endLine: 13, + endColumn: 18 } ] }, @@ -229,12 +247,18 @@ ruleTester.run('no-deprecated-destroyed-lifecycle', rule, { { message: 'The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead.', - line: 4 + line: 4, + column: 10, + endLine: 4, + endColumn: 25 }, { message: 'The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead.', - line: 5 + line: 5, + column: 10, + endLine: 5, + endColumn: 21 } ] }, @@ -260,12 +284,18 @@ ruleTester.run('no-deprecated-destroyed-lifecycle', rule, { { message: 'The `beforeDestroy` lifecycle hook is deprecated. Use `beforeUnmount` instead.', - line: 4 + line: 4, + column: 10, + endLine: 4, + endColumn: 25 }, { message: 'The `destroyed` lifecycle hook is deprecated. Use `unmounted` instead.', - line: 5 + line: 5, + column: 10, + endLine: 5, + endColumn: 21 } ] } diff --git a/tests/lib/rules/no-deprecated-dollar-listeners-api.js b/tests/lib/rules/no-deprecated-dollar-listeners-api.js index f9dd0ff40..2a4e72eb3 100644 --- a/tests/lib/rules/no-deprecated-dollar-listeners-api.js +++ b/tests/lib/rules/no-deprecated-dollar-listeners-api.js @@ -132,16 +132,16 @@ ruleTester.run('no-deprecated-dollar-listeners-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 3, column: 22, - messageId: 'deprecated', endLine: 3, endColumn: 32 }, { + messageId: 'deprecated', line: 9, column: 27, - messageId: 'deprecated', endLine: 9, endColumn: 37 } @@ -167,23 +167,23 @@ ruleTester.run('no-deprecated-dollar-listeners-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 3, column: 35, - messageId: 'deprecated', endLine: 3, endColumn: 45 }, { + messageId: 'deprecated', line: 4, column: 22, - messageId: 'deprecated', endLine: 4, endColumn: 32 }, { + messageId: 'deprecated', line: 10, column: 23, - messageId: 'deprecated', endLine: 10, endColumn: 33 } @@ -205,9 +205,11 @@ ruleTester.run('no-deprecated-dollar-listeners-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 7, column: 25, - messageId: 'deprecated' + endLine: 7, + endColumn: 35 } ] }, @@ -230,9 +232,11 @@ ruleTester.run('no-deprecated-dollar-listeners-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 8, column: 27, - messageId: 'deprecated' + endLine: 8, + endColumn: 37 } ] }, @@ -253,10 +257,18 @@ ruleTester.run('no-deprecated-dollar-listeners-api', rule, { `, errors: [ { - messageId: 'deprecated' + messageId: 'deprecated', + line: 7, + column: 29, + endLine: 7, + endColumn: 39 }, { - messageId: 'deprecated' + messageId: 'deprecated', + line: 8, + column: 31, + endLine: 8, + endColumn: 41 } ] } diff --git a/tests/lib/rules/no-deprecated-dollar-scopedslots-api.js b/tests/lib/rules/no-deprecated-dollar-scopedslots-api.js index 7dea6146e..c235698f8 100644 --- a/tests/lib/rules/no-deprecated-dollar-scopedslots-api.js +++ b/tests/lib/rules/no-deprecated-dollar-scopedslots-api.js @@ -142,16 +142,16 @@ ruleTester.run('no-deprecated-dollar-scopedslots-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 3, column: 22, - messageId: 'deprecated', endLine: 3, endColumn: 34 }, { + messageId: 'deprecated', line: 8, column: 25, - messageId: 'deprecated', endLine: 8, endColumn: 37 } @@ -191,23 +191,23 @@ ruleTester.run('no-deprecated-dollar-scopedslots-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 3, column: 31, - messageId: 'deprecated', endLine: 3, endColumn: 43 }, { + messageId: 'deprecated', line: 4, column: 22, - messageId: 'deprecated', endLine: 4, endColumn: 34 }, { + messageId: 'deprecated', line: 10, column: 23, - messageId: 'deprecated', endLine: 10, endColumn: 35 } @@ -237,9 +237,11 @@ ruleTester.run('no-deprecated-dollar-scopedslots-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 6, column: 23, - messageId: 'deprecated' + endLine: 6, + endColumn: 35 } ] }, @@ -273,9 +275,11 @@ ruleTester.run('no-deprecated-dollar-scopedslots-api', rule, { `, errors: [ { + messageId: 'deprecated', line: 7, column: 25, - messageId: 'deprecated' + endLine: 7, + endColumn: 37 } ] }, @@ -307,10 +311,18 @@ ruleTester.run('no-deprecated-dollar-scopedslots-api', rule, { `, errors: [ { - messageId: 'deprecated' + messageId: 'deprecated', + line: 6, + column: 27, + endLine: 6, + endColumn: 39 }, { - messageId: 'deprecated' + messageId: 'deprecated', + line: 7, + column: 29, + endLine: 7, + endColumn: 41 } ] } diff --git a/tests/lib/rules/no-deprecated-events-api.js b/tests/lib/rules/no-deprecated-events-api.js index c78577d4b..75c8b7d91 100644 --- a/tests/lib/rules/no-deprecated-events-api.js +++ b/tests/lib/rules/no-deprecated-events-api.js @@ -139,7 +139,10 @@ ruleTester.run('no-deprecated-events-api', rule, { { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - line: 4 + line: 4, + column: 18, + endLine: 4, + endColumn: 21 } ] }, @@ -157,7 +160,10 @@ ruleTester.run('no-deprecated-events-api', rule, { { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - line: 4 + line: 4, + column: 18, + endLine: 4, + endColumn: 22 } ] }, @@ -177,7 +183,10 @@ ruleTester.run('no-deprecated-events-api', rule, { { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - line: 4 + line: 4, + column: 18, + endLine: 4, + endColumn: 23 } ] }, @@ -198,7 +207,10 @@ ruleTester.run('no-deprecated-events-api', rule, { { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - line: 5 + line: 5, + column: 16, + endLine: 5, + endColumn: 19 } ] }, @@ -215,9 +227,30 @@ ruleTester.run('no-deprecated-events-api', rule, { `, languageOptions, errors: [ - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.' + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 4, + column: 19, + endLine: 4, + endColumn: 22 + }, + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 5, + column: 19, + endLine: 5, + endColumn: 23 + }, + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 6, + column: 19, + endLine: 6, + endColumn: 24 + } ] }, { @@ -233,9 +266,30 @@ ruleTester.run('no-deprecated-events-api', rule, { `, languageOptions, errors: [ - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', - 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.' + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 4, + column: 21, + endLine: 4, + endColumn: 24 + }, + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 5, + column: 21, + endLine: 5, + endColumn: 25 + }, + { + message: + 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', + line: 6, + column: 21, + endLine: 6, + endColumn: 26 + } ] } ] diff --git a/tests/lib/rules/no-deprecated-filter.js b/tests/lib/rules/no-deprecated-filter.js index cf2a33518..54eb4b4f1 100644 --- a/tests/lib/rules/no-deprecated-filter.js +++ b/tests/lib/rules/no-deprecated-filter.js @@ -36,37 +36,93 @@ ruleTester.run('no-deprecated-filter', rule, { { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 14, + endLine: 1, + endColumn: 26 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 14, + endLine: 1, + endColumn: 29 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 14, + endLine: 1, + endColumn: 37 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 43, + endLine: 1, + endColumn: 55 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 27, + endLine: 1, + endColumn: 39 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 27, + endLine: 1, + endColumn: 44 + } + ] }, { filename: 'test.vue', code: '', - errors: ['Filters are deprecated.'] + errors: [ + { + message: 'Filters are deprecated.', + line: 1, + column: 27, + endLine: 1, + endColumn: 50 + } + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-functional-template.js b/tests/lib/rules/no-deprecated-functional-template.js index 00cf539ff..fae03fdb7 100644 --- a/tests/lib/rules/no-deprecated-functional-template.js +++ b/tests/lib/rules/no-deprecated-functional-template.js @@ -33,9 +33,9 @@ ruleTester.run('no-deprecated-functional-template', rule, { code: '', errors: [ { + messageId: 'unexpected', line: 1, column: 11, - messageId: 'unexpected', endLine: 1, endColumn: 21 } @@ -46,9 +46,11 @@ ruleTester.run('no-deprecated-functional-template', rule, { code: '', errors: [ { + messageId: 'unexpected', line: 1, column: 11, - messageId: 'unexpected' + endLine: 1, + endColumn: 21 } ] } diff --git a/tests/lib/rules/no-deprecated-html-element-is.js b/tests/lib/rules/no-deprecated-html-element-is.js index be8ea3e71..a108f224f 100644 --- a/tests/lib/rules/no-deprecated-html-element-is.js +++ b/tests/lib/rules/no-deprecated-html-element-is.js @@ -43,9 +43,9 @@ ruleTester.run('no-deprecated-html-element-is', rule, { code: '', errors: [ { + messageId: 'unexpected', line: 1, column: 16, - messageId: 'unexpected', endLine: 1, endColumn: 24 } @@ -56,9 +56,11 @@ ruleTester.run('no-deprecated-html-element-is', rule, { code: '', errors: [ { + messageId: 'unexpected', line: 1, column: 16, - messageId: 'unexpected' + endLine: 1, + endColumn: 25 } ] } diff --git a/tests/lib/rules/no-deprecated-inline-template.js b/tests/lib/rules/no-deprecated-inline-template.js index fad9c77a7..4c278d5a1 100644 --- a/tests/lib/rules/no-deprecated-inline-template.js +++ b/tests/lib/rules/no-deprecated-inline-template.js @@ -48,12 +48,28 @@ ruleTester.run('no-deprecated-inline-template', rule, { { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 25, + endLine: 1, + endColumn: 40 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 25, + endLine: 1, + endColumn: 40 + } + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-props-default-this.js b/tests/lib/rules/no-deprecated-props-default-this.js index b887868d5..ed0b2005d 100644 --- a/tests/lib/rules/no-deprecated-props-default-this.js +++ b/tests/lib/rules/no-deprecated-props-default-this.js @@ -199,8 +199,22 @@ ruleTester.run('no-deprecated-props-default-this', rule, { `, errors: [ - 'Props default value factory functions no longer have access to `this`.', - 'Props default value factory functions no longer have access to `this`.' + { + message: + 'Props default value factory functions no longer have access to `this`.', + line: 9, + column: 24, + endLine: 9, + endColumn: 28 + }, + { + message: + 'Props default value factory functions no longer have access to `this`.', + line: 14, + column: 24, + endLine: 14, + endColumn: 28 + } ] } ] diff --git a/tests/lib/rules/no-deprecated-router-link-tag-prop.js b/tests/lib/rules/no-deprecated-router-link-tag-prop.js index cf022f79a..c95345486 100644 --- a/tests/lib/rules/no-deprecated-router-link-tag-prop.js +++ b/tests/lib/rules/no-deprecated-router-link-tag-prop.js @@ -103,7 +103,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 21 + column: 21, + endLine: 3, + endColumn: 24 } ] }, @@ -119,7 +121,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'router-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 22 + column: 22, + endLine: 3, + endColumn: 25 } ] }, @@ -136,7 +140,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 21 + column: 21, + endLine: 3, + endColumn: 24 } ] }, @@ -153,7 +159,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 21 + column: 21, + endLine: 3, + endColumn: 24 } ] }, @@ -170,7 +178,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'router-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 22 + column: 22, + endLine: 3, + endColumn: 25 } ] }, @@ -186,7 +196,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 22 + column: 22, + endLine: 3, + endColumn: 25 } ] }, @@ -202,7 +214,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'router-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 23 + column: 23, + endLine: 3, + endColumn: 26 } ] }, @@ -219,7 +233,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 22 + column: 22, + endLine: 3, + endColumn: 25 } ] }, @@ -236,7 +252,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'router-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 23 + column: 23, + endLine: 3, + endColumn: 26 } ] }, @@ -253,7 +271,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 19 + column: 19, + endLine: 3, + endColumn: 22 } ] }, @@ -270,7 +290,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'nuxt-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 20 + column: 20, + endLine: 3, + endColumn: 23 } ] }, @@ -287,7 +309,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.", line: 3, - column: 20 + column: 20, + endLine: 3, + endColumn: 23 } ] }, @@ -304,7 +328,9 @@ tester.run('no-deprecated-router-link-tag-prop', rule, { message: "'tag' property on 'nuxt-link' component is deprecated. Use scoped slots instead.", line: 3, - column: 21 + column: 21, + endLine: 3, + endColumn: 24 } ] } diff --git a/tests/lib/rules/no-deprecated-scope-attribute.js b/tests/lib/rules/no-deprecated-scope-attribute.js index f823a6878..845447cf6 100644 --- a/tests/lib/rules/no-deprecated-scope-attribute.js +++ b/tests/lib/rules/no-deprecated-scope-attribute.js @@ -66,7 +66,10 @@ tester.run('no-deprecated-scope-attribute', rule, { errors: [ { message: '`scope` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -90,7 +93,10 @@ tester.run('no-deprecated-scope-attribute', rule, { errors: [ { message: '`scope` attributes are deprecated.', - line: 4 + line: 4, + column: 33, + endLine: 4, + endColumn: 38 } ] } diff --git a/tests/lib/rules/no-deprecated-slot-attribute.js b/tests/lib/rules/no-deprecated-slot-attribute.js index 2fd5fa401..61f8f25d7 100644 --- a/tests/lib/rules/no-deprecated-slot-attribute.js +++ b/tests/lib/rules/no-deprecated-slot-attribute.js @@ -55,6 +55,42 @@ tester.run('no-deprecated-slot-attribute', rule, { `, options: [{ ignore: ['one', 'two', 'my-component'] }] + }, + { + code: ``, + options: [{ ignore: ['/one/', '/^Two$/i', '/^my-.*/i'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['LinkList'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['/^Link/'] }] } ], invalid: [ @@ -74,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 } ] }, @@ -94,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 } ] }, @@ -114,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 } ] }, @@ -134,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 } ] }, @@ -154,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 } ] }, @@ -173,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 } ] }, @@ -209,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 } ] }, @@ -224,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 } ] }, @@ -244,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 } ] }, @@ -259,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 } ] }, @@ -274,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 } ] }, @@ -289,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 } ] }, @@ -304,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 } ] }, @@ -324,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 } ] }, @@ -344,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 } ] }, @@ -364,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 } ] }, @@ -385,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: ` @@ -404,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: ` @@ -423,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 @@ -458,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 } ] }, @@ -490,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 + } ] }, { @@ -508,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 + } ] }, { @@ -536,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 + } ] }, { @@ -554,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 + } ] }, { @@ -582,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 + } ] }, { @@ -610,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 + } ] }, { @@ -642,7 +840,175 @@ 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: ` + `, + output: ` + `, + options: [ + { + ignore: ['/one/'] + } + ], + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 7, + endLine: 7, + column: 16, + endColumn: 20 + } + ] + }, + { + code: ` + `, + output: ` + `, + options: [ + { + ignore: ['/^one$/'] + } + ], + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 7, + endLine: 7, + column: 16, + endColumn: 20 + } + ] + }, + { + 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: ` @@ -667,7 +1033,15 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - errors: ['`slot` attributes are deprecated.'] + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 6, + column: 13, + endLine: 6, + endColumn: 18 + } + ] }, { code: ` @@ -680,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-dupe-keys.js b/tests/lib/rules/no-dupe-keys.js index 124442ec2..2df95908c 100644 --- a/tests/lib/rules/no-dupe-keys.js +++ b/tests/lib/rules/no-dupe-keys.js @@ -466,7 +466,7 @@ ruleTester.run('no-dupe-keys', rule, { { filename: 'test.vue', code: ` - + `, @@ -475,7 +475,7 @@ ruleTester.run('no-dupe-keys', rule, { { filename: 'test.vue', code: ` - + `, @@ -500,6 +500,17 @@ ruleTester.run('no-dupe-keys', rule, { parser: require('vue-eslint-parser'), parserOptions: { parser: require.resolve('@typescript-eslint/parser') } } + }, + { + filename: 'test.vue', + code: ` + + `, + languageOptions: { parser: require('vue-eslint-parser') } } ], @@ -1105,6 +1116,24 @@ ruleTester.run('no-dupe-keys', rule, { line: 5 } ] + }, + { + filename: 'test.vue', + code: ` + + `, + languageOptions: { parser: require('vue-eslint-parser') }, + errors: [ + { + message: + "Duplicate key 'bar'. May cause name collision in script or template tag.", + line: 5 + } + ] } ] }) diff --git a/tests/lib/rules/no-export-in-script-setup.js b/tests/lib/rules/no-export-in-script-setup.js index 8703dc74a..bf24b8682 100644 --- a/tests/lib/rules/no-export-in-script-setup.js +++ b/tests/lib/rules/no-export-in-script-setup.js @@ -92,20 +92,62 @@ ruleTester.run('no-export-in-script-setup', rule, { export * from 'foo' export default {} export class A {} + export const test = '123' + export function foo() {} + const a = 1 + export { a } + export { fao } from 'bar' `, errors: [ { message: '` `, + ` + + `, + ` + + `, ` ` + }, + { + filename: 'multiple-scripts-setup-first.vue', + code: ` + + + + + + ` + }, + { + filename: 'multiple-scripts-setup-last.vue', + code: ` + + + + + + ` } ], invalid: [ @@ -420,6 +454,60 @@ tester.run('prefer-use-template-ref', rule, { column: 28 } ] + }, + { + filename: 'multiple-scripts-setup-first.vue', + code: ` + + + + + + `, + errors: [ + { + messageId: 'preferUseTemplateRef', + data: { + name: 'ref' + }, + line: 8, + column: 20 + } + ] + }, + { + filename: 'multiple-scripts-setup-last.vue', + code: ` + + + + + + `, + errors: [ + { + messageId: 'preferUseTemplateRef', + data: { + name: 'ref' + }, + line: 12, + column: 20 + } + ] } ] }) diff --git a/tests/lib/rules/require-default-prop.js b/tests/lib/rules/require-default-prop.js index e352eddf3..43160dfda 100644 --- a/tests/lib/rules/require-default-prop.js +++ b/tests/lib/rules/require-default-prop.js @@ -388,6 +388,31 @@ ruleTester.run('require-default-prop', rule, { parser: require('vue-eslint-parser'), ...languageOptions } + }, + { + filename: 'test.vue', + code: ` + + `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + } + }, + { + filename: 'test.vue', + code: ` + + `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions, + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + } } ], @@ -700,6 +725,26 @@ ruleTester.run('require-default-prop', rule, { line: 3 } ] + }, + { + // https://github.com/vuejs/eslint-plugin-vue/issues/2725 + filename: 'type-with-props-destructure.vue', + code: ` + + `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions, + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, + errors: [ + { + message: "Prop 'foo' requires default value to be set.", + line: 3 + } + ] } ] }) 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 new file mode 100644 index 000000000..1f3b4a129 --- /dev/null +++ b/tools/generate-typegen.mjs @@ -0,0 +1,14 @@ +import fs from 'node:fs/promises' +import { pluginsToRulesDTS } from 'eslint-typegen/core' +import plugin from '../lib/index.js' + +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' + }, + }, +}); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy