vue-eslint-parser
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ // Generated by dts-bundle v0.7.3 | ||
declare module 'vue-eslint-parser' { | ||
import * as AST from "vue-eslint-parser/ast"; | ||
import * as AST from "vue-eslint-parser/ast/index"; | ||
export function parseForESLint(code: string, parserOptions: any): AST.ESLintExtendedProgram; | ||
@@ -19,3 +19,3 @@ export function parse(code: string, options: any): AST.ESLintProgram; | ||
declare module 'vue-eslint-parser/ast' { | ||
declare module 'vue-eslint-parser/ast/index' { | ||
export * from "vue-eslint-parser/ast/errors"; | ||
@@ -22,0 +22,0 @@ export * from "vue-eslint-parser/ast/locations"; |
{ | ||
"name": "vue-eslint-parser", | ||
"version": "9.4.3", | ||
"version": "10.0.0", | ||
"description": "The ESLint custom parser for `.vue` files.", | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
}, | ||
"main": "index.js", | ||
@@ -12,22 +9,26 @@ "files": [ | ||
], | ||
"engines": { | ||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=6.0.0" | ||
"eslint": "^8.57.0 || ^9.0.0" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.3.4", | ||
"eslint-scope": "^7.1.1", | ||
"eslint-visitor-keys": "^3.3.0", | ||
"espree": "^9.3.1", | ||
"esquery": "^1.4.0", | ||
"debug": "^4.4.0", | ||
"eslint-scope": "^8.2.0", | ||
"eslint-visitor-keys": "^4.2.0", | ||
"espree": "^10.3.0", | ||
"esquery": "^1.6.0", | ||
"lodash": "^4.17.21", | ||
"semver": "^7.3.6" | ||
"semver": "^7.6.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.16.0", | ||
"@babel/eslint-parser": "^7.16.3", | ||
"@babel/plugin-syntax-decorators": "^7.16.0", | ||
"@babel/plugin-syntax-pipeline-operator": "^7.16.0", | ||
"@babel/plugin-syntax-typescript": "^7.16.0", | ||
"@babel/core": "^7.26.7", | ||
"@babel/eslint-parser": "^7.26.5", | ||
"@babel/plugin-syntax-decorators": "^7.25.9", | ||
"@babel/plugin-syntax-pipeline-operator": "^7.26.7", | ||
"@babel/plugin-syntax-typescript": "^7.25.9", | ||
"@eslint/eslintrc": "^3.2.0", | ||
"@eslint/js": "^9.19.0", | ||
"@types/debug": "^4.1.7", | ||
"@types/eslint": "^8.4.6", | ||
"@types/estree": "^1.0.0", | ||
@@ -38,4 +39,4 @@ "@types/lodash": "^4.14.186", | ||
"@types/semver": "^7.3.12", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"@typescript-eslint/eslint-plugin": "^8.22.0", | ||
"@typescript-eslint/parser": "^8.22.0", | ||
"chokidar": "^3.5.2", | ||
@@ -45,8 +46,9 @@ "codecov": "^3.8.3", | ||
"dts-bundle": "^0.7.3", | ||
"eslint": "^8.12.0", | ||
"eslint": "^9.19.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-jsonc": "^2.2.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-node-dependencies": "^0.8.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-jsonc": "^2.19.1", | ||
"eslint-plugin-n": "^17.15.1", | ||
"eslint-plugin-node-dependencies": "^0.12.0", | ||
"eslint-plugin-prettier": "^5.2.3", | ||
"eslint-plugin-unicorn": "^57.0.0", | ||
"fs-extra": "^10.0.0", | ||
@@ -58,3 +60,3 @@ "jsonc-eslint-parser": "^2.0.3", | ||
"opener": "^1.5.2", | ||
"prettier": "^2.4.1", | ||
"prettier": "^3.4.2", | ||
"rimraf": "^3.0.2", | ||
@@ -65,4 +67,4 @@ "rollup": "^2.60.0", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"ts-node": "^10.4.0", | ||
"typescript": "~4.8.4", | ||
"ts-node": "^10.9.2", | ||
"typescript": "~5.7.3", | ||
"wait-on": "^6.0.0", | ||
@@ -77,4 +79,3 @@ "warun": "^1.0.0" | ||
"coverage": "opener ./coverage/lcov-report/index.html", | ||
"lint": "eslint src test package.json --ext .js,.ts", | ||
"setup": "git submodule update --init && cd test/fixtures/eslint && npm install", | ||
"lint": "eslint src test package.json", | ||
"pretest": "run-s build lint", | ||
@@ -81,0 +82,0 @@ "test": "npm run -s test:mocha", |
190
README.md
@@ -20,23 +20,19 @@ # vue-eslint-parser | ||
- Requires Node.js ^14.17.0, 16.0.0 or later. | ||
- Requires ESLint 6.0.0 or later. | ||
## ๐ Usage | ||
1. Write `parser` option into your `.eslintrc.*` file. | ||
2. Use glob patterns or `--ext .vue` CLI option. | ||
Write `parser` option into your `eslint.config.*` file. | ||
```json | ||
{ | ||
"extends": "eslint:recommended", | ||
"parser": "vue-eslint-parser" | ||
} | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
export default [ | ||
js.configs.recommended, | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
}, | ||
} | ||
] | ||
``` | ||
```console | ||
$ eslint "src/**/*.{js,vue}" | ||
# or | ||
$ eslint src --ext .vue | ||
``` | ||
## ๐ง Options | ||
@@ -47,15 +43,21 @@ | ||
```json | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2018, | ||
"ecmaFeatures": { | ||
"globalReturn": false, | ||
"impliedStrict": false, | ||
"jsx": false | ||
} | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
export default [ | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
sourceType: "module", | ||
ecmaVersion: "latest", | ||
parserOptions: { | ||
ecmaFeatures: { | ||
globalReturn: false, | ||
impliedStrict: false, | ||
jsx: false | ||
} | ||
} | ||
}, | ||
} | ||
} | ||
] | ||
``` | ||
@@ -69,20 +71,32 @@ | ||
```json | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"parser": "@babel/eslint-parser", | ||
"sourceType": "module" | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
import babelParser from "@babel/eslint-parser" | ||
export default [ | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
parserOptions: { | ||
parser: babelParser, | ||
} | ||
}, | ||
} | ||
} | ||
] | ||
``` | ||
```json | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"parser": "@typescript-eslint/parser", | ||
"sourceType": "module" | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
import tsParser from "@typescript-eslint/parser" | ||
export default [ | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
parserOptions: { | ||
parser: tsParser, | ||
} | ||
}, | ||
} | ||
} | ||
] | ||
``` | ||
@@ -92,42 +106,29 @@ | ||
```jsonc | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"parser": { | ||
// Script parser for `<script>` | ||
"js": "espree", | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
import tsParser from "@typescript-eslint/parser" | ||
export default [ | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
parserOptions: { | ||
"parser": { | ||
// Script parser for `<script>` | ||
"js": "espree", | ||
// Script parser for `<script lang="ts">` | ||
"ts": "@typescript-eslint/parser", | ||
// Script parser for `<script lang="ts">` | ||
"ts": tsParser, | ||
// Script parser for vue directives (e.g. `v-if=` or `:attribute=`) | ||
// and vue interpolations (e.g. `{{variable}}`). | ||
// If not specified, the parser determined by `<script lang ="...">` is used. | ||
"<template>": "espree", | ||
} | ||
// Script parser for vue directives (e.g. `v-if=` or `:attribute=`) | ||
// and vue interpolations (e.g. `{{variable}}`). | ||
// If not specified, the parser determined by `<script lang ="...">` is used. | ||
"<template>": "espree", | ||
} | ||
} | ||
}, | ||
} | ||
} | ||
] | ||
``` | ||
When using JavaScript configuration (`.eslintrc.js`), you can also give the parser object directly. | ||
```js | ||
const tsParser = require("@typescript-eslint/parser") | ||
const espree = require("espree") | ||
module.exports = { | ||
parser: "vue-eslint-parser", | ||
parserOptions: { | ||
// Single parser | ||
parser: tsParser, | ||
// Multiple parser | ||
parser: { | ||
js: espree, | ||
ts: tsParser, | ||
} | ||
}, | ||
} | ||
``` | ||
If the `parserOptions.parser` is `false`, the `vue-eslint-parser` skips parsing `<script>` tags completely. | ||
@@ -141,14 +142,20 @@ This is useful for people who use the language ESLint community doesn't provide custom parser implementation. | ||
```json | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"vueFeatures": { | ||
"filter": true, | ||
"interpolationAsNonHTML": true, | ||
"styleCSSVariableInjection": true, | ||
"customMacros": [] | ||
} | ||
```js | ||
import vueParser from "vue-eslint-parser" | ||
export default [ | ||
{ | ||
files: ["*.vue", "**/*.vue"], | ||
languageOptions: { | ||
parser: vueParser, | ||
parserOptions: { | ||
vueFeatures: { | ||
filter: true, | ||
interpolationAsNonHTML: true, | ||
styleCSSVariableInjection: true, | ||
customMacros: [] | ||
} | ||
} | ||
}, | ||
} | ||
} | ||
] | ||
``` | ||
@@ -163,3 +170,2 @@ | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
@@ -197,3 +203,2 @@ "vueFeatures": { | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
@@ -241,3 +246,2 @@ "vueFeatures": { | ||
{ | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
@@ -325,5 +329,4 @@ "templateTokenizer": { | ||
If you want to write code, please execute `npm install && npm run setup` after you cloned this repository. | ||
If you want to write code, please execute `npm install` after you cloned this repository. | ||
The `npm install` command installs dependencies. | ||
The `npm run setup` command initializes ESLint as git submodules for tests. | ||
@@ -337,4 +340,3 @@ ### Development Tools | ||
- `npm run lint` runs ESLint. | ||
- `npm run setup` setups submodules to develop. | ||
- `npm run update-fixtures` updates files in `test/fixtures/ast` directory based on `test/fixtures/ast/*/source.vue` files. | ||
- `npm run watch` runs `build`, `update-fixtures`, and tests with `--watch` option. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
7357
1.43%333
0.6%1125679
-0.92%42
5%- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated