Skip to content

Commit 0615fb3

Browse files
committed
Upgrade vue-eslint-parser
1 parent a473a0d commit 0615fb3

File tree

10 files changed

+410
-34
lines changed

10 files changed

+410
-34
lines changed

docs/rules/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
2626
|:--------|:------------|:---|
2727
| [vue/comment-directive](./comment-directive.md) | support comment-directives in `<template>` | |
2828
| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | |
29-
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | prevent `<script setup>` variables used in `<template>` to be marked as unused | |
3029

3130
## Priority A: Essential (Error Prevention) <badge text="for Vue.js 3.x" vertical="middle">for Vue.js 3.x</badge>
3231

@@ -420,3 +419,4 @@ The following rules extend the rules provided by ESLint itself and apply them to
420419
| [vue/name-property-casing](./name-property-casing.md) | [vue/component-definition-name-casing](./component-definition-name-casing.md) |
421420
| [vue/no-confusing-v-for-v-if](./no-confusing-v-for-v-if.md) | [vue/no-use-v-if-with-v-for](./no-use-v-if-with-v-for.md) |
422421
| [vue/no-unregistered-components](./no-unregistered-components.md) | [vue/no-undef-components](./no-undef-components.md) |
422+
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | (no replacement) |

docs/rules/jsx-uses-vars.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ If you are not using JSX or if you do not use the `no-unused-vars` rule then you
4040

4141
## :couple: Related Rules
4242

43-
- [vue/script-setup-uses-vars](./script-setup-uses-vars.md)
4443
- [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars)
4544

4645
## :rocket: Version

docs/rules/script-setup-uses-vars.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ since: v7.13.0
99

1010
> prevent `<script setup>` variables used in `<template>` to be marked as unused
1111
12-
- :gear: This rule is included in all of `"plugin:vue/base"`, `"plugin:vue/essential"`, `"plugin:vue/vue3-essential"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/recommended"` and `"plugin:vue/vue3-recommended"`.
12+
- :warning: This rule was **deprecated**.
13+
14+
::: tip
15+
16+
This rule is not needed when using `vue-eslint-parser` v9.0.0 or later.
17+
18+
:::
1319

1420
ESLint `no-unused-vars` rule does not detect variables in `<script setup>` used in `<template>`.
1521
This rule will find variables in `<script setup>` used in `<template>` and mark them as used.
@@ -47,7 +53,11 @@ After turning on, `Foo` is being marked as used and `no-unused-vars` rule doesn'
4753

4854
## :mute: When Not To Use It
4955

50-
If you are not using `<script setup>` or if you do not use the `no-unused-vars` rule then you can disable this rule.
56+
You can disable this rule in any of the following cases:
57+
58+
- You are using `vue-eslint-parser` v9.0.0 or later.
59+
- You are not using `<script setup>`.
60+
- You do not use the `no-unused-vars` rule.
5161

5262
## :couple: Related Rules
5363

docs/user-guide/README.md

+6-25
Original file line numberDiff line numberDiff line change
@@ -342,36 +342,15 @@ See also: "[Visual Studio Code](#editor-integrations)" section and [Vetur - Lint
342342

343343
#### The variables used in the `<template>` are warned by `no-unused-vars` rule
344344

345-
You must use [vue/script-setup-uses-vars](../rules/script-setup-uses-vars.md) rule.
346-
In your configuration, use the rule set provided by `eslint-plugin-vue` or enable it rule.
345+
You need to use [vue-eslint-parser] v9.0.0 or later.
347346

348-
Example **.eslintrc.js**:
349-
350-
```js
351-
module.exports = {
352-
// Use the rule set.
353-
extends: ['plugin:vue/base'],
354-
rules: {
355-
// Enable vue/script-setup-uses-vars rule
356-
'vue/script-setup-uses-vars': 'error',
357-
}
358-
}
359-
```
347+
Previously you had to use the [vue/script-setup-uses-vars](../rules/script-setup-uses-vars.md) rule, but now you don't.
360348

361349
#### Compiler macros such as `defineProps` and `defineEmits` generate `no-undef` warnings
362350

363-
You need to enable the compiler macros environment in your ESLint configuration file.
364-
If you don't want to expose these variables globally, you can use `/* global defineProps, defineEmits */` instead.
351+
You need to use [vue-eslint-parser] v9.0.0 or later.
365352

366-
Example **.eslintrc.js**:
367-
368-
```js
369-
module.exports = {
370-
env: {
371-
'vue/setup-compiler-macros': true
372-
}
373-
}
374-
```
353+
Previously you had to use the `vue/setup-compiler-macros` environment, but now you don't.
375354

376355
#### Parsing error with Top Level `await`
377356

@@ -411,3 +390,5 @@ module.exports = {
411390

412391
Try searching for existing issues.
413392
If it does not exist, you should open a new issue and share your repository to reproduce the issue.
393+
394+
[vue-eslint-parser]: https://github.com/vuejs/vue-eslint-parser

lib/configs/base.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = {
1616
plugins: ['vue'],
1717
rules: {
1818
'vue/comment-directive': 'error',
19-
'vue/jsx-uses-vars': 'error',
20-
'vue/script-setup-uses-vars': 'error'
19+
'vue/jsx-uses-vars': 'error'
2120
}
2221
}

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ module.exports = {
235235
'.vue': require('./processor')
236236
},
237237
environments: {
238+
// Deprecated
238239
'setup-compiler-macros': {
239240
globals: {
240241
defineProps: 'readonly',

lib/rules/script-setup-uses-vars.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ module.exports = {
2222
docs: {
2323
description:
2424
'prevent `<script setup>` variables used in `<template>` to be marked as unused', // eslint-disable-line eslint-plugin/require-meta-docs-description
25-
categories: ['base'],
25+
categories: undefined,
2626
url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html'
2727
},
28+
deprecated: true,
2829
schema: []
2930
},
3031
/**

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"url": "https://github.com/vuejs/eslint-plugin-vue/issues"
4949
},
5050
"engines": {
51-
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
51+
"node": "^14.17.0 || >=16.0.0"
5252
},
5353
"peerDependencies": {
5454
"eslint": "^6.2.0 || ^7.0.0 || ^8.0.0"
@@ -59,7 +59,7 @@
5959
"nth-check": "^2.0.1",
6060
"postcss-selector-parser": "^6.0.9",
6161
"semver": "^7.3.5",
62-
"vue-eslint-parser": "^8.0.1"
62+
"vue-eslint-parser": "^9.0.0-0"
6363
},
6464
"devDependencies": {
6565
"@types/eslint": "^7.28.1",

0 commit comments

Comments
 (0)