-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc
183 lines (178 loc) · 7.13 KB
/
.eslintrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
---
# Eslint configure #############################################################
################################################################################
# http://eslint.org/docs/user-guide/configuring
# YAML javascript 语法: http://nodeca.github.io/js-yaml/
ecmaFeatures:
globals:
Router: true
dom: true
store: true
ajax: true
spinner: true
toast: true
popup: true
route: true
routes: true
config: true
views: true
env:
browser: true
node: true
es6: true
jsx: true
commonjs: true
# http://eslint.org/docs/rules/
# ESLint comes with a large number of rules. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values:
# 0 - turn the rule off
# 1 - turn the rule on as a warning (doesn't affect exit code)
# 2 - turn the rule on as an error (exit code is 1 when triggered)
rules:
# block-scoped-var: 2 # var只在块语句中使用,不使用外部块定义的变量
consistent-return: 2 # 代码块返回一致性
default-case: 2 # switch需要default
no-constant-condition: 0 # 禁止在条件中使用常量表达式 if(true) if(1)
dot-notation: 2 # 避免不必要的方括号,使用.
eqeqeq: # 尽可能使用`===`
- 2
- "smart"
guard-for-in: 2 # for in循环要用if语句过滤
no-alert: 2 # 禁止使用alert confirm prompt
no-caller: 2 # 禁止使用arguments.caller或arguments.callee
no-div-regex: 2 # 不能使用看起来像除法的正则表达式/=foo/
no-else-return: 2 # 如果if语句里面有return,后面不能跟else语句
no-empty-label: 2 # 禁止使用空label
# no-empty-pattern: 2 # 禁止使用空解构模式
no-eq-null: 2 # 禁止对null使用==或!=运算符
no-eval: 2 # 禁止使用eval
no-extend-native: 2 # 不允许扩展原生类型
no-extra-bind: 2 # 禁止不必要的函数绑定
no-fallthrough: 2 # 禁止switch穿透(不停止的switch)
no-floating-decimal: 2 # 禁止省略浮点数中的0 .5 3.
no-implicit-coercion: # 禁止隐式转换
- 2
-
boolean: true
number: false
string: false
no-implied-eval: 2 # 禁止使用隐式eval
# no-invalid-this: 2 # 禁止无效的this,只能用在构造器,类,对象字面量
no-iterator: 2 # 禁止使用__iterator__ 属性
no-labels: 2 # 禁止标签声明
no-lone-blocks: 2 # 禁止不必要的嵌套块
no-loop-func: 2 # 禁止在循环中使用函数(如果没有引用外部变量不形成闭包就可以)
no-multi-str: 2 # 字符串不能用\换行
no-native-reassign: 2 # 不能重写native对象
no-new-wrappers: 2 # 禁止使用new创建包装实例,new String new Boolean new Number
no-new: 2 # 禁止在使用new构造一个实例后不赋值
no-octal-escape: 2 # 禁止使用八进制转义序列
no-octal: 2 # 禁止使用八进制数字
no-process-env: 2 # 禁止使用process.env
no-proto: 2 # 禁止使用__proto__属性
no-redeclare: 2 # 禁止重复声明变量
no-return-assign: 2 # return 语句中不能有赋值表达式
no-script-url: 2 # 禁止使用void(0)
no-self-compare: 2 # 不能比较自身
no-sequences: 2 # 禁止使用逗号运算符
no-throw-literal: 2 # 禁止抛出字面量错误 throw "error";
no-console: 0 # 在uglify 进行压缩代码的时候删除了所有console.log函数,所以此处放开便于开发的时候查看状态
no-unused-expressions: # 禁止无用的表达式
- 2
-
allowShortCircuit: true
allowTernary: true
no-useless-call: 2 # 禁止不必要的call和apply
no-useless-concat: 2 # 禁止文字或文字模板不必要的关联
no-void: 2 # 禁用void操作符
no-warning-comments: # 不能有警告备注
- 2
-
terms:
- "todo"
- "fixme"
location: "start"
no-with: 2 # 禁用with
radix: 2 # parseInt必须指定第二个参数
# vars-on-top: 2 # var必须放在作用域顶部
wrap-iife: # 立即执行函数表达式的小括号风格
- 2
- "outside"
no-catch-shadow: 2 # 禁止catch子句参数与外部作用域变量同名
no-delete-var: 2 # 不能对var声明的变量使用delete操作符
no-label-var: 2 # label名不能与var声明的变量名相同
no-shadow-restricted-names: 2 # 严格模式中规定的限制标识符不能作为声明时的变量名使用
no-shadow: 2 # 外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
no-undef-init: 2 # 变量初始化时不能直接给它赋值为undefined
no-undef: 2 # 禁止使用未声明的变量,除非global赋值过
# no-undefined: 1 # 不能使用undefined
no-unused-vars: 1 # 不能有声明后未被使用的变量或参数
no-use-before-define: 0 # 未定义前不能使用
no-new-require: 2 # 禁止使用new require
no-path-concat: 2 # node中不能使用__dirname或__filename做路径拼接
no-process-exit: 2 # 禁止使用process.exit()
block-spacing: 2 # 禁止或强制单行内空格
brace-style: # 大括号风格
- 2
- "stroustrup"
- allowSingleLine: true
camelcase: 2 # 强制驼峰法命名
comma-spacing: # 逗号前后的空格
- 2
-
before: false
after: true
comma-style: # 逗号风格,换行时在行首还是行尾
- 2
- "last"
consistent-this: # this别名
- 2
- "me"
eol-last: 2 #文件以单一的换行符结束
# func-names: 2 # 函数表达式必须有名字
indent: # 缩进风格
- 2
- 2
# key-spacing: # 对象字面量中冒号的前后空格
# - 2
# -
# beforeColon: false
# afterColon: true
# align: "colon"
new-cap: 2 # 函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用
new-parens: 2 # new时必须加小括号
newline-after-var: # 变量声明后是否需要空一行
- 1
- "always"
no-array-constructor: 2 # 禁止使用数组构造器
no-mixed-spaces-and-tabs: 2 # 禁止混用tab和空格
no-multiple-empty-lines: # 空行最多不能超过2行
- 1
- max: 2
no-new-object: 2 # 禁止使用new Object()
no-spaced-func: 1 # 函数调用时 函数名与()之间不能有空格
no-trailing-spaces: 2 # 一行结束后面不要有空格
no-underscore-dangle: 0 # 标识符不能以_开头或结尾
no-unneeded-ternary: 2 # 禁止不必要的嵌套
one-var: # 连续声明
- 2
- "always"
operator-assignment: # 赋值运算符 += -=什么的
- 2
- "always"
quotes: # 引号类型 `` "" ''
- 2
- "single"
# require-jsdoc: 2 # function需要参数注释
space-after-keywords: 2 # 关键字后面是否要空一格
space-before-blocks: 2 # 不以新行开始的块{前面要不要有空格
space-before-function-paren: 2 # 函数定义时括号前面要不要有空格
space-before-keywords: 2 # 特定关键词前要有空格
# space-infix-ops: 2 # 操作符周围要有空格
space-return-throw-case: 2 # return throw case后面要不要加空格
space-unary-ops: 1 # 一元运算符的前/后要不要加空格
spaced-comment: 1 # 注释风格要不要有空格什么的
max-len: # 字符串最大长度
- 1
- 90
- 2
extends: "eslint:recommended" # 扩展