Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vue-eslint-parser #1849

Merged
merged 6 commits into from May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rules/README.md
Expand Up @@ -29,7 +29,6 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
|:--------|:------------|:--:|:--:|
| [vue/comment-directive](./comment-directive.md) | support comment-directives in `<template>` | | :warning: |
| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | prevent `<script setup>` variables used in `<template>` to be marked as unused | | :warning: |

</rules-table>

Expand Down Expand Up @@ -320,3 +319,4 @@ The following rules extend the rules provided by ESLint itself and apply them to
| [vue/name-property-casing](./name-property-casing.md) | [vue/component-definition-name-casing](./component-definition-name-casing.md) |
| [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) |
| [vue/no-unregistered-components](./no-unregistered-components.md) | [vue/no-undef-components](./no-undef-components.md) |
| [vue/script-setup-uses-vars](./script-setup-uses-vars.md) | (no replacement) |
1 change: 0 additions & 1 deletion docs/rules/jsx-uses-vars.md
Expand Up @@ -40,7 +40,6 @@ If you are not using JSX or if you do not use the `no-unused-vars` rule then you

## :couple: Related Rules

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

## :rocket: Version
Expand Down
14 changes: 12 additions & 2 deletions docs/rules/script-setup-uses-vars.md
Expand Up @@ -9,7 +9,13 @@ since: v7.13.0

> prevent `<script setup>` variables used in `<template>` to be marked as unused

- :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"`.
- :warning: This rule was **deprecated**.

::: tip

This rule is not needed when using `vue-eslint-parser` v9.0.0 or later.

:::

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

## :mute: When Not To Use It

If you are not using `<script setup>` or if you do not use the `no-unused-vars` rule then you can disable this rule.
You can disable this rule in any of the following cases:

- You are using `vue-eslint-parser` v9.0.0 or later.
- You are not using `<script setup>`.
- You do not use the `no-unused-vars` rule.

## :couple: Related Rules

Expand Down
31 changes: 6 additions & 25 deletions docs/user-guide/README.md
Expand Up @@ -342,36 +342,15 @@ See also: "[Visual Studio Code](#editor-integrations)" section and [Vetur - Lint

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

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

Example **.eslintrc.js**:

```js
module.exports = {
// Use the rule set.
extends: ['plugin:vue/base'],
rules: {
// Enable vue/script-setup-uses-vars rule
'vue/script-setup-uses-vars': 'error',
}
}
```
Previously you had to use the [vue/script-setup-uses-vars](../rules/script-setup-uses-vars.md) rule, this is no longer needed.

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

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

Example **.eslintrc.js**:

```js
module.exports = {
env: {
'vue/setup-compiler-macros': true
}
}
```
Previously you had to use the `vue/setup-compiler-macros` environment, this is no longer needed.

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

Expand Down Expand Up @@ -411,3 +390,5 @@ module.exports = {

Try searching for existing issues.
If it does not exist, you should open a new issue and share your repository to reproduce the issue.

[vue-eslint-parser]: https://github.com/vuejs/vue-eslint-parser
3 changes: 1 addition & 2 deletions lib/configs/base.js
Expand Up @@ -16,7 +16,6 @@ module.exports = {
plugins: ['vue'],
rules: {
'vue/comment-directive': 'error',
'vue/jsx-uses-vars': 'error',
'vue/script-setup-uses-vars': 'error'
'vue/jsx-uses-vars': 'error'
}
}
1 change: 1 addition & 0 deletions lib/index.js
Expand Up @@ -236,6 +236,7 @@ module.exports = {
'.vue': require('./processor')
},
environments: {
// Deprecated
'setup-compiler-macros': {
globals: {
defineProps: 'readonly',
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/script-setup-uses-vars.js
Expand Up @@ -32,9 +32,10 @@ module.exports = {
docs: {
description:
'prevent `<script setup>` variables used in `<template>` to be marked as unused', // eslint-disable-line eslint-plugin/require-meta-docs-description
categories: ['base'],
categories: undefined,
url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html'
},
deprecated: true,
schema: []
},
/**
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -48,7 +48,7 @@
"url": "https://github.com/vuejs/eslint-plugin-vue/issues"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": "^14.17.0 || >=16.0.0"
},
"peerDependencies": {
"eslint": "^6.2.0 || ^7.0.0 || ^8.0.0"
Expand All @@ -59,7 +59,7 @@
"nth-check": "^2.0.1",
"postcss-selector-parser": "^6.0.9",
"semver": "^7.3.5",
"vue-eslint-parser": "^8.0.1"
"vue-eslint-parser": "^9.0.1"
},
"devDependencies": {
"@types/eslint": "^7.28.1",
Expand Down