@@ -38,8 +38,13 @@ const ERROR = 2;
38
38
// import type {Bar, Foo} from 'Foo';
39
39
// Also supports 'let' and 'const'.
40
40
const variableNamePattern = String . raw `\s*[a-zA-Z_$][a-zA-Z_$\d]*\s*` ;
41
- const maxLenIgnorePattern = String . raw `^(?:var|let|const|import type)\s+` +
42
- '{?' + variableNamePattern + '(?:,' + variableNamePattern + ')*}?' +
41
+ const maxLenIgnorePattern =
42
+ String . raw `^(?:var|let|const|import type)\s+` +
43
+ '{?' +
44
+ variableNamePattern +
45
+ '(?:,' +
46
+ variableNamePattern +
47
+ ')*}?' +
43
48
String . raw `\s*(?:=\s*require\(|from)[a-zA-Z_+./"'\s\d\-]+\)?[^;\n]*[;\n]` ;
44
49
45
50
function getBaseConfig ( ) {
@@ -49,14 +54,7 @@ function getBaseConfig() {
49
54
ecmaVersion : 6 ,
50
55
sourceType : 'module' ,
51
56
} ,
52
- extends :[
53
- "plugin:flowtype/recommended"
54
- ]
55
- plugins : [
56
- 'babel' ,
57
- 'flowtype' ,
58
- 'react' ,
59
- ] ,
57
+ plugins : [ 'flowtype' , 'react' ] ,
60
58
61
59
// Tries to match the jshint configuration as closely as possible, with the
62
60
// exeception of a few things that jshint doesn't check, but that we really
@@ -129,23 +127,23 @@ function getBaseConfig() {
129
127
// Best Practices <http://eslint.org/docs/rules/#best-practices>
130
128
131
129
// probably a bug, we shouldn't actually even use this yet, because of IE8
132
- 'accessor-pairs' : [ WARNING , { setWithoutGet : true } ] ,
130
+ 'accessor-pairs' : [ WARNING , { setWithoutGet : true } ] ,
133
131
// probably too noisy ATM
134
132
'block-scoped-var' : OFF ,
135
133
// cyclomatic complexity, we're too far gone
136
- ' complexity' : OFF ,
134
+ complexity : OFF ,
137
135
// require return statements to either always or never specify values
138
136
'consistent-return' : WARNING ,
139
137
// style guide: Always use brackets, even when optional.
140
- ' curly' : [ WARNING , 'all' ] ,
138
+ curly : [ WARNING , 'all' ] ,
141
139
// we don't do this/care about this
142
140
'default-case' : OFF ,
143
141
// disabled in favor of our temporary fork
144
142
'dot-notation' : OFF ,
145
143
// we don't do this/care about this, but probably should eventually
146
144
'dot-location' : OFF ,
147
145
// disabled as it's too noisy ATM
148
- ' eqeqeq' : [ OFF , 'allow-null' ] ,
146
+ eqeqeq : [ OFF , 'allow-null' ] ,
149
147
// we don't do this/care about this, equivalent to jshint forin
150
148
'guard-for-in' : OFF ,
151
149
// we have too many internal examples/tools using this
@@ -183,7 +181,7 @@ function getBaseConfig() {
183
181
// Should be effectively equivalent to jshint W028 - allowing the use
184
182
// of labels in very specific situations. ESLint no-empty-labels was
185
183
// deprecated.
186
- 'no-labels' : [ ERROR , { allowLoop : true , allowSwitch : true } ] ,
184
+ 'no-labels' : [ ERROR , { allowLoop : true , allowSwitch : true } ] ,
187
185
// lone blocks create no scope, will ignore blocks with let/const
188
186
'no-lone-blocks' : WARNING ,
189
187
// equivalent to jshint loopfunc
@@ -195,7 +193,7 @@ function getBaseConfig() {
195
193
// equivalent to jshint multistr, consider using es6 template strings
196
194
'no-multi-str' : ERROR ,
197
195
// equivalent to jshint W02OFF, similar to no-extend-native
198
- 'no-native-reassign' : [ ERROR , { exceptions : [ 'Map' , 'Set' ] } ] ,
196
+ 'no-native-reassign' : [ ERROR , { exceptions : [ 'Map' , 'Set' ] } ] ,
199
197
// equivalent to jshint evil/W054
200
198
'no-new-func' : ERROR ,
201
199
// don't use constructors for side-effects, equivalent to jshint nonew
@@ -237,17 +235,17 @@ function getBaseConfig() {
237
235
// equivalent to jshint withstmt
238
236
'no-with' : OFF ,
239
237
// require radix argument in parseInt, we do this in most places already
240
- ' radix' : WARNING ,
238
+ radix : WARNING ,
241
239
// we don't do this/care about this
242
240
'vars-on-top' : OFF ,
243
241
// equivalent to jshint immed
244
242
'wrap-iife' : OFF ,
245
243
// probably too noisy ATM
246
- ' yoda' : OFF ,
244
+ yoda : OFF ,
247
245
248
246
// Strict Mode <http://eslint.org/docs/rules/#strict-mode>
249
247
// jshint wasn't checking this, and the compiler should add this anyways
250
- ' strict' : OFF ,
248
+ strict : OFF ,
251
249
252
250
// Variables <http://eslint.org/docs/rules/#variables>
253
251
// we don't do this/care about this
@@ -269,7 +267,7 @@ function getBaseConfig() {
269
267
// using undefined is safe because we enforce no-shadow-restricted-names
270
268
'no-undefined' : OFF ,
271
269
// equivalent to jshint unused
272
- 'no-unused-vars' : [ WARNING , { args : 'none' } ] ,
270
+ 'no-unused-vars' : [ WARNING , { args : 'none' } ] ,
273
271
// too noisy
274
272
'no-use-before-define' : OFF ,
275
273
@@ -290,10 +288,10 @@ function getBaseConfig() {
290
288
'array-bracket-spacing' : WARNING ,
291
289
// TODO: enable this with consensus on single line blocks
292
290
'block-spacing' : OFF ,
293
- 'brace-style' : [ WARNING , '1tbs' , { allowSingleLine : true } ] ,
291
+ 'brace-style' : [ WARNING , '1tbs' , { allowSingleLine : true } ] ,
294
292
// too noisy at the moment, and jshint didn't check it
295
- ' camelcase' : [ OFF , { properties : 'always' } ] ,
296
- 'comma-spacing' : [ WARNING , { before : false , after : true } ] ,
293
+ camelcase : [ OFF , { properties : 'always' } ] ,
294
+ 'comma-spacing' : [ WARNING , { before : false , after : true } ] ,
297
295
// jshint had laxcomma, but that was against our style guide
298
296
'comma-style' : [ WARNING , 'last' ] ,
299
297
'computed-property-spacing' : [ WARNING , 'never' ] ,
@@ -308,19 +306,17 @@ function getBaseConfig() {
308
306
'id-length' : OFF ,
309
307
'id-match' : OFF ,
310
308
// we weren't enforcing this with jshint, so erroring would be too noisy
311
- ' indent' : [ WARNING , 2 , { SwitchCase : 1 } ] ,
309
+ indent : [ WARNING , 2 , { SwitchCase : 1 } ] ,
312
310
// we use single quotes for JS literals, double quotes for JSX literals
313
311
'jsx-quotes' : [ WARNING , 'prefer-double' ] ,
314
312
// we may use extra spaces for alignment
315
- 'key-spacing' : [ OFF , { beforeColon : false , afterColon : true } ] ,
313
+ 'key-spacing' : [ OFF , { beforeColon : false , afterColon : true } ] ,
316
314
'keyword-spacing' : [ WARNING ] ,
317
315
'lines-around-comment' : OFF ,
318
316
// should be handled by a generic TXT linter instead
319
317
'linebreak-style' : [ OFF , 'unix' ] ,
320
318
'max-depth' : OFF ,
321
- 'max-len' : [ WARNING , 120 , 2 ,
322
- { 'ignorePattern' : maxLenIgnorePattern } ,
323
- ] ,
319
+ 'max-len' : [ WARNING , 120 , 2 , { ignorePattern : maxLenIgnorePattern } ] ,
324
320
'max-nested-callbacks' : OFF ,
325
321
'max-params' : OFF ,
326
322
'max-statements' : OFF ,
@@ -357,43 +353,39 @@ function getBaseConfig() {
357
353
// too noisy ATM
358
354
'object-curly-spacing' : OFF ,
359
355
// makes indentation warnings clearer
360
- 'one-var' : [ WARNING , { initialized : 'never' } ] ,
356
+ 'one-var' : [ WARNING , { initialized : 'never' } ] ,
361
357
// prefer `x += 4` over `x = x + 4`
362
358
'operator-assignment' : [ WARNING , 'always' ] ,
363
359
// equivalent to jshint laxbreak
364
360
'operator-linebreak' : OFF ,
365
361
'padded-blocks' : OFF ,
366
362
// probably too noisy on pre-ES5 code
367
363
'quote-props' : [ OFF , 'as-needed' ] ,
368
- ' quotes' : [ WARNING , 'single' , 'avoid-escape' ] ,
364
+ quotes : [ WARNING , 'single' , 'avoid-escape' ] ,
369
365
'require-jsdoc' : OFF ,
370
- 'semi-spacing' : [ WARNING , { before : false , after : true } ] ,
366
+ 'semi-spacing' : [ WARNING , { before : false , after : true } ] ,
371
367
// equivalent to jshint asi/W032
372
- ' semi' : [ WARNING , 'always' ] ,
368
+ semi : [ WARNING , 'always' ] ,
373
369
'sort-vars' : OFF ,
374
370
// require `if () {` instead of `if (){`
375
371
'space-before-blocks' : [ WARNING , 'always' ] ,
376
372
// require `function foo()` instead of `function foo ()`
377
- 'space-before-function-paren' : [
378
- WARNING ,
379
- { anonymous : 'never' , named : 'never' } ,
380
- ] ,
373
+ 'space-before-function-paren' : [ WARNING , { anonymous : 'never' , named : 'never' } ] ,
381
374
// incompatible with our legacy inline type annotations
382
375
'space-in-parens' : [ OFF , 'never' ] ,
383
- 'space-infix-ops' : [ WARNING , { int32Hint : true } ] ,
384
- 'space-unary-ops' : [ WARNING , { words : true , nonwords : false } ] ,
376
+ 'space-infix-ops' : [ WARNING , { int32Hint : true } ] ,
377
+ 'space-unary-ops' : [ WARNING , { words : true , nonwords : false } ] ,
385
378
// TODO: Figure out a way to do this that doesn't break typechecks
386
379
// or wait for https://github.com/eslint/eslint/issues/2897
387
- 'spaced-comment' :
388
- [ OFF , 'always' , { exceptions : [ 'jshint' , 'jslint' , 'eslint' , 'global' ] } ] ,
380
+ 'spaced-comment' : [ OFF , 'always' , { exceptions : [ 'jshint' , 'jslint' , 'eslint' , 'global' ] } ] ,
389
381
'wrap-regex' : OFF ,
390
382
391
383
// ECMAScript 6 <http://eslint.org/docs/rules/#ecmascript-6>
392
384
'arrow-body-style' : OFF ,
393
385
// Forked to fb-www/arrow-parens to fix issues with flow and add fixer
394
386
'arrow-parens' : OFF ,
395
387
// tbgs finds *very few* places where we don't put spaces around =>
396
- 'arrow-spacing' : [ WARNING , { before : true , after : true } ] ,
388
+ 'arrow-spacing' : [ WARNING , { before : true , after : true } ] ,
397
389
// violation of the ES6 spec, won't transform
398
390
'constructor-super' : ERROR ,
399
391
// https://github.com/babel/babel-eslint#known-issues
@@ -416,15 +408,7 @@ function getBaseConfig() {
416
408
// there are legitimate use-cases for an empty generator
417
409
'require-yield' : OFF ,
418
410
419
- // eslint-plugin-babel <https://github.com/babel/eslint-plugin-babel>
420
- 'babel/generator-star-spacing' : OFF ,
421
- 'babel/new-cap' : OFF ,
422
- 'babel/array-bracket-spacing' : OFF ,
423
- 'babel/object-curly-spacing' : OFF ,
424
- 'babel/object-shorthand' : OFF ,
425
- 'babel/arrow-parens' : OFF ,
426
- 'babel/no-await-in-loop' : OFF ,
427
- 'babel/flow-object-type' : [ WARNING , 'comma' ] ,
411
+ 'no-await-in-loop' : OFF ,
428
412
429
413
// eslint-plugin-react <https://github.com/yannickcr/eslint-plugin-react>
430
414
// TODO: We're being extremely conservative here as we roll out eslint on
@@ -485,12 +469,14 @@ function getBaseConfig() {
485
469
// annotations.
486
470
'flowtype/define-flow-type' : WARNING ,
487
471
'flowtype/use-flow-type' : WARNING ,
472
+ 'flowtype/object-type-delimiter' : [ WARNING , 'comma' ] ,
488
473
} ,
489
474
490
475
// Defines a basic set of globals
491
476
env : {
492
477
browser : true ,
493
478
es6 : true ,
479
+ node : true
494
480
} ,
495
481
496
482
// The jshint code had more globals, which may have had something to do with
@@ -499,9 +485,7 @@ function getBaseConfig() {
499
485
// Values of true mean the global may be modified. Values of false represent
500
486
// constants.
501
487
globals : {
502
- __DEV__ : true ,
503
- module : false ,
504
- require : false
488
+ __DEV__ : true
505
489
} ,
506
490
} ;
507
491
}
@@ -522,7 +506,7 @@ var extendedConfig = {
522
506
} ,
523
507
} ;
524
508
525
- Object . keys ( extendedConfig ) . forEach ( ( key ) => {
509
+ Object . keys ( extendedConfig ) . forEach ( key => {
526
510
config [ key ] = Object . assign ( config [ key ] , extendedConfig [ key ] ) ;
527
511
} ) ;
528
512
0 commit comments