-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
116 lines (91 loc) · 4.42 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
module.exports = {
root: true,
extends: 'airbnb-base',
plugins: ['jest'],
env: {
es2021: true,
node: true,
jest: true,
},
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
settings: {
'import/resolver': {
'babel-plugin-root-import': {},
// node: {
// extensions: ['.mjs', '.js', '.json'],
// },
},
},
rules: {
// ES Modules in NodeJS require file extensions
'import/extensions': 'off',
// Allow debugger and console during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Simple function bodies can sometimes still be complex enough to benefit of the extra readability provided by a simple newline
'arrow-body-style': 'off',
// Unnecessary brackets are only a nuisance for the reader; single-argument parens are more elegant without them
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: true,
}],
// I use 4-space indents; `switch` `case`s without indent look really weird
indent: ['error', 4, {
SwitchCase: 1,
}],
// Allows single-line class property definitions to be grouped
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
// Sometimes it makes sense to group subclasses or specialty classes together with their base class or user class respectively
'max-classes-per-file': 'off',
// Line length limits are unproductive
'max-len': 'off',
// As ESLint themselves already note, there are plenty of cases where iterations are not independent, in which case `await` should be allowed
'no-await-in-loop': 'off',
// Even AirBnB themselves allow this, just use with caution
'no-bitwise': 'off',
// There are plenty of cases where break conditions can't be neatly fit inside the loop condition itself, and must be added within the loop body instead
'no-constant-condition': 'off',
// Another rule not specified by AirBnB themselves; continues are useful to prevent excessive tabbing and separate logic
'no-continue': 'off',
// In some cases it can be more logical to use an else return, allow both styles
'no-else-return': 'off',
// For multi-level if/else statements, sometimes it makes more sense keeping the nest levels separate like that
'no-lonely-if': 'off',
// This seems like a stupid rule to enable; it disables simple anonymous functions and arrow functions, even when only used as callback
'no-loop-func': 'off',
// Operator precedence is a thing for a reason; unnecessary brackets are only a nuisance for the reader
'no-mixed-operators': 'off',
// Empty lines can at times be used to better separate different parts of code
'no-multiple-empty-lines': ['error', {
max: 2,
maxBOF: 0,
maxEOF: 0,
}],
// This rule sounds good in theory, but there are too many exceptions where reassignment is wanted/needed, and the whitelist doesn't suffice
'no-param-reassign': 'off',
// When using Babel to leverage the latest ES features, for .. of is no exception
'no-restricted-syntax': 'off',
// There are too many cases that should be allowed, which the options don't properly cover
'no-underscore-dangle': 'off',
// Allow all unused function arguments; at times these can help clarity when other means are lacking
'no-unused-vars': ['error', {
vars: 'all',
args: 'none',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
}],
// Increase the number of properties allowed in a single line object definition
'object-curly-newline': ['error', {
minProperties: 6,
multiline: true,
consistent: true,
}],
// This just leads to inconsistencies about where the index/property is selected
'prefer-destructuring': 'off',
// In some cases, regular string concatenation still looks and feels superior, too bad there are no options to fine-tune this rule
'prefer-template': 'off',
},
};