1 | {
|
2 | "parserOptions": {
|
3 | "ecmaVersion": 6,
|
4 | "sourceType": "module",
|
5 | // 可选择支持的语言特性
|
6 | "ecmaFeatures": {
|
7 | "jsx": true,
|
8 | "experimentalObjectRestSpread": true,
|
9 | "arrowFunctions": true,
|
10 | "blockBindings": true,
|
11 | "defaultParams": true,
|
12 | "destructuring": true,
|
13 | "forOf": true,
|
14 | "generators": true,
|
15 | "objectLiteralComputedProperties": true,
|
16 | "objectLiteralShorthandMethods": true,
|
17 | "objectLiteralShorthandProperties": true,
|
18 | "restParams": true,
|
19 | "spread": true,
|
20 | "templateStrings": true,
|
21 | "modules": true,
|
22 | "classes": true
|
23 | }
|
24 | },
|
25 |
|
26 | "parser": "babel-eslint",
|
27 |
|
28 | "plugins": [
|
29 | "react"
|
30 | ],
|
31 |
|
32 | "env": {
|
33 | "browser": true,
|
34 | "amd": true,
|
35 | "es6": true,
|
36 | "node": true,
|
37 | "mocha": true
|
38 | },
|
39 |
|
40 | "settings": {
|
41 | "import/parser": "babel-eslint",
|
42 | "import/resolve": {
|
43 | "moduleDirectory": ["node_modules", "src"]
|
44 | }
|
45 | },
|
46 |
|
47 | "globals": {
|
48 | "document": true,
|
49 | "navigator": true,
|
50 | "window": true,
|
51 | "BSGlobal": true,
|
52 | "_":true
|
53 | },
|
54 |
|
55 | "rules": {
|
56 | /* 规则等级设置:
|
57 | *
|
58 | * "off" or 0 - 关闭规则
|
59 | * "warn" or 1 - 开启规则,使用警告级别的错误:warn(不会导致程序退出)
|
60 | * "error" or 2 - 开启规则,使用错误级别的错误:error(当被触发的时候,程序会退出)
|
61 | *
|
62 | * */
|
63 |
|
64 |
|
65 | "react/jsx-uses-react": [
|
66 | "warn"
|
67 | ],
|
68 |
|
69 | "react/jsx-uses-vars": [
|
70 | "warn"
|
71 | ],
|
72 |
|
73 | /* 格式 -- 空格 */
|
74 |
|
75 | // 强制箭头函数的箭头之前或之后有空格 [AUTO]
|
76 | "arrow-spacing": [
|
77 | "error"
|
78 | ],
|
79 |
|
80 | // 强制 generator 函数中 * 号周围有空格 [AUTO]
|
81 | "generator-star-spacing": [
|
82 | "error",
|
83 | {"before": true, "after": false}
|
84 | ],
|
85 |
|
86 | // 禁止属性前有空格
|
87 | "no-whitespace-before-property": [
|
88 | "warn"
|
89 | ],
|
90 |
|
91 | // 前缀一元运算符之后加空格 [AUTO]
|
92 | "space-unary-ops": [
|
93 | "error", {
|
94 | "words": true
|
95 | }
|
96 | ],
|
97 |
|
98 | // 禁止运算符的小括号(后,和)前加空格 [AUTO]
|
99 | "space-in-parens": [
|
100 | "warn",
|
101 | "never"
|
102 | ],
|
103 |
|
104 | // 禁止函数声明小括号(前加空格 [AUTO]
|
105 | "space-before-function-paren": [
|
106 | "warn",
|
107 | "never"
|
108 | ],
|
109 |
|
110 | // 禁止函数调用小括号(前加空格 [AUTO]
|
111 | "no-spaced-func": [
|
112 | "warn"
|
113 | ],
|
114 |
|
115 | // 禁止行尾加空格 [AUTO]
|
116 | "no-trailing-spaces": [
|
117 | "warn", {
|
118 | "skipBlankLines": true
|
119 | }
|
120 | ],
|
121 |
|
122 | // 禁止在字符串和注释之外不规则的空白
|
123 | "no-irregular-whitespace": [
|
124 | "warn", {
|
125 | "skipComments": true
|
126 | }
|
127 | ],
|
128 |
|
129 | // 强制对象属性冒号前无空格, 冒号后有空格
|
130 | "key-spacing": [
|
131 | "error", {
|
132 | "beforeColon": false,
|
133 | "afterColon": true,
|
134 | "mode": "strict"
|
135 | }
|
136 | ],
|
137 |
|
138 | // 强制代码块大括号{前有空格 [AUTO]
|
139 | "space-before-blocks": [
|
140 | "warn",
|
141 | "always"
|
142 | ],
|
143 |
|
144 | /* 格式 -- 括号 */
|
145 |
|
146 | // 强制为多行语句使用大括号
|
147 | "curly": [
|
148 | "error",
|
149 | "multi-line"
|
150 | ],
|
151 |
|
152 | // 强制使用一种大括号风格
|
153 | "brace-style": [
|
154 | "error",
|
155 | "1tbs"
|
156 | ],
|
157 |
|
158 | /* 格式 -- 逗号 */
|
159 |
|
160 | // 禁止数组、对象最后的成员加逗号
|
161 | "comma-dangle": [
|
162 | "error",
|
163 | "never"
|
164 | ],
|
165 | /*"indent": ["warn", "tab"],*/
|
166 | /* 语法 -- 变量 */
|
167 |
|
168 | // 不允许改变用const声明的变量
|
169 | "no-const-assign": [
|
170 | "error"
|
171 | ],
|
172 |
|
173 | // 禁止重复声明变量
|
174 | "no-redeclare": [
|
175 | "error"
|
176 | ],
|
177 |
|
178 | // 禁止声明了变量却不使用
|
179 | "no-unused-vars": [
|
180 | "warn",
|
181 | { "args": "none" }
|
182 | ],
|
183 |
|
184 | // 禁止先使用后声明变量
|
185 | "no-use-before-define": [
|
186 | "error"
|
187 | ],
|
188 |
|
189 | // 禁止自我赋值
|
190 | "no-self-assign": [
|
191 | "error"
|
192 | ],
|
193 |
|
194 | // 禁止删除变量
|
195 | "no-delete-var": [
|
196 | "error"
|
197 | ],
|
198 |
|
199 | // 不允许修改类声明的变量
|
200 | "no-class-assign": [
|
201 | "error"
|
202 | ],
|
203 |
|
204 | // 不允许类成员中有重复的名称
|
205 | "no-dupe-class-members": [
|
206 | "error"
|
207 | ],
|
208 |
|
209 | /* 语法 -- 函数 */
|
210 |
|
211 | // 要求箭头函数的参数使用圆括号
|
212 | "arrow-parens": [
|
213 | "error",
|
214 | "as-needed"
|
215 | ],
|
216 |
|
217 | // 立即执行函数外必须包一层小括弧
|
218 | "wrap-iife": [
|
219 | "error",
|
220 | "outside"
|
221 | ],
|
222 |
|
223 | // 禁止使用new产生副作用 (非赋值或条件语句禁止使用new操作符)
|
224 | "no-new": [
|
225 | "warn"
|
226 | ],
|
227 |
|
228 | // 强制构造函数首字母大写
|
229 | "new-cap": [
|
230 | "error",
|
231 | { "capIsNew": false }
|
232 | ],
|
233 |
|
234 | // 禁止省略调用无参构造函数的圆括号
|
235 | "new-parens": [
|
236 | "error"
|
237 | ],
|
238 |
|
239 | // 禁止函数中有重复参数
|
240 | "no-dupe-args": [
|
241 | "error"
|
242 | ],
|
243 |
|
244 | // 禁止函数重复声明
|
245 | "no-func-assign": [
|
246 | "error"
|
247 | ],
|
248 |
|
249 | // 禁止 return,throw,continue 或 break 语句之后的不可达语句
|
250 | "no-unreachable": [
|
251 | "error"
|
252 | ],
|
253 |
|
254 | /* 语法 -- 对象 */
|
255 |
|
256 | // 创建对象字面量时,禁止重复的键
|
257 | "no-dupe-keys": [
|
258 | "error"
|
259 | ],
|
260 |
|
261 | /* 语法 -- 空值 */
|
262 |
|
263 | // 禁止直接与NaN比较
|
264 | "use-isnan": [
|
265 | "error"
|
266 | ],
|
267 |
|
268 | /* 语法 -- 循环 */
|
269 |
|
270 | // 禁止在循环中声明函数
|
271 | "no-loop-func": [
|
272 | "error"
|
273 | ],
|
274 |
|
275 | /* 语法 -- 分支 */
|
276 |
|
277 | // 禁止重复的case标签
|
278 | "no-duplicate-case": [
|
279 | "error"
|
280 | ],
|
281 |
|
282 | // 禁止在条件中使用常量表达式
|
283 | "no-constant-condition": [
|
284 | "error"
|
285 | ],
|
286 |
|
287 | // 禁止in操作符的否定的左操作数
|
288 | "no-negated-in-lhs": [
|
289 | "error"
|
290 | ],
|
291 |
|
292 | // 要求 Switch 语句中有 Default 分支
|
293 | "default-case": [
|
294 | "error"
|
295 | ],
|
296 |
|
297 | // 禁用未使用过的标签
|
298 | "no-unused-labels": [
|
299 | "warn"
|
300 | ],
|
301 |
|
302 | /* 语法 -- 正则 */
|
303 |
|
304 | // 禁止在正则表达式中使用空字符集
|
305 | "no-empty-character-class": [
|
306 | "error"
|
307 | ],
|
308 |
|
309 | // 禁止在正则表达式中使用控制字符
|
310 | "no-control-regex": [
|
311 | "error"
|
312 | ],
|
313 |
|
314 | /* 语法 -- 异常 */
|
315 |
|
316 | // 禁止对 catch 块的异常进行赋值
|
317 | "no-ex-assign": [
|
318 | "error"
|
319 | ],
|
320 |
|
321 | /* 语法 -- 其他 */
|
322 |
|
323 | // 禁止使用稀疏数组
|
324 | "no-sparse-arrays": [
|
325 | "error"
|
326 | ],
|
327 |
|
328 | // 禁止重复引入同一模块
|
329 | "no-duplicate-imports": [
|
330 | "error"
|
331 | ],
|
332 |
|
333 | // 禁止出现空白代码块 (除非空代码块中包含注释)
|
334 | "no-empty": [
|
335 | "error"
|
336 | ],
|
337 |
|
338 | //禁用with
|
339 | "no-with": [
|
340 | "error"
|
341 | ],
|
342 |
|
343 | // 禁止在应该比较的地方赋值(比如if的小括弧内)
|
344 | "no-cond-assign": [
|
345 | "error",
|
346 | "except-parens"
|
347 | ],
|
348 |
|
349 | // 禁止全局对象(Math 和 JSON)当作函数使用
|
350 | "no-obj-calls": [
|
351 | "error"
|
352 | ],
|
353 |
|
354 | // 禁止代码看起来像两个表达式但实际上是一个
|
355 | "no-unexpected-multiline": [
|
356 | "error"
|
357 | ],
|
358 |
|
359 | // 确保 typeof 结果与一个有效的字符串相比较
|
360 | "valid-typeof": [
|
361 | "error"
|
362 | ],
|
363 |
|
364 | // 禁用八进制字面量
|
365 | "no-octal": [
|
366 | "error"
|
367 | ],
|
368 |
|
369 | /* React */
|
370 |
|
371 | // 禁止通过 displayName 来命名组件
|
372 | "react/display-name": [
|
373 | "error"
|
374 | ],
|
375 |
|
376 | // 使用 ES6 类声明代替 React.createClass
|
377 | "react/prefer-es6-class": [
|
378 | "error",
|
379 | "always"
|
380 | ],
|
381 |
|
382 | // 组件引用采用帕斯卡命名法,其实例采用驼峰式命名法
|
383 | "react/jsx-pascal-case": [
|
384 | "error", {
|
385 | allowAllCaps: true,
|
386 | ignore: [],
|
387 | }
|
388 | ],
|
389 |
|
390 | // 结束标签与开始标签对齐 [AUTO]
|
391 | "react/jsx-closing-bracket-location": [
|
392 | "warn"
|
393 | ],
|
394 |
|
395 | // 强制'{'后和'}'前有空格 [AUTO]
|
396 | "react/jsx-curly-spacing": [
|
397 | "warn",
|
398 | "never",
|
399 | { allowMultiline: true }
|
400 | ],
|
401 |
|
402 | // jsx中禁止出现重复属性
|
403 | "react/jsx-no-duplicate-props": [
|
404 | "error",
|
405 | { ignoreCase: false }
|
406 | ],
|
407 |
|
408 | // jsx中禁止使用未声明的变量
|
409 | "react/jsx-no-undef": [
|
410 | "error"
|
411 | ],
|
412 |
|
413 | // 禁止在同一个文件下出现重复的组件
|
414 | "react/no-multi-comp": [
|
415 | "error",
|
416 | { ignoreStateless: true }
|
417 | ],
|
418 |
|
419 | // 禁止使用未知的DOM属性 [AUTO]
|
420 | "react/no-unknown-property": [
|
421 | "error"
|
422 | ],
|
423 |
|
424 | // 强制 render() 方法中使用return
|
425 | "react/require-render-return": [
|
426 | "error"
|
427 | ],
|
428 |
|
429 | // 强制结束标签前有空格
|
430 | "react/jsx-space-before-closing": [
|
431 | "error",
|
432 | "always"
|
433 | ],
|
434 |
|
435 | // jsx中等号左右要有空格 [AUTO]
|
436 | "react/jsx-equals-spacing": [
|
437 | "error",
|
438 | "never"
|
439 | ]
|
440 | }
|
441 | } |
\ | No newline at end of file |