|
1 |
| -/* prettier-ignore */ |
2 | 1 | module.exports = {
|
3 | 2 | root: true,
|
4 |
| - parser: 'babel-eslint', |
| 3 | + parser: 'vue-eslint-parser', |
5 | 4 | parserOptions: {
|
| 5 | + parser: '@babel/eslint-parser', |
6 | 6 | sourceType: 'module'
|
7 | 7 | },
|
8 | 8 | env: {
|
9 | 9 | browser: true,
|
10 | 10 | node: true,
|
11 |
| - es6: true, |
| 11 | + es6: true |
12 | 12 | },
|
13 |
| - extends: 'eslint:recommended', |
| 13 | + extends: ['plugin:vue/essential', 'eslint:recommended'], |
14 | 14 | // required to lint *.vue files
|
15 |
| - plugins: [ |
16 |
| - 'html', |
17 |
| - 'vue' |
18 |
| - ], |
| 15 | + plugins: ['vue', 'html'], |
19 | 16 | // check if imports actually resolve
|
20 |
| - 'settings': { |
21 |
| - 'import/resolver': { |
22 |
| - 'webpack': { |
23 |
| - 'config': 'build/webpack.base.conf.js' |
24 |
| - } |
25 |
| - } |
26 |
| - }, |
27 |
| - "globals": { |
28 |
| - "BMap": true, |
29 |
| - "AMap": true, |
30 |
| - "AMapUI": true, |
31 |
| - "processEnv": true, |
32 |
| - "_": true, |
33 |
| - "Prism": true, |
34 |
| - "QRCode": true, |
35 |
| - "QC": true |
| 17 | + |
| 18 | + globals: { |
| 19 | + BMap: true, |
| 20 | + AMap: true, |
| 21 | + AMapUI: true, |
| 22 | + processEnv: true, |
| 23 | + _: true, |
| 24 | + Prism: true, |
| 25 | + QRCode: true, |
| 26 | + QC: true |
36 | 27 | },
|
37 | 28 | // add your custom rules here
|
38 | 29 | //it is base on https://github.com/vuejs/eslint-config-vue
|
39 | 30 | rules: {
|
40 |
| - // 定义对象的set存取器属性时,强制定义get |
41 |
| - 'accessor-pairs': 2, |
42 |
| - // =>的前后空格 |
43 |
| - 'arrow-spacing': [2, { |
44 |
| - 'before': true, |
45 |
| - 'after': true |
46 |
| - }], |
47 |
| - //如果代码块是单行的时候,代码块内部前后需要留一个空格 |
48 |
| - 'block-spacing': [2, 'always'], |
49 |
| - // if while function 后面的{必须与if在同一行,java风格。 |
50 |
| - 'brace-style': [0, '1tbs', { |
51 |
| - 'allowSingleLine': true |
52 |
| - }], |
53 |
| - 'camelcase': [0, { |
54 |
| - 'properties': 'always' |
55 |
| - }], |
56 |
| - // 数组和对象键值对最后一个逗号, never参数:不能带末尾的逗号, always参数:必须带末尾的逗号, |
57 |
| - // always-multiline:多行模式必须带逗号,单行模式不能带逗号 |
58 |
| - 'comma-dangle': [2, 'never'], |
59 |
| - // 控制逗号前后的空格 |
60 |
| - 'comma-spacing': [2, { |
61 |
| - 'before': false, |
62 |
| - 'after': true |
63 |
| - }], |
64 |
| - // 控制逗号在行尾出现还是在行首出现 |
65 |
| - 'comma-style': [2, 'last'], |
66 |
| - // 强制在子类构造函数中用super()调用父类构造函数,TypeScrip的编译器也会提示 |
67 |
| - 'constructor-super': 2, |
68 |
| - 'curly': [2, 'multi-line'], |
69 |
| - // 强制object.key 中 . 的位置,参数: |
70 |
| - // property,'.'号应与属性在同一行 |
71 |
| - // object, '.' 号应与对象名在同一行 |
72 |
| - 'dot-location': [2, 'property'], |
73 |
| - 'eol-last': 2, |
74 |
| - // 使用 === 替代 == |
75 |
| - 'eqeqeq': [1, 'allow-null'], |
76 |
| - //生成器函数*的前后空格 |
77 |
| - 'generator-star-spacing': [2, { |
78 |
| - 'before': true, |
79 |
| - 'after': true |
80 |
| - }], |
81 |
| - //缩进风格 |
82 |
| - 'indent': [2, 2, { |
83 |
| - 'SwitchCase': 1 |
84 |
| - }], |
85 |
| - // 对所有不包含单引号的JSX属性值强制使用单引号 |
86 |
| - // 'jsx-quotes': [2, 'prefer-single'], |
87 |
| - //对象字面量中冒号的前后空格 |
88 |
| - 'key-spacing': [2, { |
89 |
| - 'beforeColon': false, |
90 |
| - 'afterColon': true |
91 |
| - }], |
92 |
| - // 关键字空格 |
93 |
| - 'keyword-spacing': [2, { |
94 |
| - 'before': true, |
95 |
| - 'after': true |
96 |
| - }], |
97 |
| - //函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用 |
98 |
| - 'new-cap': [1, { |
99 |
| - 'newIsCap': true, |
100 |
| - 'capIsNew': false |
101 |
| - }], |
102 |
| - //new时必须加小括号 |
103 |
| - 'new-parens': 2, |
104 |
| - //禁止使用数组构造器 |
105 |
| - 'no-array-constructor': 1, |
106 |
| - //禁止使用arguments.caller或arguments.callee |
107 |
| - 'no-caller': 2, |
108 |
| - // 禁止使用console |
109 |
| - 'no-console': 'off', |
110 |
| - // 禁止给类赋值 |
111 |
| - 'no-class-assign': 2, |
112 |
| - //禁止在条件表达式中使用赋值语句 |
113 |
| - 'no-cond-assign': 2, |
114 |
| - //禁止修改const声明的变量 |
115 |
| - 'no-const-assign': 2, |
116 |
| - //禁止在正则表达式中使用控制字符 |
117 |
| - 'no-control-regex': 0, |
118 |
| - // 不能对var声明的变量使用delete操作符 |
119 |
| - 'no-delete-var': 2, |
120 |
| - // 函数参数不能重复 |
121 |
| - 'no-dupe-args': 2, |
122 |
| - // class中的成员禁止重名 |
123 |
| - 'no-dupe-class-members': 2, |
124 |
| - // 在对象字面量中,禁止使用重复的key |
125 |
| - 'no-dupe-keys': 2, |
126 |
| - // 在switch语句中禁止重复的case |
127 |
| - 'no-duplicate-case': 2, |
128 |
| - // 禁止使用不匹配任何字符串的正则表达式 |
129 |
| - 'no-empty-character-class': 2, |
130 |
| - // 禁止使用不匹配任何字符串的正则表达式 |
131 |
| - 'no-empty-pattern': 2, |
132 |
| - // 禁止使用eval函数 |
133 |
| - 'no-eval': 1, |
134 |
| - // 禁止对catch语句中的参数进行赋值 |
135 |
| - 'no-ex-assign': 2, |
136 |
| - // 禁止扩展原生对象 |
137 |
| - 'no-extend-native': 2, |
138 |
| - // 禁止在不必要的时候使用bind函数 |
139 |
| - 'no-extra-bind': 1, |
140 |
| - //在一个本来就会自动转化为布尔值的上下文中就没必要再使用!! 进行强制转化了 |
141 |
| - 'no-extra-boolean-cast': 1, |
142 |
| - // 禁止使用多余的圆括号 |
143 |
| - 'no-extra-parens': [2, 'functions'], |
144 |
| - // 在case语句中尽量加break |
145 |
| - 'no-fallthrough': 2, |
146 |
| - // 简单来说不要写这样的数字.2 2.。应该写全,2.2 2.0 . |
147 |
| - // 'no-floating-decimal': 2, |
148 |
| - // 禁止对函数名重新赋值 |
149 |
| - 'no-func-assign': 2, |
150 |
| - // 禁止使用类eval的函数。 |
151 |
| - 'no-implied-eval': 2, |
152 |
| - // 禁止在代码块中定义函数(下面的规则仅限制函数) |
153 |
| - 'no-inner-declarations': [1, 'functions'], |
154 |
| - // RegExp构造函数中禁止使用非法正则语句 |
155 |
| - 'no-invalid-regexp': 2, |
156 |
| - //禁止使用不规则的空白符 |
157 |
| - 'no-irregular-whitespace': 2, |
158 |
| - //禁止使用__iterator__属性 |
159 |
| - 'no-iterator': 2, |
160 |
| - // label和var申明的变量不能重名 |
161 |
| - 'no-label-var': 2, |
162 |
| - // 禁止使用label语句 |
163 |
| - 'no-labels': [2, { |
164 |
| - 'allowLoop': false, |
165 |
| - 'allowSwitch': false |
166 |
| - }], |
167 |
| - // 禁止使用没有必要的嵌套代码块 |
168 |
| - 'no-lone-blocks': 2, |
169 |
| - // 不要把空格和tab混用 |
170 |
| - 'no-mixed-spaces-and-tabs': 0, |
171 |
| - // 申明语句、数组元素、对象属性、sequences、函数参数中不使用超过一个的空白符 |
172 |
| - 'no-multi-spaces': 2, |
173 |
| - //该规则保证了字符串不分两行书写。 |
174 |
| - 'no-multi-str': 2, |
175 |
| - //空行不能够超过2行 |
176 |
| - 'no-multiple-empty-lines': [2, { |
177 |
| - 'max': 2 |
178 |
| - }], |
179 |
| - // 该规则保证了不重写原生对象 |
180 |
| - 'no-native-reassign': 2, |
181 |
| - //在in操作符左边的操作项不能用! 例如这样写不对的:if ( !a in b) { //dosomething } |
182 |
| - 'no-negated-in-lhs': 2, |
183 |
| - //不要通过new Object(),来定义对象 |
184 |
| - 'no-new-object': 1, |
185 |
| - //禁止把require方法和new操作符一起使用。 |
186 |
| - 'no-new-require': 2, |
187 |
| - 'no-new-symbol': 2, |
188 |
| - //当定义字符串、数字、布尔值就不要使用构造函数了,String、Number、Boolean |
189 |
| - 'no-new-wrappers': 2, |
190 |
| - //禁止无意把全局对象当函数调用了,比如下面写法错误的:Math(), JSON() |
191 |
| - 'no-obj-calls': 2, |
192 |
| - //不要使用八进制的语法。 |
193 |
| - 'no-octal': 2, |
194 |
| - 'no-octal-escape': 2, |
195 |
| - 'no-path-concat': 2, |
196 |
| - //不要使用__proto__ |
197 |
| - 'no-proto': 2, |
198 |
| - //不要重复申明一个变量 |
199 |
| - 'no-redeclare': 2, |
200 |
| - //正则表达式中不要使用空格 |
201 |
| - 'no-regex-spaces': 2, |
202 |
| - //return语句中不要写赋值语句 |
203 |
| - 'no-return-assign': [2, 'except-parens'], |
204 |
| - 'no-self-assign': 2, |
205 |
| - //不要和自身作比较 |
206 |
| - 'no-self-compare': 2, |
207 |
| - //不要使用逗号操作符 |
208 |
| - 'no-sequences': 2, |
209 |
| - // 禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等。 |
210 |
| - 'no-shadow-restricted-names': 2, |
211 |
| - // 函数调用时,圆括号前面不能有空格 |
212 |
| - 'no-spaced-func': 2, |
213 |
| - //禁止使用稀疏数组 |
214 |
| - 'no-sparse-arrays': 2, |
215 |
| - //在调用super之前不能使用this对象 |
216 |
| - 'no-this-before-super': 2, |
217 |
| - //一般来说,不允许抛出常量,例如 throw 'error' ,正确使用: throw new Error('something wrong') |
218 |
| - 'no-throw-literal': 2, |
219 |
| - //行末禁止加空格 |
220 |
| - 'no-trailing-spaces': 2, |
221 |
| - //禁止使用没有定义的变量,除非在/*global*/已经申明 |
222 |
| - 'no-undef': 2, |
223 |
| - //禁止把undefined赋值给一个变量 |
224 |
| - 'no-undef-init': 1, |
225 |
| - //禁止在不需要分行的时候使用了分行 |
226 |
| - 'no-unexpected-multiline': 2, |
227 |
| - 'no-unmodified-loop-condition': 2, |
228 |
| - //禁止使用没有必要的三元操作符,因为用些三元操作符可以使用其他语句替换 |
229 |
| - 'no-unneeded-ternary': [0, { |
230 |
| - 'defaultAssignment': false |
231 |
| - }], |
232 |
| - //禁止出现不可运行到的代码 |
233 |
| - 'no-unreachable': 1, |
234 |
| - //是否禁止在case语句中声明变量 |
235 |
| - 'no-case-declarations': 0, |
236 |
| - // 禁止在 finally 语句块中出现控制流语句 |
237 |
| - 'no-unsafe-finally': 2, |
238 |
| - // 禁止定义没用没使用的变量 |
239 |
| - 'no-unused-vars': [2, { |
240 |
| - 'vars': 'all', |
241 |
| - 'args': 'none' |
242 |
| - }], |
243 |
| - //禁止在不需要使用call()或者apply()的时候使用了这两个方法 |
244 |
| - 'no-useless-call': 2, |
245 |
| - 'no-useless-computed-key': 2, |
246 |
| - 'no-useless-constructor': 2, |
247 |
| - 'no-useless-escape': 0, |
248 |
| - 'no-whitespace-before-property': 2, |
249 |
| - //不要使用with语句 |
250 |
| - 'no-with': 2, |
251 |
| - //在某些场景只能使用一个var来申明变量 |
252 |
| - 'one-var': [2, { |
253 |
| - 'initialized': 'never' |
254 |
| - }], |
255 |
| - //在进行断行时,操作符应该放在行首还是行尾。并且还可以对某些操作符进行重写。 |
256 |
| - 'operator-linebreak': [2, 'after', { |
257 |
| - 'overrides': { |
258 |
| - '?': 'before', |
259 |
| - ':': 'before' |
260 |
| - } |
261 |
| - }], |
262 |
| - 'padded-blocks': [2, 'never'], |
263 |
| - //使用单引号 还是 双引号 |
264 |
| - 'quotes': [2, 'single', { |
265 |
| - 'avoidEscape': true, |
266 |
| - 'allowTemplateLiterals': true |
267 |
| - }], |
268 |
| - //是否加分号 |
269 |
| - 'semi': [2, 'never'], |
270 |
| - //该规则规定了分号前后的空格 |
271 |
| - 'semi-spacing': [2, { |
272 |
| - 'before': false, |
273 |
| - 'after': true |
274 |
| - }], |
275 |
| - //代码块前面需要加空格 |
276 |
| - 'space-before-blocks': [2, 'always'], |
277 |
| - //函数圆括号前面需要是否加空格 |
278 |
| - 'space-before-function-paren': [2, { |
279 |
| - "anonymous": "never", |
280 |
| - "named": "never", |
281 |
| - "asyncArrow": "always" |
282 |
| - }], |
283 |
| - //圆括号内部不需要加空格 |
284 |
| - 'space-in-parens': [2, 'never'], |
285 |
| - //操作符前后需要加空格 |
286 |
| - 'space-infix-ops': 2, |
287 |
| - //一元操作符前后是否需要加空格,单词类操作符需要加,而非单词类操作符不用加 |
288 |
| - 'space-unary-ops': [2, { |
289 |
| - 'words': true, |
290 |
| - 'nonwords': false |
291 |
| - }], |
292 |
| - //评论符号`/*` `//`,后面需要留一个空格 |
293 |
| - 'spaced-comment': [0, 'always', { |
294 |
| - 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] |
295 |
| - }], |
296 |
| - //强制模板字符串中空格的使用 |
297 |
| - 'template-curly-spacing': [2, 'never'], |
298 |
| - //推荐使用isNaN方法,而不要直接和NaN作比较 |
299 |
| - 'use-isnan': 2, |
300 |
| - //在使用typeof操作符时,作比较的字符串必须是合法字符串eg:'string' 'object' |
301 |
| - 'valid-typeof': 2, |
302 |
| - //立即执行函数需要用圆括号包围 |
303 |
| - 'wrap-iife': [1, 'any'], |
304 |
| - 'yield-star-spacing': [2, 'both'], |
305 |
| - 'yoda': [2, 'never'], |
306 |
| - // 首选const |
307 |
| - 'prefer-const': 0, |
308 |
| - 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, |
309 |
| - //大括号内是否允许不必要的空格 |
310 |
| - 'object-curly-spacing': [2, 'always', { |
311 |
| - objectsInObjects: true |
312 |
| - }], |
313 |
| - // 指定数组的元素之间要以空格隔开(,后面), never参数:[ 之后和 ] 之前不能带空格,always参数:[ 之后和 ] 之前必须带空格 |
314 |
| - 'array-bracket-spacing': [2, 'never'] |
| 31 | + 'vue/multi-word-component-names': 'off' |
315 | 32 | }
|
316 | 33 | }
|
0 commit comments