ESlint Vue Plugin Rules

{
        /**
         * 支持在模版中使用 eslint-disable-next-line 等注释
         * @category Enabling Correct ESLint Parsing
         */
        'vue/comment-directive': 'error',


        /**
         * 定义了的 jsx element 必须使用
         * @category Enabling Correct ESLint Parsing
         */
        'vue/jsx-uses-vars': 'error',


        /**
         * 计算属性禁止包含异步方法
         * @category Error Prevention
         */
        'vue/no-async-in-computed-properties': 'error',


        /**
         * 禁止重复的二级键名
         * @category Error Prevention
         */
        'vue/no-dupe-keys': 'error',


        /**
         * 禁止出现重复的属性
         * @category Error Prevention
         */
        'vue/no-duplicate-attributes': 'error',


        /**
         * 禁止出现语法错误
         * @category Error Prevention
         */
        'vue/no-parsing-error': 'error',


        /**
         * 禁止覆盖保留字
         * @category Error Prevention
         */
        'vue/no-reserved-keys': 'error',


        /**
         * 组件的 data 属性的值必须是一个函数
         * @category Error Prevention
         */
        'vue/no-shared-component-data': 'error',


        /**
         * 禁止在计算属性中对属性修改
         * @category Error Prevention
         * @reason 太严格了
         */
        'vue/no-side-effects-in-computed-properties': 'error',


        /**
         * 禁止 <template> 使用 key 属性
         * @category Error Prevention
         * @reason 太严格了
         */
        'vue/no-template-key': 'error',


        /**
         * 禁止在 <textarea> 中出现 {{message}}
         * @category Error Prevention
         */
        'vue/no-textarea-mustache': 'error',


        /**
         * 禁止定义在 components 中的组件未使用
         * @category Error Prevention
         */
        'vue/no-unused-components': 'error',


        /**
         * 禁止模版中定义的变量未使用
         * @category Error Prevention
         */
        'vue/no-unused-vars': 'error',


        /**
         * 禁止在同一个元素上使用 v-if 和 v-for 指令
         * @category Error Prevention
         */
        'vue/no-use-v-if-with-v-for': 'error',


        /**
         * <component> 必须有 v-bind:is
         * @category Error Prevention
         */
        'vue/require-component-is': 'error',


        /**
         * props 的取值必须是构造函数
         * @category Error Prevention
         * @fixable
         */
        'vue/require-prop-type-constructor': 'error',


        /**
         * render 函数必须有返回值
         * @category Error Prevention
         */
        'vue/require-render-return': 'error',


        /**
         * v-for 指令的元素必须有 v-bind:key
         * @category Error Prevention
         */
        'vue/require-v-for-key': 'error',


        /**
         * prop 的默认值必须匹配它的类型
         * @category Error Prevention
         * @reason 太严格了
         */
        'vue/require-valid-default-prop': 'error',


        /**
         * 计算属性必须有返回值
         * @category Error Prevention
         */
        'vue/return-in-computed-property': 'error',


        /**
         * 当一个节点上出现两个 v-on:click 时,其中一个必须为 exact
         * @category Error Prevention
         */
        'vue/use-v-on-exact': 'error',


        /**
         * template 的根节点必须合法
         * @category Error Prevention
         */
        'vue/valid-template-root': 'error',


        /**
         * v-bind 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-bind': 'error',


        /**
         * v-cloak 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-cloak': 'error',


        /**
         * v-else 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-else': 'error',


        /**
         * v-else-if 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-else-if': 'error',


        /**
         * v-for 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-for': 'error',


        /**
         * v-html 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-html': 'error',


        /**
         * v-if 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-if': 'error',


        /**
         * v-model 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-model': 'error',


        /**
         * v-on 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-on': 'error',


        /**
         * v-once 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-once': 'error',


        /**
         * v-pre 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-pre': 'error',


        /**
         * v-show 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-show': 'error',


        /**
         * v-text 指令必须合法
         * @category Error Prevention
         */
        'vue/valid-v-text': 'error',


        /**
         * 限制自定义组件的属性风格
         * @category Improving Readability
         * @reason 没必要限制
         * @fixable
         */
        'vue/attribute-hyphenation': 'off',


        /**
         * 模版中开始标签的反尖括号必须换行
         * @category Improving Readability
         * @fixable
         */
        'vue/html-closing-bracket-newline': 'error',


        /**
         * 模版中开始标签的反尖括号前禁止有空格,自闭和标签前必须有空格
         * @category Improving Readability
         * @fixable
         */
        'vue/html-closing-bracket-spacing': 'error',


        /**
         * html 的结束标签必须符合规定
         * @category Improving Readability
         * @reason 有的标签不必严格符合规定,如 <br> 或 <br/> 都应该是合法的
         * @fixable
         */
        'vue/html-end-tags': 'error',


        /**
         * 模版中使用 4 个空格缩进
         * @category Improving Readability
         * @fixable
         */
        'vue/html-indent': ['error', 4],


        /**
         * html 属性值必须用双引号括起来
         * @category Improving Readability
         */
        'vue/html-quotes': 'error',


        /**
         * 没有内容时,组件必须自闭和
         * @category Improving Readability
         * @fixable
         */
        'vue/html-self-closing': 'error',


        /**
         * 限制每行允许的最多属性数量
         * @category Improving Readability
         */
        'vue/max-attributes-per-line': ["error", {
            "singleline": 1,
            "multiline": {
                "max": 1,
                "allowFirstLine": false
            }
        }],


        /**
         * 多行内容或多行标签时,内容前必须换行
         * @category Improving Readability
         * @fixable
         */
        'vue/multiline-html-element-content-newline': 'error',


        /**
         * 模版内 mustache 大括号内前后禁止有空格
         * @category Improving Readability
         * @fixable
         */
        'vue/mustache-interpolation-spacing': ['error', 'never'],


        /**
         * 限制组件的 name 属性的值的风格
         * @category Improving Readability
         * @reason 没必要限制
         * @fixable
         */
        'vue/name-property-casing': ["error", "PascalCase"],


        /**
         * 禁止出现连续空格
         * @category Improving Readability
         * @fixable
         */
        'vue/no-multi-spaces': 'error',


        /**
         * 属性的等号前后禁止有空格
         * @category Improving Readability
         * @fixable
         */
        'vue/no-spaces-around-equal-signs-in-attribute': 'error',


        /**
         * 模版中的变量名禁止与前一个作用域重名
         * @category Improving Readability
         */
        'vue/no-template-shadow': 'off',


        /**
         * props 必须用驼峰式
         * @category Improving Readability
         * @fixable
         */
        'vue/prop-name-casing': 'off',


        /**
         * props 如果不是 required 的字段,必须有默认值
         * @category Improving Readability
         */
        'vue/require-default-prop': 'error',


        /**
         * prop 必须有类型限制
         * @category Improving Readability
         */
        'vue/require-prop-types': 'error',


        /**
         * 单行标签内容必须换行
         * @category Improving Readability
         * @fixable
         */
        'vue/singleline-html-element-content-newline': 'error',


        /**
         * 限制 v-bind 的风格
         * @category Improving Readability
         * @fixable
         */
        'vue/v-bind-style': 'error',


        /**
         * 限制 v-on 的风格
         * @category Improving Readability
         * @fixable
         */
        'vue/v-on-style': 'error',


        /**
         * 标签属性必须按规则排序
         * @category Minimizing Arbitrary Choices and Cognitive Overhead
         * @fixable
         */
        'vue/attributes-order': 'error',


        /**
         * 禁用 v-html
         * @category Minimizing Arbitrary Choices and Cognitive Overhead
         */
        'vue/no-v-html': 'error',


        /**
         * 组件的属性必须为一定的顺序
         * @category Minimizing Arbitrary Choices and Cognitive Overhead
         */
        'vue/order-in-components': 'error',


        /**
         * 禁止在模版中用 this
         * @category Minimizing Arbitrary Choices and Cognitive Overhead
         */
        'vue/this-in-template': 'error',


        /**
         * 数组的括号内的前后禁止有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/array-bracket-spacing': ['error', 'never'],


        /**
         * 箭头函数的箭头前后必须有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/arrow-spacing': [
            'error',
            {
                before: true,
                after: true
            }
        ],


        /**
         * 代码块如果在一行内,那么大括号内的首尾必须有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/block-spacing': ['error', 'always'],


        /**
         * if 与 else 的大括号风格必须一致
         * @category Uncategorized
         * @reason else 代码块可能前面需要有一行注释
         * @fixable
         */
        'vue/brace-style': 'off',


        /**
         * 变量名必须是 camelcase 风格的
         * @category Uncategorized
         * @reason 很多 api 或文件名都不是 camelcase
         */
        'vue/camelcase': 'off',


        /**
         * 对象的最后一个属性末尾必须有逗号
         * @category Uncategorized
         * @fixable
         */
        'vue/comma-dangle': 'off',


        /**
         * 约束自定义标签的命名规则
         * @category Uncategorized
         * @fixable
         */
        'vue/component-name-in-template-casing': 'off',


        /**
         * 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
         * @category Uncategorized
         * @fixable
         */
        'vue/eqeqeq': [
            'error',
            'always',
            {
                null: 'ignore'
            }
        ],


        /**
         * 对象字面量中冒号前面禁止有空格,后面必须有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/key-spacing': [
            'error',
            {
                beforeColon: false,
                afterColon: true,
                mode: 'strict'
            }
        ],


        /**
         * 组件名称必须和文件名一致
         * @category Uncategorized
         */
        'vue/match-component-file-name': 'off',


        /**
         * 禁止给布尔值 props 添加默认值
         * @category Uncategorized
         * @fixable
         */
        'vue/no-boolean-default': 'off',


        /**
         * 禁止使用特定的语法
         * @category Uncategorized
         * @reason 它用于限制某个具体的语法不能使用
         */
        'vue/no-restricted-syntax': 'off',


        /**
         * 对象字面量只有一行时,大括号内的首尾必须有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/object-curly-spacing': [
            'error',
            'always',
            {
                arraysInObjects: true,
                objectsInObjects: false
            }
        ],


        /**
         * 禁止手动 export default
         * @category Uncategorized
         */
        'vue/require-direct-export': 'error',


        /**
         * 一个缩进必须用四个空格替代
         * @category Uncategorized
         */
        'vue/script-indent': [
            'error',
            4,
            {
                switchCase: 1
            }
        ],


        /**
         * 操作符左右必须有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/space-infix-ops': 'error',


        /**
         * new, typeof 等后面必须有空格,++, -- 等禁止有空格
         * @category Uncategorized
         * @fixable
         */
        'vue/space-unary-ops': [
            'error',
            {
                words: true,
                nonwords: false
            }
        ],


        /**
         * 禁止在 v-on 的值中调用函数
         * @category Uncategorized
         * @fixable
         */
        'vue/v-on-function-call': 'error'
    }
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,242评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,769评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,484评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,133评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,007评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,080评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,496评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,190评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,464评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,549评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,330评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,205评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,567评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,889评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,160评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,475评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,650评论 2 335

推荐阅读更多精彩内容