关于vue eslint ident缩进红色波浪线及尾随空格

关于vue eslint ident缩进红色波浪线及尾随空格

目录

关于vue eslint ident缩进红色波浪线及尾随空格

一、现象

二、官方说明

三、经验处理方法

3.1、“缩进遗留”及“尾随空格”

3.2、原因

3.3、修正经验

3.4、其他相关的修正经验


一、现象

二、官方说明

Getting Started with ESLint - ESLint - Pluggable JavaScript Linter

其中,看Configuration配置部分

        好像,说的含含糊糊......

三、经验处理方法

3.1、“缩进遗留”及“尾随空格”

indent-legacy - ESLint - Pluggable JavaScript Linter

eol-last - ESLint - Pluggable JavaScript Linter

        强制一致的缩进的fix补丁,--fix 命令行选项 自动修复,在“ESLint v4.0.0中已弃用”。

       eol尾随“LF”换行符,而非“尾随空格”,是要求的方式,但实际中,我们不经意的给空格。

        那么,怎么办呢?!

3.2、原因

       官方在版本过渡期间,为了兼顾老版本的代码,在配置文件“.eslintrc.js”中,配置了“规则rules”:

        导致了,缩进为 2 * 2 = 4,js文件一点保存,就起“红色波浪线”而“警示”,只要你看得惯,那你就不改吧?!

3.3、修正经验

3.3.1、方法1

        'indent': [0, 0, {
            'SwitchCase': 1
        }],

3.3.2、方法2---直接关掉

        'eol-last': 0,
        // : ESLint讨厌的文档末尾行的“尾随空格” :'eol-last': 2,

 3.3.3、方法3---需要的文件,首置comment指令

/* eslint-disable eol-last */
/* eslint-disable indent */

当然,如果还要屏蔽掉“禁用尾随空格”的指令,也可一并加上:

/* eslint-disable eol-last */
/* eslint-disable indent */

3.4、其他相关的修正经验

        "vue/max-attributes-per-line": [2, {
            "singleline": 10,
            "multiline": {
                "max": 1,
                "allowFirstLine": false
            }
        }],
        "vue/singleline-html-element-content-newline": "off",
        "vue/multiline-html-element-content-newline": "off",
        "vue/name-property-casing": ["error", "PascalCase"],
        "vue/no-v-html": "off",
        'accessor-pairs': 2,
        'arrow-spacing': [2, {
            'before': true,
            'after': true
        }],
        'block-spacing': [2, 'always'],
        'brace-style': [2, '1tbs', {
            'allowSingleLine': true
        }],
        'comma-style': [2, 'last'],
        'constructor-super': 2,
        'curly': [2, 'multi-line'],
        'dot-location': [2, 'property'],
        'eqeqeq': ["error", "always", { "null": "ignore" }],
        'generator-star-spacing': [2, {
            'before': true,
            'after': true
        }],
        'handle-callback-err': [2, '^(err|error)$'],
        // 'comma-dangle': [2, 'never'],
        'camelcase': [0, {
            'properties': 'always'
        }],
        'comma-spacing': [2, {
            'before': false,
            'after': true
        }],
        'jsx-quotes': [2, 'prefer-single'],
        // 'key-spacing': [2, {
        //     'beforeColon': false,
        //     'afterColon': true
        // }],
        'key-spacing': [0, {}],
        // 'keyword-spacing': [2, {
        //     'before': false,
        //     'after': true
        // }],
        'keyword-spacing': [0, {}],
        'new-cap': [2, {
            'newIsCap': true,
            'capIsNew': false
        }],
        // 'no-unused-vars': [2, {  'vars': 'all',  'args': 'none'  }],
        'no-unused-vars': [0, []],

module.exports = {
    /** :除上述经验配置外:
     * 主要注意:
     * 1、以上做的一些配置
     * 2、src等源代码中:
     * 2.1、箭头函数 () => 前后空格
     * 2.2、函数  function aFun() {}  前后空格
     * 2.3、组件-模板  单双引号
     * 2.4、组件-脚本  导入模块 { aModule } 对象中前后空格
     * 3、jsconfig.json
     *    加compilerOptions选项属性:  "jsx":"preserve"
    */
}

 module.exports = {
    /** :除上述经验配置外:
     * 主要注意:
     * 1、以上做的一些配置
     * 2、src等源代码中:
     * 2.1、箭头函数 () => 前后空格
     * 2.2、函数  function aFun() {}  前后空格
     * 2.3、组件-模板  单双引号
     * 2.4、组件-脚本  导入模块 { aModule } 对象中前后空格
     * 3、jsconfig.json
     *    加compilerOptions选项属性:  "jsx":"preserve"
    */
}

  喜欢的,就收藏并点个赞,鼓励我继续技术的原创写作及经验分享:

部署vue2 element-ui admin_pulledup的博客-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

专讲冷知识

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值