[英]@babel/eslint-parser throwing error on vue files
I have set up eslint-webpack-plugin with @babel/eslint-parser and eslint-plugin-vue on my webpack and vue project, but when I try to check the vue files it throws the following error:我已经在我的 webpack 和 vue 项目中使用 @babel/eslint-parser 和 eslint-plugin-vue 设置了 eslint-webpack-plugin,但是当我尝试检查 vue 文件时,它会抛出以下错误:
Error in phone-link.vue
phone-link.vue 中的错误
1:0 error Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)1:0 错误解析错误:此实验性语法需要启用以下解析器插件之一:'jsx, flow, typescript' (1:0)
Am I missing something in my setup as it works on none vue files?我的设置中是否缺少某些内容,因为它适用于非 vue 文件?
Packages:套餐:
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.16.0",
"eslint": "^8.2.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-vue": "^8.0.3",
"eslint-webpack-plugin": "^3.1.0",
Webpack config网络包配置
const ESLintPlugin = require('eslint-webpack-plugin');
plugins: [
new ESLintPlugin({
extensions: ['vue', 'js'],
})
],
eslintrc eslintrc
"extends": [
"eslint:recommended",
"airbnb-base",
"plugin:vue/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
Example vue file示例 vue 文件
<template>
<a :href="phoneLinkNumber" class="">{{ phoneLinkText }}</a>
</template>
<script>
import SiteConstants from '../Constants/site-constants.js';
export default {
name: 'phone-link',
props: {
phoneLinkText: {
default: SiteConstants.PhoneNumber,
},
},
data() {
return {
phoneLinkNumber: `tel:${SiteConstants.PhoneNumber.replace(/\s/g, "")}`,
}
},
}
</script>
最后我为vue-eslint-parser
更改了 babel vue-eslint-parser
:
"parser": "vue-eslint-parser",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.