Vue.js eslint不允许使用4个空格进行缩进
我已经为我的项目安装了eslint和eslint插件vue。 在浏览器中加载项目时,控制台中会出现以下警告: 预期缩进2个空格,但找到4个Vue.js eslint不允许使用4个空格进行缩进,vue.js,eslint,Vue.js,Eslint,我已经为我的项目安装了eslint和eslint插件vue。 在浏览器中加载项目时,控制台中会出现以下警告: 预期缩进2个空格,但找到4个 src\\ u nav.js:2:1 这是我的_nav.js: export default { items: [{ /*this is line 2 - indented with 4 spaces*/ 我试图告诉林特我想使用4个空格,但我仍然得到警告。我对.vue文件也有同样的问题 这是我的.eslintrc.js: module.expor
src\\ u nav.js:2:1 这是我的_nav.js:
export default {
items: [{ /*this is line 2 - indented with 4 spaces*/
我试图告诉林特我想使用4个空格,但我仍然得到警告。我对.vue文件也有同样的问题
这是我的.eslintrc.js:
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"indent": ["error", 4],
"vue/html-indent": ["error", 4],
"vue/script-indent": ["error", 4],
}
}
您确定eslint加载了配置文件吗?它应该被称为.eslintrc.js,而不是.eslintrs.js是的,文件名是正确的(我刚才的问题中有一个输入错误)。我如何测试配置是否从这个文件加载?添加一个故意的语法错误,看看eslint是否停止。突然,它用4个空格工作——如果我切换回2个空格则忽略它——我认为这涉及到一些缓存。对于其他用户:我的解决方案是删除这个超级错误插件(我可以在没有“超级错误”的情况下关注代码缩进)
npm remove@vue/cli插件eslint