-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.js
513 lines (500 loc) · 17.2 KB
/
.eslintrc.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
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
module.exports = {
"env": {
"amd": true,
"browser": true,
"commonjs": true,
"es6": true,
"jasmine": true,
"jest/globals": true,
"jquery": true,
"mocha": true,
"mongo": true,
"node": true,
"protractor": true,
"serviceworker": true,
"shared-node-browser": true,
"worker": true,
},
"extends": [
"airbnb", // See <https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb>
],
"globals": {
"beforeEach": true,
"describe": true,
"expect": true,
"it": true,
"jasmine": true,
"React": true,
"xdescribe": true,
"xit": true,
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"allowImportExportEverywhere": false,
"classes": true,
"experimentalObjectRestSpread": true,
"globalReturn": false,
"impliedStrict": true,
"jsx": true,
},
"sourceType": "module",
},
"plugins": [
"import",
"jest",
"jsx-a11y",
"react",
"react-native",
],
"rules": {
/* BEST PRACTICES */
"consistent-return": 0,
"eqeqeq": [2, "smart"], // CORRECT: `typepof foo == 'undefined'`
"func-names": 0,
"global-require": 0,
"no-bitwise": [0, {
"int32Hint": true,
}],
"no-class-assign": 2,
"no-extra-boolean-cast": 0, // CORRECT: `!!value !== 0`
"no-func-assign": 2,
"no-this-before-super": 2,
"no-undef": [2, {
"typeof": true,
}],
"no-unneeded-ternary": [1, {
"defaultAssignment": true,
}],
"no-unused-expressions": [1, {
"allowShortCircuit": true,
"allowTernary": true,
"allowTaggedTemplates": true,
}],
"no-unused-vars": [1, {
"args": "none",
"argsIgnorePattern": "^date|fpInstance",
"caughtErrors": "none",
"ignoreRestSiblings": true,
"vars": "local",
"varsIgnorePattern": "^due|[rR]eact", // Allows `import React from 'react';`
}],
"no-useless-computed-key": 2,
"no-useless-concat": 2,
"no-useless-constructor": 2,
"no-useless-rename": [2, {
"ignoreImport": true,
"ignoreExport": true,
"ignoreDestructuring": true,
}],
"no-useless-return": 0,
"no-var": 2,
"prefer-arrow-callback": [2, {
"allowNamedFunctions": false,
"allowUnboundThis": false,
}],
"prefer-const": [2, {
"destructuring": "any",
"ignoreReadBeforeAssign": false,
}],
"prefer-destructuring": [2, {
"VariableDeclarator": {
"array": false,
"object": true,
},
"AssignmentExpression": {
"array": true,
"object": false,
},
}, {
"enforceForRenamedProperties": false,
}],
"prefer-rest-params": 2,
"prefer-spread": 2,
"prefer-template": 2,
"require-yield": 2,
"rest-spread-spacing": 2,
"semi": [2, "always", {
"omitLastInOneLineBlock": false,
}],
"space-infix-ops": [2, {
"int32Hint": true, // CORRECT: `const foo = bar|0;`
}],
"strict": [2, "global"], // Default "safe" string option maps to "global" because the
// config specifies both the 'node' & 'commonjs' environments.
"symbol-description": 1,
/* POSSIBLE ERRORS */
"valid-jsdoc": 2,
/* STYLISTIC RULES */
"arrow-parens": [2, "always", {
"requireForBlockBody": false, // CORRECT: `(x) => x + 1`, `(x, y) => x + y`
}],
"comma-dangle": [2, {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
}],
"eol-last": [2, "always"],
"indent": [2, 2, {
"ignoredNodes": ["ConditionalExpression"],
"SwitchCase": 1,
}],
"jsx-quotes": [2, "prefer-double"],
"max-len": [2, {
"code": 120,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreTrailingComments": true,
"ignoreUrls": true,
"tabWidth": 2,
}],
"newline-per-chained-call": 0,
"no-confusing-arrow": 0,
"no-console": [1, {
"allow": [
"clear", // Enables `console.clear()`
"error", // Enables `console.error()`
"info", // Enables `console.info()`
"table", // Enables `console.table()`
"time", // Enables `console.time()`
"timeEnd", // Enables `console.timeEnd()`
"warn", // Enables `console.warn()`
],
}],
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
// "no-extra-parens": [2, "all", {
// "conditionalAssign": true,
// "enforceForArrowConditionals": true,
// "ignoreJSX": "all",
// "nestedBinaryExpressions": true,
// "returnAssign": true,
// }],
"no-extra-semi": 2,
"no-fallthrough": [2, {
"commentPattern": "Break[\\s\\w]*omitted",
}],
"no-mixed-operators": [2, {
"allowSamePrecedence": true,
"groups": [
["+", "-", "*", "/", "%", "**"], // Arithmetic operators
["&", "|", "^", "~", "<<", ">>", ">>>"], // Bitwise operators
["==", "!=", "===", "!==", ">", ">=", "<", "<="], // Comparison operators
["&&", "||"], // Logical operators
["in", "instanceof"], // Relational operators
],
}],
"no-multi-assign": 0,
"no-multi-spaces": [2, {
"ignoreEOLComments": true,
}],
"no-trailing-spaces": [2, {
"skipBlankLines": false,
}],
"no-nested-ternary": 0,
"no-param-reassign": [1, {
"props": true,
"ignorePropertyModificationsFor": [
"acc", "curr", // Enabled for use with Array#reduce method calls
"channel", // Allows parameter reassignment in Reselect selector
"context", "ctx", // Allows setting of the appropriate `this` context
"e", "evt", "event", // Allows working with event objects
"fpInstance", // Allows internal modification of FlatPickr instance(s)
"monitor", // Allow mutation of React-DnD monitor(s)
"node", // Allow modifications to `node` objects in GraphQL
"registration", // Enabled for registration of Service Worker(s)
"result", // Enabled for `countriesByGeos.js`
],
}],
"no-plusplus": [2, {
"allowForLoopAfterthoughts": true,
}],
"no-prototype-builtins": 0,
"no-restricted-syntax": [0,
"ForInStatement", // Allow object looping
"ForOfStatement", // Allow loops of ES6 iterables
"UnaryExpression", // Allow unary operations, e.g., `++i`
"YieldExpression", // Allow ES6 generators/iterators
],
"no-return-assign": 0,
"no-script-url": 0,
"no-sparse-arrays": 0,
"no-underscore-dangle": [2, {
"allow": [
"_cryptoUuid",
"_formatIntBlock",
"_onResize",
"_randFallbackKeyGenerator",
],
"allowAfterThis": true, // CORRECT: this._privateMethodName()
}],
"no-use-before-define": [0, "nofunc"], // This may be bugged currently. Refer to:
// <https://github.com/babel/babel-eslint/issues/249>
"object-curly-spacing": 0,
"object-shorthand": [2, "always", {
"avoidExplicitReturnArrows": true,
"avoidQuotes": false,
"ignoreConstructors": false,
}],
"one-var": [0, {
"const": "never", // As many `const` declarations per function as there are `const` assignments
"let": "never", // As many `let` declarations per block as there are `let` assignemtns
"var": "always", // Exactly one `var` declaration per function
}],
"one-var-declaration-per-line": [2, "initializations"],
"quotes": [2, "single", {
"allowTemplateLiterals": true,
"avoidEscape": true,
}],
"semi-spacing": [2, {
"before": false,
"after": true,
}],
// "sort-imports": [2, {
// "ignoreCase": true,
// "ignoreMemberSort": false,
// "memberSyntaxSortOrder": [
// "single",
// "multiple",
// "all",
// "none",
// ],
// }],
"sort-keys": [2, "asc", {
"caseSensitive": true,
"natural": true,
}],
"sort-vars": [2, {
"ignoreCase": false,
}],
"space-before-function-paren": [2, {
"anonymous": "never", // CORRECT: function() {}
"named": "never", // CORRECT: function foo() {}
"asyncArrow": "always", // CORRECT: async () => {}
}],
"template-curly-spacing": [2, "never"],
"wrap-iife": [2, "inside", { // CORRECT: `const x = (function () { return { y: 1 };})();`
"functionPrototypeMethods": true, // CORRECT: `const x = (function(){ foo(); }).call(bar)`
}],
"wrap-regex": 2,
"yield-star-spacing": [2, {
"before": false,
"after": true,
}],
/* IMPORT RULES */
"import/default": 2,
"import/export": 2,
"import/extensions": [2, "never", {
"json": "always",
"sass": "always",
"scss": "always",
"svg": "always",
}],
"import/first": 2,
"import/max-dependencies": [1, {
"max": 35,
}],
"import/named": 2,
"import/namespace": [2, {
"allowComputed": true, // CORRECT: `import * as foo from './foo';`
}], // `console.log(foo['bar']);`
"import/newline-after-import": [2, {
"count": 1,
}],
"import/no-absolute-path": 2, // INCORRECT: `import foo from '/foo';`
"import/no-amd": 2,
"import/no-anonymous-default-export": [2, {
"allowArray": false, // INCORRECT: `export default ['foo', 'bar'];`
"allowArrowFunction": true, // CORRECT: `export default () => { console.log('Hello World!'); };`
"allowAnonymousClass": false, // INCORRECT: `export default class { /* class internals */ };`
"allowAnonymousFunction": true, // CORRECT: `export default function() { /* function internals */ };`
"allowLiteral": false, // INCORRECT: `export default 42;`
"allowObject": true, // CORRECT: `export default { name: 'Oliver' };`
}],
"import/no-commonjs": [0, "allow-primitive-modules"],
"import/no-deprecated": 1,
"import/no-duplicates": 2,
"import/no-dynamic-require": 1,
"import/no-extraneous-dependencies": [2, {
"devDependencies": [ // Specify allowable deps by glob patterns
"**/*.js", // General *.js-extension files
"**/*.jsx", // React-specific *.jsx-extension files
"**/*.test.js", // Test suite *.test.js-extension files
"**/*.spec.js", // Test suite *.spec.js-extension files
"prop-types", // Allow import of the `prop-types` DevDependency
// "mongodb", // Allow import of the `mongodb` DevDependency
],
"optionalDependencies": true,
"peerDependencies": true,
// "packageDir": "./", // Specifies path to the folder against whose package.json file the above are referenced
}],
"import/no-internal-modules": [2, {
"allow": [
"**/actions/*", // Whitelist Redux 'actions' directory
"**/assets/**", // Whitelist stylesheet & image asset imports
"**/db/**", // Whitelist internal database resources
"**/server/**", // Whitelist 'server' directory resources
"**/src/**/*", // Whitelist primary app dir
"lodash/**", // Enable `lodash` module accession: `import map from 'lodash/map';`
"material-ui/**", // Enable `material-ui` module accession: `import FontIcon from 'material-ui/FontIcon';`
"uuid/*", // Enable `uuid` module accession: `import uuidv4 from 'uuid/v4';`
],
}],
"import/no-mutable-exports": 2,
"import/no-named-as-default": 2,
"import/no-named-as-default-member": 2,
"import/no-named-default": 1,
"import/no-namespace": 0,
"import/no-nodejs-modules": [2, {
"allow": [
"fs", // Node.js FileSystem Module
"path", // Node.js path Module
],
}],
"import/no-unassigned-import": [2, {
"allow": [
"**/assets/**", // Whitelist stylesheet & image asset imports
],
}],
"import/no-unresolved": [2, {
"amd": false, // INCORRECT: `define(['./foo'], function (foo) { /*...*/ });`
"commonjs": false, // INCORRECT: `const { default: x } = require('./foo');`
// Default Setting: { "es6": true } -> CORRECT: `import { bar } from 'foo';`
"caseSensitive": true,
"ignore": [
'\.((jp|pn|sv)g)$',
'server\.js$',
],
}],
"import/no-webpack-loader-syntax": 2,
"import/prefer-default-export": 2,
/* ACCESSIBILITY RULES */
"jsx-a11y/img-has-alt": 0,
"jsx-a11y/label-has-for": 1,
"jsx-a11y/no-interactive-element-to-noninteractive-role": 0,
"jsx-a11y/no-noninteractive-element-interactions": 0,
/* REACT/JSX RULES */
"react/boolean-prop-naming": [2, {
"propTypeNames": [
"bool",
"mutuallyExclusiveTrueProps",
],
"rule": "^(doe|[hw]a|i)s[A-Z]([\w\d]?)+", // CORRECT: `doesWork`, `hasChildren`, `isEnabled`, `wasCalled`
}],
"react/default-props-match-prop-types": [2, {
"allowRequiredDefaults": true,
}],
"react/display-name": [2, {
"ignoreTranspilerName": true,
}],
"react/forbid-component-props": [1, {
"forbid": [],
}],
"react/forbid-prop-types": [1, {
"forbid": [
"any", // INCORRECT: `someProp: PropTypes.any`
"array", // INCORRECT: `someProp: PropTypes.array`
// CORRECT: `myObject: PropTypes.arrayOf(PropTypes.bool)`
"object", // INCORRECT: `myObject: PropTypes.object`
// CORRECT: `myObject: PropTypes.shape({ /* ... */ })`, `myObject: PropTypes.objectOf(PropTypes.string)`
],
}],
"react/jsx-closing-bracket-location": [2, {
nonEmpty: 'tag-aligned',
selfClosing: 'tag-aligned',
}],
"react/jsx-filename-extension": 0,
"react/jsx-sort-props": [2, {
"callbacksLast": true,
"ignoreCase": true,
"noSortAlphabetically": false,
"reservedFirst": [
"children",
"dangerouslySetInnerHTML",
"key",
"ref",
// "__self", => NOTE: `__self={this}`
// "__source",
],
"shorthandFirst": true,
"shorthandLast": false,
}],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-array-index-key": 2, // INCORRECT: `list.map((item, index) => <ListItem key={index} />)`
"react/no-children-prop": 0, // INCORRECT: `<MyComponent children={['Child1', 'Child2']} />`
"react/no-danger": 2, // INCORRECT: `<div dangerouslySetInnerHTML={{ __html: "Hello World" }}></div>`
"react/no-deprecated": 1, // INCORRECT: `import { PropTypes } from 'react';`
// CORRECT: `import PropTypes from 'prop-types';`
"react/no-did-mount-set-state": 2,
"react/no-direct-mutation-state": 2,
"react/no-find-dom-node": 0, // Required for Drag-n-Drop implementation
"react/no-unused-prop-types": 0,
"react/prefer-stateless-function": 0,
"react/prop-types": 1,
"react/react-in-jsx-scope": 2,
"react/require-default-props": 1,
"react/sort-comp": 1,
/* REACT NATIVE PLUGIN */
"react-native/no-color-literals": 1, // CORRECT: `<MyComponent style={{ color: theme.colors.ltGrey }} />`
"react-native/no-inline-styles": 0, // CORRECT: `<MyComponent style={{ font: this.props.font, width: '100vw' }} />`
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 2, // CORRECT: 'App.ios.js', 'App.android.js'
},
"settings": {
"import/cache": {
"lifetime": 5,
},
"import/external-module-folders": [
"node_modules",
],
"import/ignore": [
"\.coffee$", // CoffeeScript -> Without polyglot parse, fraught with errors
"\.(s?c|le|sa)ss$", // CSS/Less/Sass/SCSS -> Disallow unprocessed CSS module parsing
"bower_components", // Disallow parsing of modules imported via Bower
"node_modules", // Included by default, but replaced if explicitly configured
"server\.jsx?$", // Exclude the root-level app server file
],
"import/resolver": {
"webpack": {
"config": {
"resolve": {
"modules": [
"./src",
"./node_modules",
],
"extensions": [
".coffee",
".js",
".json",
".jsx",
],
"alias": {
"@": "./src",
"@app": "./src",
},
},
},
},
},
"react": {
"createClass": "createReactClass", // Default Regex expression for Component Factory
"pragma": "React", // Default pragma
"version": "15.4.1", // Defaults to latest stable React release
},
"propWrapperFunctions": [
"forbidExtraProps",
], // Names of any wrappers around the `PropTypes` object
},
};
/**
* NOTES:
* • "off" <=> 0 // Disable linting rule
* • "warn" <=> 1 // Turn the rule on as a warning (doesn’t affect exit code)
* • "error" <=> 2 // Throw error on occurrence (affects exit code)
*/