Skip to content

Commit

Permalink
Change legacy base config so that vue-eslint-parser is only used for …
Browse files Browse the repository at this point in the history
…`.vue` (#2668)
  • Loading branch information
ota-meshi authored Jan 29, 2025
1 parent be3ff99 commit f47f6c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
7 changes: 3 additions & 4 deletions docs/user-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,12 @@ If you have issues with these, please also refer to the [FAQ](#does-not-work-wel

### Running ESLint from the command line

If you want to run `eslint` from the command line, make sure you include the `.vue` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-target-files-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.
If you want to run `eslint` from the command line, ESLint will automatically check for the `.vue` extension if you use the config provided by the plugin.

Examples:

```bash
eslint --ext .js,.vue src
eslint "src/**/*.{js,vue}"
eslint src
```

::: tip
Expand Down Expand Up @@ -393,7 +392,7 @@ See also: "[How to use a custom parser?](#how-to-use-a-custom-parser)" section.

1. Make sure your tool is set to lint `.vue` files.

- CLI targets only `.js` files by default. You have to specify additional extensions with the `--ext` option or glob patterns. E.g. `eslint "src/**/*.{js,vue}"` or `eslint src --ext .vue`. If you use `@vue/cli-plugin-eslint` and the `vue-cli-service lint` command - you don't have to worry about it.
- Make sure you are using the shareable config provided by `eslint-plugin-vue`.
- If you are having issues with configuring editor, please read [editor integrations](#editor-integrations)

### Conflict with [Prettier]
Expand Down
9 changes: 7 additions & 2 deletions lib/configs/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* in order to update its content execute "npm run update"
*/
module.exports = {
parser: require.resolve('vue-eslint-parser'),
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
Expand All @@ -17,5 +16,11 @@ module.exports = {
rules: {
'vue/comment-directive': 'error',
'vue/jsx-uses-vars': 'error'
}
},
overrides: [
{
files: '*.vue',
parser: require.resolve('vue-eslint-parser')
}
]
}
9 changes: 7 additions & 2 deletions tools/update-lib-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function formatCategory(category) {
* in order to update its content execute "npm run update"
*/
module.exports = {
parser: require.resolve('vue-eslint-parser'),
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
Expand All @@ -68,7 +67,13 @@ module.exports = {
plugins: [
'vue'
],
rules: ${formatRules(category.rules, category.categoryId)}
rules: ${formatRules(category.rules, category.categoryId)},
overrides: [
{
files: '*.vue',
parser: require.resolve('vue-eslint-parser')
}
]
}
`
}
Expand Down

0 comments on commit f47f6c1

Please sign in to comment.