Skip to content

Commit dd7f829

Browse files
committed
Add more rules
1 parent b80cb6e commit dd7f829

File tree

1 file changed

+105
-1
lines changed

1 file changed

+105
-1
lines changed

.eslintrc.js

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
module.exports = {
22
parser: 'babel-eslint',
3-
plugins: ['prettier', 'markdown', 'html'],
3+
plugins: ['prettier', 'markdown', 'html', 'fp'],
44
extends: [
55
'eslint:recommended',
66
'standard',
77
'prettier',
88
'prettier/standard',
99
'plugin:eslint-comments/recommended',
1010
'plugin:unicorn/recommended',
11+
'plugin:node/recommended',
1112
'plugin:ava/recommended',
1213
'plugin:react/recommended',
1314
'prettier/react',
1415
'plugin:you-dont-need-lodash-underscore/all',
16+
// TODO: enable
17+
// 'plugin:fp/recommended',
1518
],
1619
reportUnusedDisableDirectives: true,
1720
rules: {
1821
// Those ESLint rules are not enabled by Prettier, ESLint recommended rules
1922
// nor standard JavaScript. However, they are still useful
2023
'array-callback-return': [2, { allowImplicit: true, checkForEach: true }],
2124
'block-scoped-var': 2,
25+
'class-methods-use-this': 2,
26+
complexity: [2, 5],
2227
'consistent-this': 2,
2328
'default-case': 2,
2429
'default-case-last': 2,
@@ -29,13 +34,20 @@ module.exports = {
2934
'id-length': [2, { exceptions: ['t', '_'] }],
3035
'line-comment-position': 2,
3136
'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],
3241
'max-params': [2, { max: 4 }],
42+
'max-statements': [2, 15],
43+
'max-statements-per-line': [2, { max: 2 }],
3344
'multiline-comment-style': [2, 'separate-lines'],
3445
'no-await-in-loop': 2,
3546
'no-bitwise': 2,
3647
'no-constructor-return': 2,
3748
'no-duplicate-imports': 2,
3849
'no-else-return': [2, { allowElseIf: false }],
50+
'no-empty': [2, { allowEmptyCatch: true }],
3951
'no-extra-label': 2,
4052
'no-implicit-coercion': 2,
4153
'no-implicit-globals': [2, { lexicalBindings: true }],
@@ -78,6 +90,26 @@ module.exports = {
7890
'no-multi-assign': 2,
7991
'no-negated-condition': 2,
8092
'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+
],
81113
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
82114
'no-promise-executor-return': 2,
83115
'no-return-await': 2,
@@ -104,6 +136,9 @@ module.exports = {
104136
radix: [2, 'as-needed'],
105137
'require-await': 2,
106138

139+
// TODO: enable
140+
// strict: 2,
141+
107142
// The autofix makes it impossible to use those in debugging
108143
'ava/no-only-test': 0,
109144
'ava/no-skip-test': 0,
@@ -114,6 +149,50 @@ module.exports = {
114149
{ allow: ['eslint-disable-next-line', 'eslint-disable', 'eslint-enable', 'eslint-env'] },
115150
],
116151

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 }],
117196
'import/order': [
118197
2,
119198
{
@@ -125,6 +204,30 @@ module.exports = {
125204
},
126205
],
127206

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+
128231
'react/prop-types': 0,
129232

130233
// Not enabled by default in unicorn/recommended, but still pretty useful
@@ -171,6 +274,7 @@ module.exports = {
171274
{
172275
files: ['.*.js'],
173276
rules: {
277+
'max-lines': 0,
174278
'no-magic-numbers': 0,
175279
'node/no-unpublished-require': 0,
176280
},

0 commit comments

Comments
 (0)