Skip to content

Commit 2f96315

Browse files
Upgrade vue-eslint-parser (#1849)
* Upgrade vue-eslint-parser * Update tests/lib/script-setup-vars.js Co-authored-by: Flo Edelmann <[email protected]> * Update docs/user-guide/README.md Co-authored-by: Flo Edelmann <[email protected]> * Update docs/user-guide/README.md Co-authored-by: Flo Edelmann <[email protected]> * Update parser * Update tools/update-lib-index.js Co-authored-by: Flo Edelmann <[email protected]> Co-authored-by: Flo Edelmann <[email protected]>
1 parent 186833a commit 2f96315

File tree

10 files changed

+410
-33
lines changed

10 files changed

+410
-33
lines changed

Diff for: docs/rules/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
2929
|:--------|:------------|:--:|:--:|
3030
| [vue/comment-directive](./comment-directive.md) | support comment-directives in `<template>` | | :warning: |
3131
| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
32-
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | prevent `<script setup>` variables used in `<template>` to be marked as unused | | :warning: |
3332

3433
</rules-table>
3534

@@ -321,3 +320,4 @@ The following rules extend the rules provided by ESLint itself and apply them to
321320
| [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) |
322321
| [vue/no-invalid-model-keys](./no-invalid-model-keys.md) | [vue/valid-model-definition](./valid-model-definition.md) |
323322
| [vue/no-unregistered-components](./no-unregistered-components.md) | [vue/no-undef-components](./no-undef-components.md) |
323+
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | (no replacement) |

Diff for: 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

Diff for: 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

Diff for: 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, this is no longer needed.
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, this is no longer needed.
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

Diff for: 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
}

Diff for: lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ module.exports = {
237237
'.vue': require('./processor')
238238
},
239239
environments: {
240+
// Deprecated
240241
'setup-compiler-macros': {
241242
globals: {
242243
defineProps: 'readonly',

Diff for: lib/rules/script-setup-uses-vars.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ module.exports = {
3232
docs: {
3333
description:
3434
'prevent `<script setup>` variables used in `<template>` to be marked as unused', // eslint-disable-line eslint-plugin/require-meta-docs-description
35-
categories: ['base'],
35+
categories: undefined,
3636
url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html'
3737
},
38+
deprecated: true,
3839
schema: []
3940
},
4041
/**

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.1"
6363
},
6464
"devDependencies": {
6565
"@types/eslint": "^7.28.1",

0 commit comments

Comments
 (0)