我刚刚用npm init nuxt-app <project-name>
启动了一个新的Nuxt应用程序,并用npx eslint --init
配置了ESlint。
此外,我还向.eslintrc.js配置文件添加了两个规则,如下所示:
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'plugin:vue/essential',
'standard'
],
parserOptions: {
ecmaVersion: 12,
sourceType: 'module'
},
plugins: [
'vue'
],
rules: {
'vue/multi-word-component-names': 'warn',
'no-unused-vars': 'warn'
}
}
当我运行我的应用程序并测试是否一切正常时,我注意到我在.eslintrc.js文件中设置的规则没有得到正确的应用。例如,在使用未使用的变量时,我仍然会得到一个错误,而不是警告。
有这方面的经验吗?或者解决方案?
在Vue应用程序中,它一直适用于我,但现在,对于Nuxt,它就没有了。
发布于 2021-12-03 14:13:37
我不确定您的项目的实际配置,但是我已经设置了我的ESlint以匹配Nuxt的规则,并且还有其他规则与下面的.eslintrc.js
文件正常工作(收到警告)
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
},
extends: [
'@nuxtjs',
'plugin:prettier/recommended',
'prettier',
],
plugins: [],
// add your custom rules here
rules: {},
}
下面是我的ESlint +更漂亮的开发包,可以让整个程序正常工作:@babel/eslint-parser @nuxtjs/eslint-config @nuxtjs/eslint-module eslint eslint-config-prettier eslint-plugin-nuxt eslint-plugin-prettier eslint-plugin-vue prettier
。
发布于 2021-12-17 19:10:39
感谢您的回复。
通过更改,我需要重新安装我的Nuxt项目。我使用了npm init nuxt-app <project-name>
,这一次我把TypeScript作为我的语言。
出于某种原因,这一次一切都很顺利。
我当前的.eslintrc.js
文件:
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'plugin:vue/essential',
'standard'
],
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
plugins: [
'vue',
'@typescript-eslint'
],
rules: {
'vue/multi-word-component-names': 'warn',
'no-unused-vars': 'warn',
'space-in-parens': 'off',
'computed-property-spacing': 'off'
}
}
老实说,我不知道是什么造成了这一切.
https://stackoverflow.com/questions/70215026
复制相似问题