Skip to content

Commit

Permalink
Update docs related to <script setup>.
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jul 2, 2021
1 parent a770662 commit 2655921
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/README.md
Expand Up @@ -15,7 +15,8 @@ This plugin allows us to check the `<template>` and `<script>` of `.vue` files w
ESLint editor integrations are useful to check your code in real-time.

:::warning Status of Vue.js 3.x supports
This plugin supports the basic syntax of Vue.js 3.0, but the Vue.js 3.0 experimental features `<script setup>` and `<style vars>` are not yet supported. Follow [#1248](https://github.com/vuejs/eslint-plugin-vue/issues/1248) for more details.
This plugin supports the basic syntax of Vue.js 3.0, but `<script setup>` does not yet fully support it.
Also, the Vue.js 3.0 experimental feature CSS variable injection is not yet supported. Follow [#1248](https://github.com/vuejs/eslint-plugin-vue/issues/1248) for more details.
:::

## :traffic_light: Versioning policy
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/experimental-script-setup-vars.md
Expand Up @@ -19,6 +19,10 @@ This rule will find variables defined in `<script setup="args">` and mark them a

This rule only has an effect when the `no-undef` rule is enabled.

:::warning
`<script setup="args">` syntax wasn't rejected by Vue's RFC. Check out the [new syntax](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md).
:::

## :book: Rule Details

Without this rule this code triggers warning:
Expand Down
62 changes: 61 additions & 1 deletion docs/user-guide/README.md
Expand Up @@ -72,7 +72,8 @@ By default all rules from **base** and **essential** categories report ESLint er
:::

:::warning Status of Vue.js 3.x supports
This plugin supports the basic syntax of Vue.js 3.0, but the Vue.js 3.0 experimental features `<script setup>` and `<style vars>` are not yet supported. Follow [#1248](https://github.com/vuejs/eslint-plugin-vue/issues/1248) for more details.
This plugin supports the basic syntax of Vue.js 3.0, but `<script setup>` does not yet fully support it.
Also, the Vue.js 3.0 experimental feature CSS variable injection is not yet supported. Follow [#1248](https://github.com/vuejs/eslint-plugin-vue/issues/1248) for more details.
:::

### Running ESLint from the command line
Expand Down Expand Up @@ -333,3 +334,62 @@ Note that you cannot use angle-bracket type assertion style (`var x = <foo>bar;`
You need to turn off Vetur's template validation by adding `vetur.validation.template: false` to your `.vscode/settings.json`.

See also: "[Visual Studio Code](#editor-integrations)" section and [Vetur - Linting](https://vuejs.github.io/vetur/guide/linting-error.html#linting).

### Does not work well with `<script setup>`

#### 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.

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',
}
}
```

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

##### Using ESLint <= v7.x

The parser `espree` that comes with `ESLint` doesn't understand the syntax of ES2022, so it can't parse Top Level `await` either.
However, the `vue-eslint-parser` used by `eslint-plugin-vue` can use `espree` v8, which understands ES2022 by configuration.

```js
module.exports = {
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 2022, // If you specify 2022, espree >= v8.x will be used automatically.
sourceType: 'module'
},
}
```

However, note that the AST generated by `espree` v8 may not work well with some rules of `ESLint` v7.

<!--
##### Using ESLint >= v8.x
You need to specify `2022` for `parserOptions.ecmaVersion`.
```js
module.exports = {
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module'
},
}
```
-->

#### Other Problems

This `eslint-plugin-vue` does not yet fully support `<script setup>`.
Follow [#1248](https://github.com/vuejs/eslint-plugin-vue/issues/1248) for more details.

0 comments on commit 2655921

Please sign in to comment.