Skip to content

Commit bb2e328

Browse files
committed
Add more rules
1 parent f0c197b commit bb2e328

File tree

4 files changed

+373
-90
lines changed

4 files changed

+373
-90
lines changed

.eslintrc.js

Lines changed: 110 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,132 @@
11
/* eslint-disable max-lines */
22
module.exports = {
3-
plugins: ['prettier', 'fp', 'markdown', 'html'],
3+
parser: 'babel-eslint',
4+
plugins: ['prettier', 'markdown', 'html'],
45
extends: [
56
'eslint:recommended',
67
'standard',
78
'prettier',
89
'prettier/standard',
9-
'plugin:unicorn/recommended',
1010
'plugin:eslint-comments/recommended',
11-
'plugin:node/recommended',
12-
'plugin:fp/recommended',
11+
'plugin:unicorn/recommended',
1312
'plugin:ava/recommended',
13+
'plugin:react/recommended',
14+
'prettier/react',
1415
'plugin:you-dont-need-lodash-underscore/all',
1516
],
1617
reportUnusedDisableDirectives: true,
1718
rules: {
18-
'no-console': 0,
19-
'no-unused-vars': [2, {}],
20-
'no-empty': [2, { allowEmptyCatch: true }],
21-
'import/order': [
19+
// Those ESLint rules are not enabled by Prettier, ESLint recommended rules
20+
// nor standard JavaScript. However, they are still useful
21+
'array-callback-return': [2, { allowImplicit: true, checkForEach: true }],
22+
'block-scoped-var': 2,
23+
'consistent-this': 2,
24+
'default-case': 2,
25+
'default-case-last': 2,
26+
'default-param-last': 2,
27+
'func-name-matching': [2, { considerPropertyDescriptor: true }],
28+
'func-names': [2, 'as-needed'],
29+
'func-style': 2,
30+
'id-length': [2, { exceptions: ['t', '_'] }],
31+
'line-comment-position': 2,
32+
'max-classes-per-file': 2,
33+
'max-params': [2, { max: 4 }],
34+
'multiline-comment-style': [2, 'separate-lines'],
35+
'no-await-in-loop': 2,
36+
'no-bitwise': 2,
37+
'no-constructor-return': 2,
38+
'no-duplicate-imports': 2,
39+
'no-else-return': [2, { allowElseIf: false }],
40+
'no-extra-label': 2,
41+
'no-implicit-coercion': 2,
42+
'no-implicit-globals': [2, { lexicalBindings: true }],
43+
'no-inline-comments': 2,
44+
'no-invalid-this': 2,
45+
'no-label-var': 2,
46+
'no-lonely-if': 2,
47+
'no-loop-func': 2,
48+
'no-loss-of-precision': 2,
49+
'no-magic-numbers': [
2250
2,
2351
{
24-
'newlines-between': 'always',
25-
alphabetize: {
26-
order: 'asc',
27-
caseInsensitive: true,
28-
},
52+
ignore: [
53+
// Common small numbers
54+
-2,
55+
-1,
56+
0,
57+
1,
58+
2,
59+
3,
60+
// HTTP statuses
61+
200,
62+
201,
63+
204,
64+
300,
65+
301,
66+
400,
67+
401,
68+
403,
69+
404,
70+
410,
71+
422,
72+
500,
73+
],
74+
enforceConst: true,
75+
detectObjects: true,
2976
},
3077
],
31-
'no-process-exit': 0,
32-
'require-atomic-updates': 0,
78+
'no-multi-assign': 2,
79+
'no-negated-condition': 2,
80+
'no-nested-ternary': 2,
81+
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
82+
'no-promise-executor-return': 2,
83+
'no-return-await': 2,
84+
'no-shadow': 2,
85+
'no-underscore-dangle': [2, { enforceInMethodNames: true }],
86+
'no-unreachable-loop': 2,
3387
'no-undef': [2, { typeof: true }],
34-
35-
'max-lines': [
36-
2,
37-
{
38-
max: 150,
39-
skipBlankLines: true,
40-
skipComments: true,
41-
},
42-
],
43-
'max-lines-per-function': [
44-
2,
45-
{
46-
max: 100,
47-
skipBlankLines: true,
48-
skipComments: true,
49-
IIFEs: true,
50-
},
51-
],
52-
'max-statements': [2, 15],
53-
'max-statements-per-line': [2, { max: 2 }],
54-
'import/max-dependencies': [2, { max: 20 }],
55-
complexity: [2, 5],
56-
'max-depth': [2, 2],
57-
'max-nested-callbacks': [2, 2],
88+
'no-unused-vars': [2, {}],
89+
'no-useless-backreference': 2,
90+
'no-useless-computed-key': [2, { enforceForClassMembers: true }],
91+
'no-useless-concat': 2,
92+
'no-var': 2,
93+
'object-shorthand': 2,
94+
'operator-assignment': 2,
95+
'padding-line-between-statements': 2,
96+
'prefer-destructuring': 2,
97+
'prefer-exponentiation-operator': 2,
98+
'prefer-numeric-literals': 2,
99+
'prefer-object-spread': 2,
100+
'prefer-regex-literals': [2, { disallowRedundantWrapping: true }],
101+
'prefer-rest-params': 2,
102+
'prefer-spread': 2,
103+
'prefer-template': 2,
104+
radix: [2, 'as-needed'],
58105
'require-await': 2,
59106

60-
'node/no-sync': 2,
61-
'node/handle-callback-err': 2,
62-
'node/no-new-require': 2,
63-
'node/callback-return': 2,
64-
'node/exports-style': 2,
65-
'node/file-extension-in-import': 2,
66-
'node/global-require': 2,
67-
'node/no-mixed-requires': 2,
68-
// Browser globals should not use `require()`. Non-browser globals should
69-
'node/prefer-global/console': 2,
70-
'node/prefer-global/url-search-params': 2,
71-
'node/prefer-global/text-decoder': 2,
72-
'node/prefer-global/text-encoder': 2,
73-
'node/prefer-global/url': 2,
74-
'node/prefer-global/buffer': [2, 'never'],
75-
'node/prefer-global/process': [2, 'never'],
76-
// TODO: enable after dropping support for Node <11.4.0
77-
'node/prefer-promises/fs': 2,
78-
'node/prefer-promises/dns': 2,
79-
// This does not work well in a monorepo
80-
'node/shebang': 0,
107+
// The autofix makes it impossible to use those in debugging
108+
'ava/no-only-test': 0,
109+
'ava/no-skip-test': 0,
81110

82111
'eslint-comments/no-unused-disable': 0,
83112
'eslint-comments/no-use': [
84113
2,
85114
{ allow: ['eslint-disable-next-line', 'eslint-disable', 'eslint-enable', 'eslint-env'] },
86115
],
87116

117+
'import/order': [
118+
2,
119+
{
120+
'newlines-between': 'always',
121+
alphabetize: {
122+
order: 'asc',
123+
caseInsensitive: true,
124+
},
125+
},
126+
],
127+
128+
'react/prop-types': 0,
129+
88130
// Not enabled by default in unicorn/recommended, but still pretty useful
89131
'unicorn/custom-error-definition': 2,
90132
'unicorn/no-unused-properties': 2,
@@ -112,34 +154,6 @@ module.exports = {
112154
// TODO: enable after dropping Node 8 support
113155
'unicorn/prefer-optional-catch-binding': 0,
114156
'unicorn/prefer-trim-start-end': 0,
115-
116-
'fp/no-rest-parameters': 0,
117-
'fp/no-unused-expression': 0,
118-
'fp/no-nil': 0,
119-
'fp/no-throw': 0,
120-
'fp/no-mutating-methods': [
121-
2,
122-
{ allowedObjects: ['error', 'errorA', 'res', 'state', 'runState', 'logs', 'logsArray', 'currentEnv'] },
123-
],
124-
'fp/no-mutation': [
125-
2,
126-
{
127-
commonjs: true,
128-
exceptions: [
129-
{ object: 'error' },
130-
{ object: 'errorA' },
131-
{ object: 'res' },
132-
{ object: 'state' },
133-
{ object: 'runState' },
134-
{ object: 'logs' },
135-
{ object: 'logsArray' },
136-
{ object: 'currentEnv' },
137-
{ object: 'process', property: 'exitCode' },
138-
],
139-
},
140-
],
141-
142-
'ava/no-skip-test': 0,
143157
},
144158
overrides: [
145159
{
@@ -165,9 +179,17 @@ module.exports = {
165179
rules: {
166180
'no-undef': 0,
167181
'no-unused-vars': 0,
182+
// Inline comments making code samples vertically shorter are useful
183+
'line-comment-position': 0,
184+
'no-inline-comments': 0,
168185
'node/no-missing-require': 0,
169186
},
170187
},
171188
],
189+
settings: {
190+
react: {
191+
version: '16.13.1',
192+
},
193+
},
172194
}
173195
/* eslint-enable max-lines */

0 commit comments

Comments
 (0)