vue官方eslint插件配置eslint-plugin-vue-libs
生活随笔
收集整理的這篇文章主要介紹了
vue官方eslint插件配置eslint-plugin-vue-libs
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
由于eslint-config-vue已經(jīng)被廢棄,于是總結(jié)了一下eslint-plugin-vue-libs的eslint config配置,如下:
module.exports = {extends: ['plugin:vue/essential'],plugins: ['vue-libs'],parserOptions: {parser: require.resolve('babel-eslint'),ecmaVersion: 2017,sourceType: 'module'},env: {es6: true,node: true},globals: {document: false,navigator: false,window: false},rules: {// 0 禁用此規(guī)則 1 不符合規(guī)則即給出警告 2 不符合規(guī)則即報(bào)錯(cuò)'accessor-pairs': 2,// 在對(duì)象中使用getter/setter'arrow-spacing': [2, { 'before': true, 'after': true }],// 箭頭函數(shù)前后括號(hào)'block-spacing': [2, 'always'],// 塊級(jí)作用域縮進(jìn) https://eslint.org/docs/rules/block-spacing#rule-details'brace-style': [2, '1tbs', { 'allowSingleLine': true }],// 大括號(hào)風(fēng)格,允許寫(xiě)在一行 https://eslint.org/docs/rules/brace-style#require-brace-style-brace-style'camelcase': [2, { 'properties': 'never' }],// 強(qiáng)制駝峰命名法 'comma-dangle': [2, 'never'],// 對(duì)象字面量項(xiàng)尾不能有逗號(hào)'comma-spacing': [2, { 'before': false, 'after': true }],// 逗號(hào)前后的空格'comma-style': [2, 'last'],// 逗號(hào)風(fēng)格,換行時(shí)在行首還是行尾'constructor-super': 2,// 非派生類(lèi)不能調(diào)用super,派生類(lèi)必須調(diào)用super'curly': [2, 'multi-line'],// 塊級(jí)作用域可以不帶大括號(hào) https://eslint.org/docs/rules/curly#require-following-curly-brace-conventions-curly'dot-location': [2, 'property'],// 對(duì)象訪(fǎng)問(wèn)符的位置,換行的時(shí)候在行首 https://eslint.org/docs/rules/dot-location#enforce-newline-before-and-after-dot-dot-location'eol-last': 2,// 文件以單一的換行符結(jié)束'eqeqeq': [2, 'allow-null'], // 必須使用全等'generator-star-spacing': [2, { 'before': true, 'after': true }],// generate函數(shù)的前后空格'handle-callback-err': [2, '^(err|error)$' ],// nodejs函數(shù)處理錯(cuò)誤'indent': [2, 2, { 'SwitchCase': 1 }],// 縮進(jìn)風(fēng)格,switch縮進(jìn)風(fēng)格'jsx-quotes': [2, 'prefer-single'],// jsx使用單引號(hào)'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],// 對(duì)象字面量中冒號(hào)添加后空格'keyword-spacing': [2, { 'before': true, 'after': true }],// 關(guān)鍵字前后空格'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }],// 新建對(duì)象實(shí)例首字母必須大寫(xiě)'new-parens': 2,// new時(shí)必須加小括號(hào)'no-array-constructor': 2,// 禁止使用數(shù)組構(gòu)造器 https://eslint.org/docs/rules/no-array-constructor#rule-details'no-caller': 2, // 禁止使用arguments.caller或arguments.callee'no-class-assign': 2, // 禁止給類(lèi)賦值'no-cond-assign': 2,// 禁止在條件表達(dá)式中使用賦值語(yǔ)句'no-const-assign': 2,//禁止修改const聲明的變量'no-control-regex': 2,//禁止在正則表達(dá)式中使用控制字符'no-delete-var': 2,//不能對(duì)var聲明的變量使用delete操作符'no-dupe-args': 2,//函數(shù)參數(shù)不能重復(fù)'no-dupe-class-members': 2, //對(duì)象成員不能重復(fù)'no-dupe-keys': 2,//在創(chuàng)建對(duì)象字面量時(shí)不允許鍵重復(fù)'no-duplicate-case': 2,//switch中的case標(biāo)簽不能重復(fù)'no-empty-character-class': 2,//正則表達(dá)式中的[]內(nèi)容不能為空'no-empty-pattern': 2,// https://eslint.org/docs/rules/no-empty-pattern#version'no-eval': 2,//禁止使用eval'no-ex-assign': 2,//禁止給catch語(yǔ)句中的異常參數(shù)賦值'no-extend-native': 2,//禁止擴(kuò)展native對(duì)象'no-extra-bind': 2,//禁止不必要的函數(shù)綁定'no-extra-boolean-cast': 2,//禁止不必要的bool轉(zhuǎn)換'no-extra-parens': [2, 'functions'],//禁止非必要的括號(hào)'no-fallthrough': 2,//禁止switch穿透'no-floating-decimal': 2,//禁止省略浮點(diǎn)數(shù)中的0 .5 3.'no-func-assign': 2,//禁止重復(fù)的函數(shù)聲明'no-implied-eval': 2,禁止使用隱式eval'no-inner-declarations': [2, 'functions'],//禁止在塊語(yǔ)句中使用聲明(變量或函數(shù))'no-invalid-regexp': 2,//禁止無(wú)效的正則表達(dá)式'no-irregular-whitespace': 2,//不能有不規(guī)則的空格'no-iterator': 2,//禁止使用__iterator__ 屬性'no-label-var': 2,//label名不能與var聲明的變量名相同'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }],'no-lone-blocks': 2,//禁止標(biāo)簽聲明'no-mixed-spaces-and-tabs': 2,//禁止混用tab和空格'no-multi-spaces': [2, { "ignoreEOLComments": true }],//不能用多余的空格'no-multi-str': 2,//字符串不能用\換行'no-multiple-empty-lines': [2, { 'max': 1 }],//空行最多不能超過(guò)2行'no-native-reassign': 2,//不能重寫(xiě)native對(duì)象'no-negated-in-lhs': 2,//in 操作符的左邊不能有!'no-new-object': 2,//禁止使用new Object()'no-new-require': 2,//禁止使用new require'no-new-symbol': 2,// 使用Symbol()而不能使用new'no-new-wrappers': 2,// https://eslint.org/docs/rules/no-new-wrappers#disallow-primitive-wrapper-instances-no-new-wrappers'no-obj-calls': 2,//不能調(diào)用內(nèi)置的全局對(duì)象,比如Math() JSON()'no-octal': 2,//禁止使用八進(jìn)制數(shù)字'no-octal-escape': 2,//禁止使用八進(jìn)制轉(zhuǎn)義序列'no-path-concat': 2,//node中不能使用__dirname或__filename做路徑拼接'no-proto': 2,//禁止使用__proto__屬性'no-redeclare': 2,//禁止重復(fù)聲明變量'no-regex-spaces': 2,//禁止在正則表達(dá)式字面量中使用多個(gè)空格'no-return-assign': [2, 'except-parens'],//return 語(yǔ)句中不能有賦值表達(dá)式'no-self-assign': 2,// 不能自聲明'no-self-compare': 2,// 不能自比較'no-sequences': 2,//禁止使用逗號(hào)運(yùn)算符'no-shadow-restricted-names': 2,//嚴(yán)格模式中規(guī)定的限制標(biāo)識(shí)符不能作為聲明時(shí)的變量名使用'no-spaced-func': 2,// 函數(shù)調(diào)用時(shí) 函數(shù)名與()之間不能有空格'no-sparse-arrays': 2,//禁止稀疏數(shù)組, [1,,2]'no-this-before-super': 2,//在調(diào)用super()之前不能使用this或super'no-throw-literal': 2,//禁止拋出字面量錯(cuò)誤 throw "error";'no-trailing-spaces': 2,//一行結(jié)束后面不要有空格'no-undef': 2,//不能有未定義的變量'no-undef-init': 2,//變量初始化時(shí)不能直接給它賦值為undefined'no-unexpected-multiline': 2,//避免多行表達(dá)式'no-unmodified-loop-condition': 2,//不使用未定義的循環(huán)條件'no-unneeded-ternary': [2, { 'defaultAssignment': false }],//禁止不必要的嵌套 https://eslint.org/docs/rules/no-unneeded-ternary#disallow-ternary-operators-when-simpler-alternatives-exist-no-unneeded-ternary'no-unreachable': 2,//不能有無(wú)法執(zhí)行的代碼'no-unsafe-finally': 2,// finally中不能執(zhí)行有歧義的代碼'no-unused-vars': [2, { 'vars': 'all', 'args': 'none' }],//不聲明未使用的變量'no-useless-call': 2,//禁止不必要的call和apply'no-useless-computed-key': 2,//不聲明無(wú)用的鍵'no-useless-constructor': 2,// https://eslint.org/docs/rules/no-useless-constructor#disallow-unnecessary-constructor-no-useless-constructor'no-useless-escape': 0,// https://eslint.org/docs/rules/no-useless-escape#disallow-unnecessary-escape-usage-no-useless-escape'no-whitespace-before-property': 2,// 對(duì)象鍵之前無(wú)空格'no-with': 2,//禁用with'one-var': [2, { 'initialized': 'never' }],//禁用連續(xù)聲明'operator-linebreak': [2, 'after', { 'overrides': { '?': 'before', ':': 'before' } }],//換行時(shí)運(yùn)算符在行尾還是行首'padded-blocks': [2, 'never'],//塊語(yǔ)句內(nèi)行首行尾不能空行'quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],//使用單引號(hào)'semi': [2, 'never'],//不使用語(yǔ)句強(qiáng)制分號(hào)結(jié)尾'semi-spacing': [2, { 'before': false, 'after': true }],//分號(hào)前后空格'space-before-blocks': [2, 'always'],//不以新行開(kāi)始的塊{前面需要有空格'space-before-function-paren': [2, 'always'],//函數(shù)定義時(shí)括號(hào)前面需要有空格'space-in-parens': [2, 'never'],//小括號(hào)里面不需要有空格'space-infix-ops': 2,//中綴操作符周?chē)枰锌崭?#39;space-unary-ops': [2, { 'words': true, 'nonwords': false }],//一元運(yùn)算符的前/后要不要加空格'spaced-comment': [2, 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }],//注釋風(fēng)格需要有空格'template-curly-spacing': [2, 'never'],//模板中{}包裹的變量不需要空格'use-isnan': 2,//禁止比較時(shí)使用NaN,只能用isNaN()'valid-typeof': 2,//必須使用合法的typeof的值'wrap-iife': [2, 'any'],//立即執(zhí)行函數(shù)表達(dá)式的小括號(hào)風(fēng)格任意一種都可以'yield-star-spacing': [2, 'both'],// generate 函數(shù) yeild風(fēng)格'yoda': [2, 'never'],//禁止尤達(dá)條件'prefer-const': 2,//優(yōu)先使用const'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,//禁止使用debugger,開(kāi)發(fā)環(huán)境允許使用'object-curly-spacing': [2, 'always', { objectsInObjects: false }],//大括號(hào)內(nèi)是否允許不必要的空格'array-bracket-spacing': [2, 'never'],//是否允許非空數(shù)組里面有多余的空格'vue-libs/jsx-uses-vars': 2,'vue/require-v-for-key': 0} }轉(zhuǎn)載于:https://www.cnblogs.com/goOtter/p/10636787.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的vue官方eslint插件配置eslint-plugin-vue-libs的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Spring Boot 自动配置原理
- 下一篇: html5倒计时秒杀怎么做,vue 设