鍍金池/ 問(wèn)答/iOS  HTML/ eslint-plugin-vue插件關(guān)于vue文件中script總是縮進(jìn)出問(wèn)題

eslint-plugin-vue插件關(guān)于vue文件中script總是縮進(jìn)出問(wèn)題

vue-cli生成vue項(xiàng)目后添加eslinit報(bào)錯(cuò).
版本如下:

"babel-eslint": "^8.2.1",
 "eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",

具體配置如下:

// https://eslint.org/docs/user-guide/configuring

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 paren-less arrow functions
        'arrow-parens': 0,
        // allow async-await
        'generator-star-spacing': 'off',
        // allow debugger during development
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        // 通用空格一致
        'comma-spacing': 0,
        //方法前空格允許
        'space-before-function-paren': 0,
        // 限制使用單引號(hào),
        'quotes': 0,
        //不允許行尾有空格
        'no-trailing-spaces': 0,

        'no-unused-vars': 0,
        // 關(guān)閉語(yǔ)句強(qiáng)制分號(hào)結(jié)尾
        'semi': [2, 'always'],
        //空行最多不能超過(guò)100行
        'no-multiple-empty-lines': [0, {'max': 100}],
        //關(guān)閉禁止混用tab和空格
        'no-mixed-spaces-and-tabs': [0],
        'no-tabs': 0,
        'indent': ['error', 'tab'],
        //'indent': 0,
        //注釋空格
        'spaced-comment': 0,
        //判斷無(wú)等號(hào)
        'padded-blocks': 0,
        'no-useless-escape': 0
    },
    "overrides": [
        {
            "files": ["*.vue"],
            "rules": {
                "indent": "off",
                "vue/script-indent": ["error", 4, {"baseIndent": 4}]
            }
        }
    ]
}

報(bào)錯(cuò)信息如下:

clipboard.png

clipboard.png

解決方法已經(jīng)在官方github上的issue找遍,就連配置里面的overrides都是官方上找到的,現(xiàn)在只能是把ident關(guān)閉了
官方github:https://github.com/vuejs/esli...

回答
編輯回答
墨染殤

更新vue-cli遇到此問(wèn)題!目前我也沒(méi)找到合適辦法。就找到2個(gè)臨時(shí)變通辦法:

  1. 回檔使用eslint-plugin-html插件,不使用eslint-plugin-vue
  2. 像你說(shuō)的關(guān)閉'indent': 'off'

哎,強(qiáng)迫癥!習(xí)慣script標(biāo)簽內(nèi)容首行縮進(jìn)。

2017年4月19日 11:10