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/.changeset/great-ravens-happen.md b/.changeset/great-ravens-happen.md new file mode 100644 index 000000000..eea070fd5 --- /dev/null +++ b/.changeset/great-ravens-happen.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-vue": minor +--- + +Added [`@stylistic/eslint-plugin`](https://eslint.style/) as optional peer dependency diff --git a/.changeset/purple-lights-invite.md b/.changeset/purple-lights-invite.md new file mode 100644 index 000000000..80aa90b8d --- /dev/null +++ b/.changeset/purple-lights-invite.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-vue': minor +--- + +Added `ignorePattern` option to [`vue/no-v-html`](https://eslint.vuejs.org/rules/no-v-html.html) diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index cd2a71931..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,133 +0,0 @@ -workflows: - version: 2 - node-multi-build: - jobs: - - eslint-v6 - - eslint-v7 - - ts-eslint-v4 - - node-v14 - - node-v16 - - lint - -version: 2 -jobs: - node-base: &node-base - docker: - - image: node - steps: - - run: - name: Versions - command: npm version - - checkout - # - restore_cache: - # keys: - # - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - - run: - name: Install dependencies - command: npm install --legacy-peer-deps - - run: - name: Test - command: npm test - # - save_cache: - # key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - # paths: - # - node_modules - - eslint-v6: - docker: - - image: node:14 - steps: - - run: - name: Versions - command: npm version - - checkout - - run: - name: Install eslint@6 - command: | - npm install --save-exact eslint@6.8.0 @typescript-eslint/parser@5 - - run: - name: Install dependencies - command: npm install - - run: - name: Test - command: npm test - eslint-v7: - docker: - - image: node:14 - steps: - - run: - name: Versions - command: npm version - - checkout - - run: - name: Install eslint@7 - command: | - npm install eslint@7 @typescript-eslint/parser@5 - - run: - name: Install dependencies - command: npm install - - run: - name: Test - command: npm test - ts-eslint-v4: - docker: - - image: node:14 - steps: - - run: - name: Versions - command: npm version - - checkout - - run: - name: Install @typescript-eslint/parser@4 eslint@7 typescript@4.7 - command: | - npm install @typescript-eslint/parser@4 eslint@7 typescript@4.7 --save-exact - - run: - name: Install dependencies - command: npm install - - run: - name: Test - command: npm test - node-v14: - docker: - - image: node:14 - steps: - - run: - name: Versions - command: npm version - - checkout - - run: - name: Install @typescript-eslint/parser@5 - command: | - npm install @typescript-eslint/parser@5 --save-exact - - run: - name: Install dependencies - command: npm install - - run: - name: Test - command: npm test - node-v16: - <<: *node-base - docker: - - image: node:16 - - lint: - docker: - - image: node:16 - steps: - - run: - name: Versions - command: npm version - - checkout - - restore_cache: - keys: - - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - - run: - name: Install dependencies - command: npm install - - save_cache: - key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - paths: - - node_modules - - run: - name: Lint - command: npm run lint diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1e7f59ac7..c4d031e9c 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ github: -- ota-meshi -- FloEdelmann + - ota-meshi + - FloEdelmann diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f1169f466..08d755127 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,6 +26,7 @@ about: Create a report to help us improve - **ESLint version:** - **eslint-plugin-vue version:** +- **Vue version:** - **Node version:** - **Operating System:** diff --git a/.github/ISSUE_TEMPLATE/change.md b/.github/ISSUE_TEMPLATE/change.md index a6a4a7dc0..02397f6cd 100644 --- a/.github/ISSUE_TEMPLATE/change.md +++ b/.github/ISSUE_TEMPLATE/change.md @@ -13,6 +13,7 @@ about: Request a change that is not a bug fix, rule change, or new rule - **ESLint version:** - **eslint-plugin-vue version:** +- **Vue version:** - **Node version:** **The problem you want to solve.** diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index afb8b9ad4..fede1a47a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,9 +1,13 @@ name: CI on: push: - branches: [master] + branches: + - 'master' pull_request: - branches: [master] + types: + - 'opened' + - 'synchronize' + - 'reopened' permissions: contents: read @@ -13,48 +17,94 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Node.js - uses: actions/setup-node@v3 - - name: Install Packages - run: npm install --legacy-peer-deps - - name: Lint - run: npm run lint + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install --legacy-peer-deps + - name: Lint + run: npm run lint test: name: Test strategy: matrix: - node: [17, 18, 20] - os: [ubuntu-latest] + node: [18, 20, 21, 'lts/*'] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install Packages + run: npm install + - name: Test + run: npm test - runs-on: ${{ matrix.os }} + test-with-eslint-v8: + name: Test with ESLint v8 + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - - name: Install Packages - run: npm install --legacy-peer-deps - - name: Test - run: npm test + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js v18 + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install Packages + run: npm install + - name: Install ESLint v8 + run: npm install --save-dev eslint@8 --force + - name: Test + run: npm test - test-for-ts-eslint-v5: - name: Test + test-without-eslint-stylistic: + name: Test without ESLint Stylistic + 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: Uninstall @stylistic/eslint-plugin + run: npm uninstall @stylistic/eslint-plugin + - name: Test + run: npm test + + test-with-old-eslint-stylistic: + name: Test with old ESLint Stylistic + strategy: + matrix: + stylistic: [2, 3, 4] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install + - name: Install @stylistic/eslint-plugin v${{ matrix.stylistic }} + run: npm install -D @stylistic/eslint-plugin@${{ matrix.stylistic }} --force + - name: Test + run: npm test + + test-with-typescript-eslint-v7: + name: Test with typescript-eslint v7 runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install Packages - run: npm install --legacy-peer-deps - - name: Install typescript-eslint v5 - run: npm install -D @typescript-eslint/parser - - name: Test - run: npm test + - 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 v7 + run: npm install -D @typescript-eslint/parser@7 --force + - 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 new file mode 100644 index 000000000..31f881b1d --- /dev/null +++ b/.github/workflows/check-for-resources-update.yml @@ -0,0 +1,31 @@ +name: Check for utils resources update +on: + workflow_dispatch: null + schedule: + - cron: 0 0 * * 0 # At 00:00 on Sunday, see https://crontab.guru/#0_0_*_*_0 + +permissions: + 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 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install Packages + run: npm install + - name: Update + run: npm run update-resources + - uses: peter-evans/create-pull-request@v7 + with: + commit-message: Updates resources + branch: update-resources + branch-suffix: timestamp + title: Updates resources 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/.markdownlint.yml b/.markdownlint.yml index 42e207971..6591a3543 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -15,7 +15,7 @@ code-block-style: code-fence-style: style: backtick emphasis-style: - style: asterisk + style: underscore heading-style: style: atx hr-style: diff --git a/.markdownlintignore b/.markdownlintignore index 3c3629e64..e7becf85b 100644 --- a/.markdownlintignore +++ b/.markdownlintignore @@ -1 +1,2 @@ node_modules +CHANGELOG.md diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..d341f1772 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +tests/fixtures/ +.github/ISSUE_TEMPLATE/*.md diff --git a/.vscode/launch.json b/.vscode/launch.json index 324a79864..171c80066 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,12 +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/.vscode/settings.json b/.vscode/settings.json index 3c179f5a7..8c7be0b23 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,21 +1,14 @@ { - "editor.tabSize": 2, - "eslint.experimental.useFlatConfig": true, - "eslint.validate": [ - "javascript", - "javascriptreact", - "vue", - "json", - "jsonc" - ], - "typescript.tsdk": "./node_modules/typescript/lib", - "vetur.validation.script": false, - "[typescript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, + "editor.tabSize": 2, + "eslint.validate": ["javascript", "javascriptreact", "vue", "json", "jsonc", "markdown"], + "typescript.tsdk": "./node_modules/typescript/lib", + "vetur.validation.script": false, + "[typescript]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..71932ee19 --- /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](https://github.com/antfu/eslint-typegen) ([#2790](https://github.com/vuejs/eslint-plugin-vue/pull/2790)) + +- Fixed inconsistent quotes in [`vue/block-lang`](https://eslint.vuejs.org/rules/block-lang.html) error messages ([#2805](https://github.com/vuejs/eslint-plugin-vue/pull/2805)) + +## 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 cacd80209..01bc6b687 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 @@ -13,7 +13,14 @@ Please refer to the [official website](https://eslint.vuejs.org). ## :anchor: Versioning Policy -This plugin follows [Semantic Versioning](https://semver.org) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). +This plugin follows [Semantic Versioning]. +However, please note that we do not follow [ESLint's Semantic Versioning Policy]. +In minor version releases, this plugin may change the sharable configs provided by the plugin or the default behavior of the plugin's rules in order to add features to the plugin. Because we want to add many features to the plugin soon, so that users can easily take advantage of new features in Vue and Nuxt. + +According to our policy, any minor update may report more linting errors than the previous release. As such, we recommend using the [tilde (`~`)](https://semver.npmjs.com/#syntax-examples) in `package.json` to guarantee the results of your builds. + +[Semantic Versioning]: https://semver.org/ +[ESLint's Semantic Versioning Policy]: https://github.com/eslint/eslint#semantic-versioning-policy ## :newspaper: Releases @@ -27,13 +34,13 @@ Contributing is welcome! See the [ESLint Vue Plugin Developer Guide](https://esl Be sure to read the [official ESLint guide](https://eslint.org/docs/developer-guide/working-with-rules) before you start writing a new rule. -To see what an abstract syntax tree (AST) of your code looks like, you may use [AST Explorer](https://astexplorer.net). After opening [AST Explorer](https://astexplorer.net), select `Vue` as the syntax and `vue-eslint-parser` as the parser. +To see what an abstract syntax tree (AST) of your code looks like, you may use [AST Explorer](https://astexplorer.net). After opening [AST Explorer](https://astexplorer.net), select `Vue` as the syntax and [`vue-eslint-parser`](https://github.com/vuejs/vue-eslint-parser) as the parser. The default JavaScript parser must be replaced because [Vue.js single file components](https://vuejs.org/guide/scaling-up/sfc.html) are not plain JavaScript, but a custom file format. [`vue-eslint-parser`](https://github.com/vuejs/vue-eslint-parser) is a replacement parser that generates an enhanced AST with nodes that represent specific parts of the template syntax, as well as the contents of the ` @@ -107,7 +108,7 @@ export default { - + @@ -130,11 +131,11 @@ export default { ```vue @@ -150,7 +151,7 @@ export default { diff --git a/docs/rules/component-options-name-casing.md b/docs/rules/component-options-name-casing.md index d37ee9fce..469865478 100644 --- a/docs/rules/component-options-name-casing.md +++ b/docs/rules/component-options-name-casing.md @@ -5,11 +5,12 @@ title: vue/component-options-name-casing description: enforce the casing of component name in `components` options since: v8.2.0 --- + # vue/component-options-name-casing > enforce the casing of component name in `components` options -- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule. +- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix-problems) can automatically fix some of the problems reported by this rule. - :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). ## :book: Rule Details diff --git a/docs/rules/component-tags-order.md b/docs/rules/component-tags-order.md index 22b161aa0..a5037cdee 100644 --- a/docs/rules/component-tags-order.md +++ b/docs/rules/component-tags-order.md @@ -5,13 +5,12 @@ title: vue/component-tags-order description: enforce order of component top-level elements since: v6.1.0 --- + # vue/component-tags-order > enforce order of component top-level elements -- :no_entry_sign: This rule was **deprecated** and replaced by [vue/block-order](block-order.md) rule. -- :gear: This rule is included in `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`. -- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule. +- :no_entry: This rule was **removed** in eslint-plugin-vue v10.0.0 and replaced by [vue/block-order](block-order.md) rule. ## :book: Rule Details diff --git a/docs/rules/custom-event-name-casing.md b/docs/rules/custom-event-name-casing.md index 29afde056..a57e0eb80 100644 --- a/docs/rules/custom-event-name-casing.md +++ b/docs/rules/custom-event-name-casing.md @@ -5,6 +5,7 @@ title: vue/custom-event-name-casing description: enforce specific casing for custom event name since: v7.0.0 --- + # vue/custom-event-name-casing > enforce specific casing for custom event name @@ -42,7 +43,7 @@ This rule enforces camelCase by default. +``` + + + ## :couple: Related Rules - [vue/define-props-declaration](./define-props-declaration.md) diff --git a/docs/rules/define-macros-order.md b/docs/rules/define-macros-order.md index 37074f05c..14729f991 100644 --- a/docs/rules/define-macros-order.md +++ b/docs/rules/define-macros-order.md @@ -2,30 +2,34 @@ pageClass: rule-details sidebarDepth: 0 title: vue/define-macros-order -description: enforce order of `defineEmits` and `defineProps` compiler macros +description: enforce order of compiler macros (`defineProps`, `defineEmits`, etc.) since: v8.7.0 --- + # vue/define-macros-order -> enforce order of `defineEmits` and `defineProps` compiler macros +> enforce order of compiler macros (`defineProps`, `defineEmits`, etc.) -- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule. +- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix-problems) can automatically fix some of the problems reported by this rule. +- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). ## :book: Rule Details -This rule reports the `defineProps` and `defineEmits` compiler macros when they are not the first statements in ` ``` - + ```vue +``` + + + +### `{ "order": ["definePage", "defineModel", "defineCustom", "defineEmits", "defineSlots"] }` + + + +```vue + + +``` + + + + + +```vue + + +``` + + + +### `{ "defineExposeLast": true }` + + + +```vue + + +``` + + + + + +```vue + + ``` diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md index 8b88f1ce5..40c5ea0b0 100644 --- a/docs/rules/define-props-declaration.md +++ b/docs/rules/define-props-declaration.md @@ -5,6 +5,7 @@ title: vue/define-props-declaration description: enforce declaration style of `defineProps` since: v9.5.0 --- + # vue/define-props-declaration > enforce declaration style of `defineProps` @@ -21,7 +22,7 @@ This rule only works in setup script and `lang="ts"`. diff --git a/docs/rules/define-props-destructuring.md b/docs/rules/define-props-destructuring.md new file mode 100644 index 000000000..e3c2b2745 --- /dev/null +++ b/docs/rules/define-props-destructuring.md @@ -0,0 +1,98 @@ +--- +pageClass: rule-details +sidebarDepth: 0 +title: vue/define-props-destructuring +description: enforce consistent style for props destructuring +since: v10.1.0 +--- + +# vue/define-props-destructuring + +> enforce consistent style for props destructuring + +## :book: Rule Details + +This rule enforces a consistent style for handling Vue 3 Composition API props, allowing you to choose between requiring destructuring or prohibiting it. + +By default, the rule requires you to use destructuring syntax when using `defineProps` instead of storing props in a variable and warns against combining `withDefaults` with destructuring. + + + +```vue + +``` + + + +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/dot-location.md b/docs/rules/dot-location.md index cf4095d77..101b58776 100644 --- a/docs/rules/dot-location.md +++ b/docs/rules/dot-location.md @@ -5,18 +5,26 @@ title: vue/dot-location description: Enforce consistent newlines before and after dots in ` `, 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 @@ -675,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 + } ] }, { @@ -695,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 + } ] }, { @@ -715,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 d79e82eff..118cf6353 100644 --- a/tests/lib/rules/multiline-ternary.js +++ b/tests/lib/rules/multiline-ternary.js @@ -4,13 +4,12 @@ */ '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({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { + languageOptions: { + parser: require('vue-eslint-parser'), ecmaVersion: 2020, sourceType: 'module' } @@ -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: ` - ` + `, + { + // https://github.com/vuejs/eslint-plugin-vue/issues/2681 + code: ` + + `, + options: [{ allowlist: ['foo', 'foo_bar'] }] + }, + { + code: ` + + `, + options: [{ allowlist: ['@@'] }] + }, + // regex + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\d+/g`] }] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\$\w+/`] }] + }, + { + code: ` + + `, + options: [{ allowlist: [String.raw`/\d+/`, 'foo'] }] + } ], invalid: [ { @@ -224,6 +271,24 @@ tester.run('no-bare-strings-in-template', rule, { } ] }, + { + code: ` + + `, + options: [{ allowlist: ['foo'] }], + errors: [ + { + messageId: 'unexpected', + line: 4, + column: 13, + endLine: 4, + endColumn: 20 + } + ] + }, { code: ` `, + { + code: ``, + options: [{ ignore: ['one', 'two', 'my-component'] }] + }, + { + code: ``, + options: [{ ignore: ['/one/', '/^Two$/i', '/^my-.*/i'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['LinkList'] }] + }, + { + code: ``, + options: [{ ignoreParents: ['/^Link/'] }] + } ], invalid: [ { @@ -65,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 } ] }, @@ -85,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 } ] }, @@ -105,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 } ] }, @@ -125,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 } ] }, @@ -145,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 } ] }, @@ -164,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 } ] }, @@ -200,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 } ] }, @@ -215,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 } ] }, @@ -235,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 } ] }, @@ -250,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 } ] }, @@ -265,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 } ] }, @@ -280,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 } ] }, @@ -295,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 } ] }, @@ -309,13 +405,16 @@ tester.run('no-deprecated-slot-attribute', rule, { output: ` `, errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 26 } ] }, @@ -326,11 +425,19 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - output: null, + output: ` + `, errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 18 } ] }, @@ -341,11 +448,19 @@ tester.run('no-deprecated-slot-attribute', rule, { `, - output: null, + output: ` + `, errors: [ { message: '`slot` attributes are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 19 } ] }, @@ -366,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: ` @@ -385,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: ` @@ -404,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 @@ -439,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 } ] }, @@ -471,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 + } ] }, { @@ -489,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 + } ] }, { @@ -517,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 + } ] }, { @@ -535,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 + } ] }, { @@ -563,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 + } ] }, { @@ -591,8 +796,272 @@ 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 + } + ] + }, + { + code: ` + `, + output: ` + `, + options: [ + { + ignore: ['one'] + } + ], + 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: ` + `, + output: ` + `, + errors: [ + { + message: '`slot` attributes are deprecated.', + line: 6, + column: 13, + endLine: 6, + endColumn: 18 + } + ] + }, + { + code: ` + `, + output: null, + 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 728aaccd3..7b9eb870b 100644 --- a/tests/lib/rules/no-deprecated-slot-scope-attribute.js +++ b/tests/lib/rules/no-deprecated-slot-scope-attribute.js @@ -1,13 +1,10 @@ 'use strict' -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/no-deprecated-slot-scope-attribute') const tester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { - ecmaVersion: 2015 - } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) tester.run('no-deprecated-slot-scope-attribute', rule, { @@ -69,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 } ] }, @@ -89,11 +89,13 @@ tester.run('no-deprecated-slot-scope-attribute', rule, { errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 21, + endLine: 4, + endColumn: 31 } ] }, - // cannot fix { code: ` `, - output: null, + output: ` + `, errors: [ { message: '`slot-scope` are deprecated.', - line: 4 + line: 4, + column: 14, + endLine: 4, + endColumn: 24 } ] }, @@ -120,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 } ] }, @@ -135,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 } ] }, @@ -149,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: ` @@ -162,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 c02342a86..355d1a86c 100644 --- a/tests/lib/rules/no-deprecated-v-bind-sync.js +++ b/tests/lib/rules/no-deprecated-v-bind-sync.js @@ -5,11 +5,10 @@ 'use strict' const rule = require('../../../lib/rules/no-deprecated-v-bind-sync') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2015 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) ruleTester.run('no-deprecated-v-bind-sync', rule, { @@ -38,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 + } ] }, { @@ -46,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 + } ] }, { @@ -54,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 + } ] }, { @@ -62,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 + } ] }, { @@ -70,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 + } ] }, { @@ -78,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 + } ] }, { @@ -86,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 + } ] }, { @@ -95,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 + } ] }, { @@ -104,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 + } ] }, { @@ -113,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 + } ] }, { @@ -122,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 + } ] }, { @@ -131,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 + } ] }, { @@ -140,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 + } ] }, { @@ -149,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 + } ] }, { @@ -158,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 + } ] }, { @@ -167,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 + } ] }, { @@ -176,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 + } ] }, { @@ -185,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-deprecated-v-is.js b/tests/lib/rules/no-deprecated-v-is.js index cdc47b9aa..3935c9b39 100644 --- a/tests/lib/rules/no-deprecated-v-is.js +++ b/tests/lib/rules/no-deprecated-v-is.js @@ -1,13 +1,10 @@ 'use strict' -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/no-deprecated-v-is') const tester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { - ecmaVersion: 2015 - } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) tester.run('no-deprecated-v-is', rule, { @@ -28,7 +25,10 @@ tester.run('no-deprecated-v-is', rule, { errors: [ { message: '`v-is` directive is deprecated.', - line: 3 + line: 3, + column: 14, + endLine: 3, + endColumn: 18 } ] } diff --git a/tests/lib/rules/no-deprecated-v-on-native-modifier.js b/tests/lib/rules/no-deprecated-v-on-native-modifier.js index 1342f25bf..b9863d9ed 100644 --- a/tests/lib/rules/no-deprecated-v-on-native-modifier.js +++ b/tests/lib/rules/no-deprecated-v-on-native-modifier.js @@ -5,11 +5,10 @@ 'use strict' const rule = require('../../../lib/rules/no-deprecated-v-on-native-modifier') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2015 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) ruleTester.run('no-deprecated-v-on-native-modifier', rule, { diff --git a/tests/lib/rules/no-deprecated-v-on-number-modifiers.js b/tests/lib/rules/no-deprecated-v-on-number-modifiers.js index 986b5e335..f039d1162 100644 --- a/tests/lib/rules/no-deprecated-v-on-number-modifiers.js +++ b/tests/lib/rules/no-deprecated-v-on-number-modifiers.js @@ -5,11 +5,10 @@ 'use strict' const rule = require('../../../lib/rules/no-deprecated-v-on-number-modifiers') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2015 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { @@ -70,7 +69,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 29, + endLine: 1, + endColumn: 31 + } ] }, { @@ -79,7 +85,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 29, + endLine: 1, + endColumn: 31 + } ] }, { @@ -88,7 +101,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 37, + endLine: 1, + endColumn: 39 + } ] }, { @@ -97,7 +117,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 36, + endLine: 1, + endColumn: 38 + } ] }, { @@ -106,7 +133,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 44, + endLine: 1, + endColumn: 46 + } ] }, { @@ -115,7 +149,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 36, + endLine: 1, + endColumn: 38 + } ] }, { @@ -123,7 +164,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 25, + endLine: 1, + endColumn: 27 + } ] }, { @@ -132,7 +180,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 25, + endLine: 1, + endColumn: 27 + } ] }, { @@ -141,7 +196,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 33, + endLine: 1, + endColumn: 35 + } ] }, { @@ -150,7 +212,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 32, + endLine: 1, + endColumn: 34 + } ] }, { @@ -159,7 +228,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 40, + endLine: 1, + endColumn: 42 + } ] }, { @@ -168,7 +244,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { output: "", errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 32, + endLine: 1, + endColumn: 34 + } ] }, { @@ -176,7 +259,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: null, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 25, + endLine: 1, + endColumn: 27 + } ] }, { @@ -184,7 +274,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: null, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 25, + endLine: 1, + endColumn: 27 + } ] }, { @@ -192,7 +289,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: null, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 33, + endLine: 1, + endColumn: 35 + } ] }, { @@ -200,7 +304,14 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { code: "", output: null, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 1, + column: 40, + endLine: 1, + endColumn: 42 + } ] }, { @@ -217,13 +328,62 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { `, output: null, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 3, + column: 25, + endLine: 3, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 4, + column: 25, + endLine: 4, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 5, + column: 25, + endLine: 5, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 6, + column: 25, + endLine: 6, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 7, + column: 25, + endLine: 7, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 8, + column: 25, + endLine: 8, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 9, + column: 25, + endLine: 9, + endColumn: 28 + } ] }, { @@ -245,11 +405,46 @@ ruleTester.run('no-deprecated-v-on-number-modifiers', rule, { `, errors: [ - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", - "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead." + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 3, + column: 25, + endLine: 3, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 4, + column: 25, + endLine: 4, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 5, + column: 25, + endLine: 5, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 6, + column: 25, + endLine: 6, + endColumn: 27 + }, + { + message: + "'KeyboardEvent.keyCode' modifier on 'v-on' directive is deprecated. Using 'KeyboardEvent.key' instead.", + line: 7, + column: 25, + endLine: 7, + endColumn: 27 + } ] } ] diff --git a/tests/lib/rules/no-deprecated-vue-config-keycodes.js b/tests/lib/rules/no-deprecated-vue-config-keycodes.js index 37c8bf3c4..1a00c1c86 100644 --- a/tests/lib/rules/no-deprecated-vue-config-keycodes.js +++ b/tests/lib/rules/no-deprecated-vue-config-keycodes.js @@ -5,11 +5,10 @@ 'use strict' const rule = require('../../../lib/rules/no-deprecated-vue-config-keycodes') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2020 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2020 } }) ruleTester.run('no-deprecated-vue-config-keycodes', rule, { @@ -47,12 +46,28 @@ ruleTester.run('no-deprecated-vue-config-keycodes', rule, { { filename: 'test.js', code: 'Vue?.config?.keyCodes', - errors: ['`Vue.config.keyCodes` are deprecated.'] + errors: [ + { + message: '`Vue.config.keyCodes` are deprecated.', + line: 1, + column: 1, + endLine: 1, + endColumn: 22 + } + ] }, { filename: 'test.js', code: '(Vue?.config)?.keyCodes', - errors: ['`Vue.config.keyCodes` are deprecated.'] + errors: [ + { + message: '`Vue.config.keyCodes` are deprecated.', + line: 1, + column: 1, + endLine: 1, + endColumn: 24 + } + ] } ] }) diff --git a/tests/lib/rules/no-dupe-keys.js b/tests/lib/rules/no-dupe-keys.js index 72ea22620..794dbd2ec 100644 --- a/tests/lib/rules/no-dupe-keys.js +++ b/tests/lib/rules/no-dupe-keys.js @@ -5,10 +5,10 @@ 'use strict' const rule = require('../../../lib/rules/no-dupe-keys') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parserOptions: { + languageOptions: { ecmaVersion: 2018, sourceType: 'module' } @@ -401,7 +401,7 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 0 `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', @@ -414,8 +414,10 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 0 `, - parser: require.resolve('vue-eslint-parser'), - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + } }, { filename: 'test.vue', @@ -425,7 +427,7 @@ ruleTester.run('no-dupe-keys', rule, { const { foo, bar } = props `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', @@ -436,7 +438,7 @@ ruleTester.run('no-dupe-keys', rule, { const bar = props.bar `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', @@ -447,7 +449,7 @@ ruleTester.run('no-dupe-keys', rule, { const { foo, bar } = toRefs(props) `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', @@ -459,25 +461,25 @@ ruleTester.run('no-dupe-keys', rule, { const bar = toRef(props, 'bar') `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', code: ` - + `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', code: ` - + `, - parser: require.resolve('vue-eslint-parser') + languageOptions: { parser: require('vue-eslint-parser') } }, { filename: 'test.vue', @@ -494,8 +496,21 @@ ruleTester.run('no-dupe-keys', rule, { const foo = props.foo `, - parser: require.resolve('vue-eslint-parser'), - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + } + }, + { + filename: 'test.vue', + code: ` + + `, + languageOptions: { parser: require('vue-eslint-parser') } } ], @@ -531,22 +546,34 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 5 + line: 5, + column: 13, + endLine: 5, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 10 + line: 10, + column: 15, + endLine: 10, + endColumn: 18 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 14 + line: 14, + column: 13, + endLine: 14, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 21 + line: 21, + column: 15, + endLine: 21, + endColumn: 18 } ] }, @@ -581,22 +608,34 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 5 + line: 5, + column: 13, + endLine: 5, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 10 + line: 10, + column: 15, + endLine: 10, + endColumn: 18 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 14 + line: 14, + column: 13, + endLine: 14, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 21 + line: 21, + column: 15, + endLine: 21, + endColumn: 18 } ] }, @@ -622,17 +661,26 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 5 + line: 5, + column: 13, + endLine: 5, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 12 + line: 12, + column: 13, + endLine: 12, + endColumn: 16 } ] }, @@ -669,22 +717,34 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 13, + endLine: 7, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 13 + line: 13, + column: 13, + endLine: 13, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 16 + line: 16, + column: 13, + endLine: 16, + endColumn: 16 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 23 + line: 23, + column: 15, + endLine: 23, + endColumn: 18 } ] }, @@ -705,7 +765,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 13, + endLine: 7, + endColumn: 16 } ] }, @@ -731,7 +794,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 12 + line: 12, + column: 15, + endLine: 12, + endColumn: 18 } ] }, @@ -755,7 +821,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 10 + line: 10, + column: 15, + endLine: 10, + endColumn: 18 } ] }, @@ -777,7 +846,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 16 } ] }, @@ -799,7 +871,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 16 } ] }, @@ -821,7 +896,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 16 } ] }, @@ -843,7 +921,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 16 } ] }, @@ -864,7 +945,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 13, + endLine: 7, + endColumn: 16 } ] }, @@ -885,7 +969,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 13, + endLine: 7, + endColumn: 16 } ] }, @@ -910,7 +997,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 6 + line: 6, + column: 17, + endLine: 6, + endColumn: 20 } ] }, @@ -931,7 +1021,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 17, + endLine: 7, + endColumn: 20 } ] }, @@ -951,7 +1044,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 6 + line: 6, + column: 17, + endLine: 6, + endColumn: 20 } ] }, @@ -972,7 +1068,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 17, + endLine: 7, + endColumn: 20 } ] }, @@ -993,7 +1092,10 @@ ruleTester.run('no-dupe-keys', rule, { { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 7 + line: 7, + column: 17, + endLine: 7, + endColumn: 20 } ] }, @@ -1007,12 +1109,15 @@ ruleTester.run('no-dupe-keys', rule, { const foo = 0 `, - parser: require.resolve('vue-eslint-parser'), + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 6 + line: 6, + column: 15, + endLine: 6, + endColumn: 22 } ] }, @@ -1035,22 +1140,31 @@ ruleTester.run('no-dupe-keys', rule, { const bar = () => 'bar'; `, - parser: require.resolve('vue-eslint-parser'), + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: "Duplicate key 'baz'. May cause name collision in script or template tag.", - line: 4 + line: 4, + column: 16, + endLine: 4, + endColumn: 19 }, { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 12 + line: 12, + column: 9, + endLine: 14, + endColumn: 10 }, { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", - line: 15 + line: 15, + column: 15, + endLine: 15, + endColumn: 32 } ] }, @@ -1067,18 +1181,26 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 'bar'; `, - parser: require.resolve('vue-eslint-parser'), - parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", - line: 8 + line: 8, + column: 13, + endLine: 8, + endColumn: 24 }, { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", - line: 9 + line: 9, + column: 13, + endLine: 9, + endColumn: 24 } ] }, @@ -1091,12 +1213,36 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 42 `, - parser: require.resolve('vue-eslint-parser'), + languageOptions: { parser: require('vue-eslint-parser') }, + errors: [ + { + message: + "Duplicate key 'bar'. May cause name collision in script or template tag.", + line: 5, + column: 13, + endLine: 5, + endColumn: 21 + } + ] + }, + { + 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 + line: 5, + column: 13, + endLine: 5, + endColumn: 24 } ] } diff --git a/tests/lib/rules/no-dupe-v-else-if.js b/tests/lib/rules/no-dupe-v-else-if.js index 214657a9c..0d65ddf31 100644 --- a/tests/lib/rules/no-dupe-v-else-if.js +++ b/tests/lib/rules/no-dupe-v-else-if.js @@ -4,12 +4,12 @@ */ 'use strict' -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/no-dupe-v-else-if') const tester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { + languageOptions: { + parser: require('vue-eslint-parser'), ecmaVersion: 2019, sourceType: 'module' } @@ -165,7 +165,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 4 + line: 4, + column: 25, + endLine: 4, + endColumn: 39 } ] }, @@ -182,7 +185,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 6 + line: 6, + column: 25, + endLine: 6, + endColumn: 31 } ] }, @@ -200,7 +206,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 6 + line: 6, + column: 25, + endLine: 6, + endColumn: 32 } ] }, @@ -215,7 +224,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 4 + line: 4, + column: 25, + endLine: 4, + endColumn: 26 } ] }, @@ -231,7 +243,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 5 + line: 5, + column: 25, + endLine: 5, + endColumn: 31 } ] }, @@ -246,7 +261,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 4 + line: 4, + column: 25, + endLine: 4, + endColumn: 26 } ] }, @@ -261,7 +279,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 4 + line: 4, + column: 25, + endLine: 4, + endColumn: 36 } ] }, @@ -276,7 +297,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 4 + line: 4, + column: 25, + endLine: 4, + endColumn: 26 } ] }, @@ -292,7 +316,10 @@ tester.run('no-dupe-v-else-if', rule, { errors: [ { messageId: 'unexpected', - line: 5 + line: 5, + column: 31, + endLine: 5, + endColumn: 47 } ] }, @@ -332,8 +359,20 @@ tester.run('no-dupe-v-else-if', rule, { `, errors: [ - { messageId: 'unexpected', line: 4 }, - { messageId: 'unexpected', line: 5 } + { + messageId: 'unexpected', + line: 4, + column: 25, + endLine: 4, + endColumn: 36 + }, + { + messageId: 'unexpected', + line: 5, + column: 25, + endLine: 5, + endColumn: 36 + } ] }, { @@ -346,8 +385,20 @@ tester.run('no-dupe-v-else-if', rule, { `, errors: [ - { messageId: 'unexpected', line: 4 }, - { messageId: 'unexpected', line: 5 } + { + messageId: 'unexpected', + line: 4, + column: 25, + endLine: 4, + endColumn: 26 + }, + { + messageId: 'unexpected', + line: 5, + column: 25, + endLine: 5, + endColumn: 26 + } ] }, { @@ -359,263 +410,702 @@ tester.run('no-dupe-v-else-if', rule, {
`, - errors: [{ messageId: 'unexpected' }, { messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 4, + column: 26, + endLine: 4, + endColumn: 60 + }, + { + messageId: 'unexpected', + line: 5, + column: 26, + endLine: 5, + endColumn: 60 + } + ] }, // Referred to the ESLint core rule. { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 43, + endLine: 1, + endColumn: 44 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 85, + endLine: 1, + endColumn: 86 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 85, + endLine: 1, + endColumn: 86 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 85, + endLine: 1, + endColumn: 86 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 106, + endLine: 1, + endColumn: 107 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }, { messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 43, + endLine: 1, + endColumn: 44 + }, + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + } + ] }, { filename: 'test.vue', code: '', errors: [ - { messageId: 'unexpected' }, - { messageId: 'unexpected' }, - { messageId: 'unexpected' } + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + }, + { + messageId: 'unexpected', + line: 1, + column: 85, + endLine: 1, + endColumn: 86 + }, + { + messageId: 'unexpected', + line: 1, + column: 106, + endLine: 1, + endColumn: 107 + } ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 63, + endLine: 1, + endColumn: 64 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 49, + endLine: 1, + endColumn: 56 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 47, + endLine: 1, + endColumn: 52 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 46, + endLine: 1, + endColumn: 50 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 54 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 53, + endLine: 1, + endColumn: 64 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 46, + endLine: 1, + endColumn: 50 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 49, + endLine: 1, + endColumn: 54 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 49, + endLine: 1, + endColumn: 70 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }, { messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + }, + { + messageId: 'unexpected', + line: 1, + column: 69, + endLine: 1, + endColumn: 70 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 54 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 70 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 74, + endLine: 1, + endColumn: 80 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 65, + endLine: 1, + endColumn: 81 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 43, + endLine: 1, + endColumn: 44 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 59 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 59 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 64, + endLine: 1, + endColumn: 75 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 70, + endLine: 1, + endColumn: 76 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 75, + endLine: 1, + endColumn: 91 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 53, + endLine: 1, + endColumn: 64 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 65, + endLine: 1, + endColumn: 71 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 62, + endLine: 1, + endColumn: 80 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 58, + endLine: 1, + endColumn: 69 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 75, + endLine: 1, + endColumn: 91 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 62, + endLine: 1, + endColumn: 75 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 49, + endLine: 1, + endColumn: 55 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 90, + endLine: 1, + endColumn: 91 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 53, + endLine: 1, + endColumn: 78 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 55, + endLine: 1, + endColumn: 68 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 91, + endLine: 1, + endColumn: 97 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 70, + endLine: 1, + endColumn: 81 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 43, + endLine: 1, + endColumn: 49 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 54 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 43, + endLine: 1, + endColumn: 44 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + } + ] }, { filename: 'test.vue', code: '', - errors: [{ messageId: 'unexpected' }] + errors: [ + { + messageId: 'unexpected', + line: 1, + column: 48, + endLine: 1, + endColumn: 49 + } + ] } ] }) diff --git a/tests/lib/rules/no-duplicate-attr-inheritance.js b/tests/lib/rules/no-duplicate-attr-inheritance.js index 7fc112123..8a007b491 100644 --- a/tests/lib/rules/no-duplicate-attr-inheritance.js +++ b/tests/lib/rules/no-duplicate-attr-inheritance.js @@ -6,11 +6,11 @@ const rule = require('../../../lib/rules/no-duplicate-attr-inheritance') -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const ruleTester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { + languageOptions: { + parser: require('vue-eslint-parser'), ecmaVersion: 2018, sourceType: 'module' } @@ -43,6 +43,57 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { ` }, + // ignore multi root by default + { + filename: 'test.vue', + code: ` + + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + ` + }, + { + filename: 'test.vue', + code: ` + + `, + options: [{ checkMultiRootNodes: false }] + }, { filename: 'test.vue', code: ` @@ -106,7 +157,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { { filename: 'test.vue', code: '', - errors: ['Set "inheritAttrs" to false.'] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 1, + column: 29, + endLine: 1, + endColumn: 35 + } + ] }, { filename: 'test.vue', @@ -118,7 +177,15 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { } `, - errors: ['Set "inheritAttrs" to false.'] + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 2, + column: 37, + endLine: 2, + endColumn: 43 + } + ] }, { filename: 'test.vue', @@ -133,7 +200,10 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { errors: [ { message: 'Set "inheritAttrs" to false.', - line: 7 + line: 7, + column: 30, + endLine: 7, + endColumn: 36 } ] }, @@ -148,7 +218,119 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { errors: [ { message: 'Set "inheritAttrs" to false.', - line: 5 + line: 5, + column: 30, + endLine: 5, + endColumn: 36 + } + ] + }, + { + filename: 'test.vue', + code: ``, + options: [{ checkMultiRootNodes: true }], + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 1, + column: 24, + endLine: 1, + endColumn: 30 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + options: [{ checkMultiRootNodes: true }], + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] + }, + // condition group as a single root node + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 3, + column: 40, + endLine: 3, + endColumn: 46 } ] } diff --git a/tests/lib/rules/no-duplicate-attributes.js b/tests/lib/rules/no-duplicate-attributes.js index b47611184..48dedf509 100644 --- a/tests/lib/rules/no-duplicate-attributes.js +++ b/tests/lib/rules/no-duplicate-attributes.js @@ -5,12 +5,11 @@ */ 'use strict' -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/no-duplicate-attributes') const tester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2015 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 } }) tester.run('no-duplicate-attributes', rule, { @@ -63,36 +62,84 @@ tester.run('no-duplicate-attributes', rule, { { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'foo'."] + errors: [ + { + message: "Duplicate attribute 'foo'.", + line: 1, + column: 25, + endLine: 1, + endColumn: 35 + } + ] }, { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'foo'."] + errors: [ + { + message: "Duplicate attribute 'foo'.", + line: 1, + column: 25, + endLine: 1, + endColumn: 29 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistStyle: false }], - errors: ["Duplicate attribute 'style'."] + errors: [ + { + message: "Duplicate attribute 'style'.", + line: 1, + column: 27, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistClass: false }], - errors: ["Duplicate attribute 'class'."] + errors: [ + { + message: "Duplicate attribute 'class'.", + line: 1, + column: 27, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistStyle: false }], - errors: ["Duplicate attribute 'style'."] + errors: [ + { + message: "Duplicate attribute 'style'.", + line: 1, + column: 28, + endLine: 1, + endColumn: 33 + } + ] }, { filename: 'test.vue', code: '', options: [{ allowCoexistClass: false }], - errors: ["Duplicate attribute 'class'."] + errors: [ + { + message: "Duplicate attribute 'class'.", + line: 1, + column: 28, + endLine: 1, + endColumn: 33 + } + ] } ] }) diff --git a/tests/lib/rules/no-empty-component-block.js b/tests/lib/rules/no-empty-component-block.js index 8ba6a2f2c..87ad2dd66 100644 --- a/tests/lib/rules/no-empty-component-block.js +++ b/tests/lib/rules/no-empty-component-block.js @@ -3,12 +3,11 @@ */ 'use strict' -const RuleTester = require('eslint').RuleTester +const RuleTester = require('../../eslint-compat').RuleTester const rule = require('../../../lib/rules/no-empty-component-block') const tester = new RuleTester({ - parser: require.resolve('vue-eslint-parser'), - parserOptions: { ecmaVersion: 2018 } + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2018 } }) tester.run('no-empty-component-block', rule, { @@ -28,117 +27,310 @@ tester.run('no-empty-component-block', rule, { invalid: [ { code: ``, + output: '', errors: [ { - message: '`