-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
267 lines (229 loc) · 6.07 KB
/
index.js
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/**
* Main configuration for ESLint shareable configuration eslint-config-chromatix.
*
* @author Tim Malone <[email protected]>
* @author Julian Chan <[email protected]>
*/
const INDENTATION_SPACES = 2;
module.exports = {
env: {
browser: true,
es6: true,
jest: true,
jquery: true,
node: false
},
parserOptions: {
ecmaVersion: 8,
sourceType: "module",
},
// @see https://www.npmjs.com/package/eslint-plugin-jest
// @see https://github.com/WordPress-Coding-Standards/eslint-config-wordpress/blob/master/index.js
// @see https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress/tree/master/lib
extends: [
'plugin:jest/recommended',
'eslint:recommended',
'plugin:@wordpress/eslint-plugin/recommended'
],
plugins: [ 'jest' ],
// @see https://eslint.org/docs/rules/{NAME-OF-RULE}
rules: {
// Coming soon.
//
//'no-var': [ 'error' ],
//'prefer-const': [ 'error' ],
//
// @see https://yarnpkg.com/en/package/eslint-plugin-dollar-sign
//'dollar-sign/dollar-sign': [2, 'ignoreProperties'],
// Rule categories:
// - Best practices (and quality code).
// - Documentation.
// - Indentation.
// - Handled elsewhere.
// - Node safety.
// - Purely helpful.
// - Security.
// - Stylistic.
// - UX.
// - Variables.
'array-bracket-newline': [ // Stylistic.
'error',
{
minItems: 2
}
],
'array-callback-return': [ 'warn' ], // Purely helpful.
'array-element-newline': [ // Stylistic.
'error',
'always'
],
'callback-return': [ 'error' ], // Node safety.
'capitalized-comments': [ // Documentation.
'warn',
'always',
{
ignoreConsecutiveComments: true
}
],
'complexity': [ // Best practices.
'error',
{
max: 20
}
],
'dot-location': [ // Stylistic.
'error',
'property'
],
'eqeqeq': [ // Best practices.
'error',
'always'
],
'guard-for-in': [ 'error' ], // Best practices.
'handle-callback-err': [ 'error' ], // Node safety.
'id-length': [ // Variables.
'error',
{
max: 30,
min: 2
}
],
// Indentation.
// @see https://eslint.org/docs/rules/indent
'indent': [
'error',
INDENTATION_SPACES,
{
flatTernaryExpressions: true,
SwitchCase: 1,
VariableDeclarator: {
const: 3,
let: 2,
var: 2
}
}
],
'key-spacing': [ // Stylistic.
'warn',
{
'align': {
afterColon: true,
beforeColon: false,
on: 'value'
}
}
],
'linebreak-style': [ 'off' ], // Handled by git.
'lines-around-comment': [ // Documentation.
'warn',
{
beforeBlockComment: true,
beforeLineComment: true
}
],
'max-depth': [ // Best practices.
'error',
{
max: 3
}
],
'max-len': [ // Stylistic.
'error',
{
code: 100,
ignoreUrls: true,
tabWidth: 2
}
],
'max-lines': [ // Stylistic.
'error',
{
max: 800,
skipBlankLines: false,
skipComments: false
}
],
'max-nested-callbacks': [ // Best practices.
'error',
{
max: 3
}
],
'max-params': [ // Best practices.
'error',
{
max: 4
}
],
'max-statements': [ // Best practices.
'error',
{
max: 20
}
],
'max-statements-per-line': [ 'error' ], // Stylistic.
'no-alert': [ 'error' ], // UX.
'no-array-constructor': [ 'error' ], // Stylistic.
'no-buffer-constructor': [ 'error' ], // Node safety.
'no-console': [ 'off' ], // Handled by strip-debug during minify for prod.
'no-empty-function': [ 'error' ], // Stylistic.
'no-eq-null': [ 'error' ], // Best practices.
'no-eval': [ 'error' ], // Security.
'no-implicit-coercion': [ 'error' ], // Best practices.
'no-implied-eval': [ 'error' ], // Security.
'no-lone-blocks': [ 'error' ], // Stylistic.
'no-lonely-if': [ 'error' ], // Stylistic.
'no-loop-func': [ 'error' ], // Best practices.
'no-magic-numbers': 0,
'no-mixed-requires': [ // Node safety.
'error',
{
'allowCall': true
}
],
'no-multi-spaces': [ 'error' ], // Stylistic.
'no-multi-str': [ 'error' ], // Stylistic.
'no-multiple-empty-lines': [ // Stylistic.
'error',
{
max: 1,
maxBOF: 1,
maxEOF: 1
}
],
'no-negated-condition': [ 'error' ], // Stylistic.
'no-new-object': [ 'error' ], // Stylistic.
'no-param-reassign': [ 'error' ], // Best practices.
'no-path-concat': [ 'error' ], // Node safety.
'no-plusplus': [ 'off' ], // Only should be on if not using semicolons
'no-process-env': [ 'error' ], // Node safety.
'no-process-exit': [ 'error' ], // Node safety.
'no-return-assign': [ 'error' ], // Best practices.
'no-self-compare': [ 'error' ], // Best practices.
'no-tabs': [ 'error' ], // Stylistic.
'no-unused-expressions': [ 'error' ], // Best practices.
'no-use-before-define': [ 'error' ], // Variables.
'no-warning-comments': [ 'warn' ], // Documentation.
'object-property-newline': [ 'error' ], // Stylistic.
'require-jsdoc': [ 'warn' ], // Documentation.
'strict': [ // Best practices.
'error',
'safe'
],
'valid-jsdoc': [ 'warn' ], // Documentation.
'comma-dangle': [
'error',
'only-multiline',
],
'no-trailing-spaces': [
'warn',
{
'skipBlankLines': true,
'ignoreComments': true
}
],
'yoda': 0,
'quotes': 0,
'prettier/prettier': 0
} // Rules.
}; // Module.exports