当我拥有.eslint.js文件时,请包含以下规则:
"vue/script-indent": [
"error",4,{
"baseIndent": 1,"switchCase": 1,}
]
error: Expected indentation of 32 spaces but found 24 spaces (vue/script-indent)
是什么原因导致这种奇怪的冲突? (因为它似乎没有采用我的.eslint.js文件中的规则)
例
<template>
<div>
<label>
Display Name:
<a></a>
<input
v-model="data.display_name"
class="form-control"
type="text"
>
</label>
</div>
</template>
.eslintrc.js
module.exports = {
"env": {
"browser": true,"es6": true,"node": true
},"extends": [
"eslint:recommended","plugin:vue/recommended"
],// "parser": "vue-eslint-parser","parserOptions": {
"sourceType": "module","ecmaVersion": 2018,"allowImportExportEverywhere": true
},"rules": {
"array-bracket-newline":
[
"error",{
minItems: 1
}
],"array-element-newline":
[
"error","always"
],"brace-style": [
"error","allman",{
"allowSingleLine": true
}
],"function-paren-newline":
[
"error",{
minItems:
2
}
],"indent": [
"error",{
"SwitchCase": 1,"ObjectExpression":
"first","ArrayExpression":
"first"
}
],"newline-per-chained-call":
[
"error",{
"ignoreChainWithDepth": 1
}
],"no-console": "off","no-fallthrough": "off","no-case-declarations": "off","no-unneeded-ternary": "error","no-unused-vars":
[
"error",{
"args": "none"
}
],"object-curly-newline":
[
"error",{
"ObjectExpression":
{
"multiline":
true,"minProperties":
1
},"ObjectPattern":
{
"multiline":
true,"ImportDeclaration":
{
"multiline":
true,"ExportDeclaration":
{
"multiline":
true,"minProperties":
1
}
}
],"object-property-newline":
[
"error",{
"allowAllPropertiesOnSameLine":
false
}
],"quotes": [
"error","double"
],"semi": [
"error","never"
],// "vue/component-name-in-template-casing": [
// "never"
// ],"vue/attribute-hyphenation": [
"never"
],"vue/html-closing-bracket-newline": [
"error",{
"singleline": "never","multiline": "always"
}
],"vue/html-indent": [
"error",{
"attribute": 1,"closeBracket": 0,"alignAttributesVertically": true,"ignores": []
}
],"vue/prop-name-casing": [
"never",],"vue/html-self-closing": [
"never"
],"vue/multiline-html-element-content-newline": [
"never"
],"vue/no-unused-components": [
"never"
],},"overrides": [
{
"files": [
"*.vue"
],"rules": {
"indent": "off","vue/script-indent": [
"error",{
"baseIndent": 1,"ignores": [
// nested objects,excluding top level of exported object (data,methods,computed,etc.)
"[value.type='ObjectExpression']:not(:matches(ExportDefaultDeclaration,[left.property.name='exports']) > * > [value.type='ObjectExpression'])",// nested arrays
"[value.type='ArrayExpression']"
]
}
]
}
}
]
}
最佳答案
'overrides': [
{
'files': ['*.vue'],'rules': {
'indent': 'off'
}
}