javascript-vue-cli3 eslint vue / script-indent与编译器冲突

前端之家收集整理的这篇文章主要介绍了javascript-vue-cli3 eslint vue / script-indent与编译器冲突 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我拥有.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文件中的规则)

enter image description here

<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'
  }
}

reference

原文链接:https://www.f2er.com/js/531164.html

猜你在找的JavaScript相关文章