1
1
'use strict' ;
2
2
3
+ const {
4
+ es5Paths,
5
+ esNextPaths,
6
+ } = require ( './scripts/shared/pathsByLanguageVersion' ) ;
7
+
3
8
const OFF = 0 ;
4
9
const ERROR = 2 ;
5
10
@@ -16,6 +21,15 @@ module.exports = {
16
21
'react-internal' ,
17
22
] ,
18
23
24
+ parser : 'espree' ,
25
+ parserOptions : {
26
+ ecmaVersion : 2017 ,
27
+ sourceType : 'script' ,
28
+ ecmaFeatures : {
29
+ experimentalObjectRestSpread : true ,
30
+ } ,
31
+ } ,
32
+
19
33
// We're stricter than the default config, mostly. We'll override a few rules
20
34
// and then enable some React specific ones.
21
35
rules : {
@@ -44,6 +58,13 @@ module.exports = {
44
58
'space-before-function-paren' : OFF ,
45
59
'valid-typeof' : [ ERROR , { requireStringLiterals : true } ] ,
46
60
61
+ // We apply these settings to files that should run on Node.
62
+ // They can't use JSX or ES6 modules, and must be in strict mode.
63
+ // They can, however, use other ES6 features.
64
+ // (Note these rules are overridden later for source files.)
65
+ 'no-var' : ERROR ,
66
+ strict : ERROR ,
67
+
47
68
// React & JSX
48
69
// Our transforms set this automatically
49
70
'react/jsx-boolean-value' : [ ERROR , 'always' ] ,
@@ -71,6 +92,33 @@ module.exports = {
71
92
} ,
72
93
73
94
overrides : [
95
+ {
96
+ // We apply these settings to files that we ship through npm.
97
+ // They must be ES5.
98
+ files : es5Paths ,
99
+ parser : 'espree' ,
100
+ parserOptions : {
101
+ ecmaVersion : 5 ,
102
+ sourceType : 'script' ,
103
+ } ,
104
+ rules : {
105
+ 'no-var' : OFF ,
106
+ strict : ERROR ,
107
+ } ,
108
+ } ,
109
+ {
110
+ // We apply these settings to the source files that get compiled.
111
+ // They can use all features including JSX (but shouldn't use `var`).
112
+ files : esNextPaths ,
113
+ parser : 'babel-eslint' ,
114
+ parserOptions : {
115
+ sourceType : 'module' ,
116
+ } ,
117
+ rules : {
118
+ 'no-var' : ERROR ,
119
+ strict : OFF ,
120
+ } ,
121
+ } ,
74
122
{
75
123
files : [ '**/__tests__/*.js' ] ,
76
124
rules : {
0 commit comments