1
1
module . exports = {
2
2
parser : 'babel-eslint' ,
3
- plugins : [ 'prettier' , 'markdown' , 'html' ] ,
3
+ plugins : [ 'prettier' , 'markdown' , 'html' , 'fp' ] ,
4
4
extends : [
5
5
'eslint:recommended' ,
6
6
'standard' ,
7
7
'prettier' ,
8
8
'prettier/standard' ,
9
9
'plugin:eslint-comments/recommended' ,
10
10
'plugin:unicorn/recommended' ,
11
+ 'plugin:node/recommended' ,
11
12
'plugin:ava/recommended' ,
12
13
'plugin:react/recommended' ,
13
14
'prettier/react' ,
14
15
'plugin:you-dont-need-lodash-underscore/all' ,
16
+ // TODO: enable
17
+ // 'plugin:fp/recommended',
15
18
] ,
16
19
reportUnusedDisableDirectives : true ,
17
20
rules : {
18
21
// Those ESLint rules are not enabled by Prettier, ESLint recommended rules
19
22
// nor standard JavaScript. However, they are still useful
20
23
'array-callback-return' : [ 2 , { allowImplicit : true , checkForEach : true } ] ,
21
24
'block-scoped-var' : 2 ,
25
+ 'class-methods-use-this' : 2 ,
26
+ complexity : [ 2 , 5 ] ,
22
27
'consistent-this' : 2 ,
23
28
'default-case' : 2 ,
24
29
'default-case-last' : 2 ,
@@ -29,13 +34,20 @@ module.exports = {
29
34
'id-length' : [ 2 , { exceptions : [ 't' , '_' ] } ] ,
30
35
'line-comment-position' : 2 ,
31
36
'max-classes-per-file' : 2 ,
37
+ 'max-depth' : [ 2 , 2 ] ,
38
+ 'max-lines' : [ 2 , { max : 150 , skipBlankLines : true , skipComments : true } ] ,
39
+ 'max-lines-per-function' : [ 2 , { max : 100 , skipBlankLines : true , skipComments : true , IIFEs : true } ] ,
40
+ 'max-nested-callbacks' : [ 2 , 2 ] ,
32
41
'max-params' : [ 2 , { max : 4 } ] ,
42
+ 'max-statements' : [ 2 , 15 ] ,
43
+ 'max-statements-per-line' : [ 2 , { max : 2 } ] ,
33
44
'multiline-comment-style' : [ 2 , 'separate-lines' ] ,
34
45
'no-await-in-loop' : 2 ,
35
46
'no-bitwise' : 2 ,
36
47
'no-constructor-return' : 2 ,
37
48
'no-duplicate-imports' : 2 ,
38
49
'no-else-return' : [ 2 , { allowElseIf : false } ] ,
50
+ 'no-empty' : [ 2 , { allowEmptyCatch : true } ] ,
39
51
'no-extra-label' : 2 ,
40
52
'no-implicit-coercion' : 2 ,
41
53
'no-implicit-globals' : [ 2 , { lexicalBindings : true } ] ,
@@ -78,6 +90,26 @@ module.exports = {
78
90
'no-multi-assign' : 2 ,
79
91
'no-negated-condition' : 2 ,
80
92
'no-nested-ternary' : 2 ,
93
+ 'no-param-reassign' : [
94
+ 2 ,
95
+ {
96
+ props : true ,
97
+ ignorePropertyModificationsFor : [
98
+ 'error' ,
99
+ 'errorA' ,
100
+ 'req' ,
101
+ 'request' ,
102
+ 'res' ,
103
+ 'response' ,
104
+ 'state' ,
105
+ 'runState' ,
106
+ 'logs' ,
107
+ 'logsArray' ,
108
+ 'currentEnv' ,
109
+ 't' ,
110
+ ] ,
111
+ } ,
112
+ ] ,
81
113
'no-plusplus' : [ 2 , { allowForLoopAfterthoughts : true } ] ,
82
114
'no-promise-executor-return' : 2 ,
83
115
'no-return-await' : 2 ,
@@ -104,6 +136,9 @@ module.exports = {
104
136
radix : [ 2 , 'as-needed' ] ,
105
137
'require-await' : 2 ,
106
138
139
+ // TODO: enable
140
+ // strict: 2,
141
+
107
142
// The autofix makes it impossible to use those in debugging
108
143
'ava/no-only-test' : 0 ,
109
144
'ava/no-skip-test' : 0 ,
@@ -114,6 +149,50 @@ module.exports = {
114
149
{ allow : [ 'eslint-disable-next-line' , 'eslint-disable' , 'eslint-enable' , 'eslint-env' ] } ,
115
150
] ,
116
151
152
+ // Those rules are too strict
153
+ 'fp/no-rest-parameters' : 0 ,
154
+ 'fp/no-unused-expression' : 0 ,
155
+ 'fp/no-nil' : 0 ,
156
+ 'fp/no-throw' : 0 ,
157
+ // Avoid state mutation except for some known state variables
158
+ 'fp/no-mutating-methods' : [
159
+ 2 ,
160
+ {
161
+ allowedObjects : [
162
+ 'error' ,
163
+ 'errorA' ,
164
+ 'req' ,
165
+ 'request' ,
166
+ 'res' ,
167
+ 'response' ,
168
+ 'state' ,
169
+ 'runState' ,
170
+ 'logs' ,
171
+ 'logsArray' ,
172
+ 'currentEnv' ,
173
+ 't' ,
174
+ ] ,
175
+ } ,
176
+ ] ,
177
+ 'fp/no-mutation' : [
178
+ 2 ,
179
+ {
180
+ commonjs : true ,
181
+ exceptions : [
182
+ { object : 'error' } ,
183
+ { object : 'errorA' } ,
184
+ { object : 'res' } ,
185
+ { object : 'state' } ,
186
+ { object : 'runState' } ,
187
+ { object : 'logs' } ,
188
+ { object : 'logsArray' } ,
189
+ { object : 'currentEnv' } ,
190
+ { object : 'process' , property : 'exitCode' } ,
191
+ ] ,
192
+ } ,
193
+ ] ,
194
+
195
+ 'import/max-dependencies' : [ 2 , { max : 20 } ] ,
117
196
'import/order' : [
118
197
2 ,
119
198
{
@@ -125,6 +204,30 @@ module.exports = {
125
204
} ,
126
205
] ,
127
206
207
+ 'node/no-sync' : 2 ,
208
+ 'node/handle-callback-err' : 2 ,
209
+ 'node/no-new-require' : 2 ,
210
+ 'node/callback-return' : 2 ,
211
+ 'node/exports-style' : 2 ,
212
+ 'node/file-extension-in-import' : 2 ,
213
+ 'node/global-require' : 2 ,
214
+ 'node/no-mixed-requires' : 2 ,
215
+ // Browser globals should not use `require()`. Non-browser globals should
216
+ 'node/prefer-global/console' : 2 ,
217
+ 'node/prefer-global/buffer' : [ 2 , 'never' ] ,
218
+ 'node/prefer-global/process' : [ 2 , 'never' ] ,
219
+ // TODO: enable after dropping support for Node <10.0.0
220
+ 'node/prefer-global/url-search-params' : 0 ,
221
+ 'node/prefer-global/url' : 0 ,
222
+ // TODO: enable after dropping support for Node <11.0.0
223
+ 'node/prefer-global/text-decoder' : 0 ,
224
+ 'node/prefer-global/text-encoder' : 0 ,
225
+ // TODO: enable after dropping support for Node <11.4.0
226
+ 'node/prefer-promises/fs' : 0 ,
227
+ 'node/prefer-promises/dns' : 0 ,
228
+ // This does not work well in a monorepo
229
+ 'node/shebang' : 0 ,
230
+
128
231
'react/prop-types' : 0 ,
129
232
130
233
// Not enabled by default in unicorn/recommended, but still pretty useful
@@ -171,6 +274,7 @@ module.exports = {
171
274
{
172
275
files : [ '.*.js' ] ,
173
276
rules : {
277
+ 'max-lines' : 0 ,
174
278
'no-magic-numbers' : 0 ,
175
279
'node/no-unpublished-require' : 0 ,
176
280
} ,
0 commit comments