forked from docpad/docpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc
532 lines (375 loc) · 13.2 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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
// 14 September 2015
// https://github.com/bevry/base
// http://eslint.org
{
"parser": "babel-eslint",
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"octalLiterals": true,
"regexUFlag": true,
"regexYFlag": true,
"restParams": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"unicodeCodePointEscapes": true,
"globalReturn": true,
"jsx": true,
"experimentalObjectRestSpread": true
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
// ----------------------------
// Problems with these rules
// If we can figure out how to enable the following, that would be great
// Two spaces after one line if or else:
// if ( blah ) return
// Insead of one space:
// if ( blah ) return
// No spaces on embedded function:
// .forEach(function(key, value){
// instead of:
// .forEach(function (key, value) {
// Else and catch statements on the same line as closing brace:
// } else {
// } catch (e) {
// instead of:
// }
// else {
// --------------------------------------
// Possible Errors
// ES6 supports dangling commas
"comma-dangle": 0,
// Don't allow assignments in conditional statements (if, while, etc.)
"no-cond-assign": [2, "always"],
// Warn but don't error about console statements
"no-console": 1,
// Allow while(true) loops
"no-constant-condition": 0,
// Seems like a good idea to error about this
"no-control-regex": 2,
// Warn but don't error about console statements
"no-debugger": 1,
// Don't allow duplicate arguments in a function, they can cause errors
"no-dupe-args": 2,
// Disallow duplicate keys in an object, they can cause errors
"no-dupe-keys": 2,
// Disallow duplicate case statements in a switch
"no-duplicate-case": 2,
// Allow empty block statements, they are useful for clarity
"no-empty": 0,
// Disallow empty [] in regular expressions as they cause unexpected behaviour
"no-empty-character-class": 2,
// Overwriting the exception argument in a catch statement can cause memory leaks in some browsers
"no-ex-assign": 2,
// Disallow superflous boolean casts, they offer no value
"no-extra-boolean-cast": 2,
// Allow superflous parenthesis as they offer clarity in some cases
"no-extra-parens": 0,
// Disallow superflous semicolons, they offer no value
"no-extra-semi": 0,
// Seems like a good idea to error about this
"no-func-assign": 2,
// Seems like a good idea to error about this
"no-inner-declarations": 2,
// Seems like a good idea to error about this
"no-invalid-regexp": 2,
// Seems like a good idea to error about this
"no-irregular-whitespace": 2,
// Seems like a good idea to error about this
"no-negated-in-lhs": 2,
// Seems like a good idea to error about this
"no-obj-calls": 2,
// Seems like a good idea to error about this
// Instead of / / used / {2}/ instead
"no-regex-spaces": 2,
// Seems like a good idea to error about this
// "no-reserved-keys": 2,
"quote-props": ["consistent-as-needed", 2],
// Seems like a good idea to error about this
"no-sparse-arrays": 2,
// Seems like a good idea to error about this
"no-unreachable": 2,
// Seems like a good idea to error about this
"use-isnan": 2,
// We use YUIdoc, not JSDoc
"valid-jsdoc": 0,
// Seems like a good idea to error about this
"valid-typeof": 2,
// --------------------------------------
// Best Practices
// This rule seems buggy
"block-scoped-var": 0,
// Disable complexity checks, they are annoying and not that useful in detecting actual complexity
"complexity": 0,
// We use blank returns for break statements
"consistent-return": 0,
// Always require curly braces unless the statement is all on a single line
"curly": [2, "multi-line"],
// If we don't have a default cause, it probably means we should throw an error
"default-case": 2,
// Use dot notation where possible
"dot-notation": 2,
// Unless you are doing == null, then force === to avoid truthy/falsey mistakes
"eqeqeq": [2, "allow-null"],
// Always use hasOwnProperty when doing for in
"guard-for-in": 2,
// Warn about alert statements in our code
// Use one of the suggested alternatives instead
// Reasoning is they could be mistaken for left over debugging statements
"no-alert": 1,
// They are very slow
"no-caller": 2,
// Seems like a good idea to error about this
"no-div-regex": 2,
// Returns in else statements offer code clarity, so disable this rule
"no-else-return": 0,
// Seems like a good idea to error about this
"no-empty-label": 2,
// We know that == null is a null and undefined check
"no-eq-null": 0,
// Eval is slow and unsafe, use vm's instead
"no-eval": 2,
// There is never a good reason for this
"no-extend-native": 2,
// Don't allow useless binds
"no-extra-bind": 2,
// Don't allow switch case statements to follow through, use continue keyword instead
"no-fallthrough": 2,
// Use zero when doing decimals, otherwise it is confusing
"no-floating-decimal": 2,
// A sneaky way to do evals
"no-implied-eval": 2,
// Use proper iterators instead
"no-iterator": 2,
// We never use this, it seems silly to allow this
"no-labels": 2,
// We never use this, it seems silly to allow this
"no-lone-blocks": 2,
// Loop functions always cause problems, as the scope isn't clear through iterations
"no-loop-func": 2,
// We like multi spaces for clarity
// E.g. We like
// if ( blah ) return foo
// Instead of:
// if ( blah ) return foo
// @TODO would be great to enforce the above
"no-multi-spaces": 0,
// Use ES6 template strings instead
"no-multi-str": 2,
// Would be silly to allow this
"no-native-reassign": 2,
// We never use this, it seems silly to allow this
"no-new": 2,
// We never use this, it seems silly to allow this
"no-new-func": 2,
// We never use this, it seems silly to allow this
"no-new-wrappers": 2,
// We never use this, it seems silly to allow this
"no-octal": 2,
// We never use this, it seems silly to allow this
"no-octal-escape": 2,
// We use process.env wisely
"no-process-env": 0,
// We never use this, it seems silly to allow this
"no-proto": 2,
// We never use this, it seems silly to allow this
"no-redeclare": 2,
// We never use this, it seems silly to allow this
"no-return-assign": 2,
// We never use this, it seems silly to allow this
"no-script-url": 2,
// We never use this, it seems silly to allow this
"no-self-compare": 2,
// We never use this, it seems silly to allow this
"no-sequences": 2,
// We always want proper error objects as they have stack traces and respond to instanceof Error checks
"no-throw-literal": 2,
// We never use this, it seems silly to allow this
"no-unused-expressions": 2,
// We never use this, it seems silly to allow this
"no-void": 2,
// Warn about todos
"no-warning-comments": [1, { "terms": ["todo", "fixme"], "location": "anywhere" }],
// We never use this, it seems silly to allow this
// "no-with": true,
// Always specify a radix to avoid errors
"radix": 2,
// We appreciate the clarity late defines offer
"vars-on-top": 0,
// Wrap instant called functions in parenthesis for clearer intent
"wrap-iife": 2,
// Because we force === and never allow assignments in conditions
// we have no need for yoda statements, so disable them
"yoda": [2, "never"],
// --------------------------------------
// Strict Mode
// Force strict mode in the global scope as we want it everywhere
"strict": 0,
// Off because when using ES6 in modules, "use strict" is necessary, but eslint complains about it
// --------------------------------------
// Variables
// Don't allow the catch method to shadow objects as browsers handle this differently
// Update: We don't care for IE8
// "no-catch-shadow": 2,
// Don't use delete, it disables optimisations
"no-delete-var": 2,
// We never use this, it seems silly to allow this
"no-label-var": 2,
// We use shadowing
"no-shadow": 0,
// We never use this, it seems silly to allow this
"no-shadow-restricted-names": 2,
// Error when an undefined variable is used
"no-undef": 2,
// Makes sense
"no-undef-init": 2,
// typeof blah === 'undefined' should always be used
"no-undefined": 2,
// Warn us when we don't use something
"no-unused-vars": 1,
// Error when we try and use something before it is defined
"no-use-before-define": 2,
// --------------------------------------
// Node.js
// Force handling of callback errors
"handle-callback-err": 2,
// @TODO decide if this is good or not
"no-mixed-requires": 2,
// Disallow error prone syntax
"no-new-require": 2,
// Always use path.join for windows support
"no-path-concat": 2,
// We know what we are doing
"no-process-exit": 0,
// No need for this rule
"no-restricted-modules": 0,
// Sometimes sync methods are useful, so warn but don't error
"no-sync": 1,
// --------------------------------------
// ES6
// @TODO This probably should be an error
// however it is useful for: for ( var key in obj ) {
// which hopefully is more performant than let (@TODO check if it actually is more performant)
"no-var": 1,
// Seems the most consistent location for it
"generator-star-spacing": [2, "before"],
// --------------------------------------
// Stylistic
// Use tabs and indent case blocks
"indent": [2, "tab", {"SwitchCase": 1}],
// Opening brace on same line, closing brace on its own line, except when statement is a single line
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
// Use camel case
"camelcase": 2,
// Require a comma after always
"comma-spacing": [2, {"before": false, "after": true}],
// Commas go last, we have tooling to detect if we forget a comma
"comma-style": [2, "last"],
// When aliasing this, call it "me"
"consistent-this": [2, "me"],
// Enable to make UNIX people's lives easier
"eol-last": 2,
// We like anonymous functions
"func-names": 0,
// Prefer to define functions via variables
"func-style": [1, "declaration"],
// Space after the colon
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
// We are smart enough to know if this is bad or not
"max-nested-callbacks": 0,
// Constructors should be CamelCase
"new-cap": 2,
// Always use parens when instantiating a class
"new-parens": 2,
// Don't use the array constructor when it is not needed
"no-array-constructor": 2,
// We like inline comments
"no-inline-comments": 0,
// The code could be optimised if this error occurs
"no-lonely-if": 2,
// Don't mix spaces and tabs
// @TODO maybe [2, "smart-tabs"] will be better, we will see
"no-mixed-spaces-and-tabs": 2,
// We use multiple empty lines for styling
"no-multiple-empty-lines": 0,
// Nested ternaries are too complicated, use if statement instead
"no-nested-ternary": 2,
// Use {} instead of new Object()
"no-new-object": 2,
// We never use this, it seems silly to allow this
// "no-space-before-semi": 2,
"semi-spacing": [2, {"before": false, "after": true}],
// We never use this, it seems silly to allow this
"no-spaced-func": 2,
// Sometimes ternaries are useful
// @TODO revise
"no-ternary": 0,
// Disallow trailing spaces
"no-trailing-spaces": 2,
// Sometimes this is useful when avoiding shadowing
"no-underscore-dangle": 0,
// Unless it is needed such as IIFE rule then warn as sometimes it can be useful for clarity
// "no-wrap-func": 2,
"no-extra-parens": 1,
// We like multiple var statements
"one-var": 0,
// This rule doesn't appear to work correclty
"padded-blocks": 0,
// Force use of shorthands when available
"operator-assignment": [2, "always"],
// Quote object property keys only when needed
"quote-props": [2, "as-needed"],
// Use single quotes where escaping isn't needed
"quotes": [2, "single", "avoid-escape"],
// Never use semicolons
"semi": [2, "never"],
// If semi's are used, then add spacing after
"semi-spacing": [2, {"before": false, "after": true}],
// We don't care if our vars are alphabetical
"sort-vars": 0,
// Always force a space after a keyword
"space-after-keywords": [2, "always"],
// Always force a space before a {
"space-before-blocks": [2, "always"],
// function () {, get blah () {
// "space-before-function-parentheses": [2, "always"],
"space-before-function-paren": [2, "always"],
// This is for spacing between [], so [ 1, 2, 3 ] which we don't want
"space-in-brackets": 0,
// This is for spacing between (), so doSomething( 1, 2, 3 ) or if ( 1 === 3 )
// which we want for ifs, but don't want for calls
"space-in-parens": 0,
// We use this
"space-infix-ops": 2,
// We use this
"space-return-throw-case": 2,
// We use this
"space-unary-ops": 2,
// We use this
// "spaced-line-comment": 2,
"spaced-comment": 2,
// We use this
// @TODO revise this
"wrap-regex": 2
}
}