-
Notifications
You must be signed in to change notification settings - Fork 7
/
.eslintrc.js
168 lines (138 loc) · 3.75 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
module.exports = {
'root': true ,
'env': {
'browser': true ,
'node': true ,
'es6': true ,
'es2022': true
} ,
'parserOptions': {
'ecmaVersion': 2022
} ,
'extends': [ 'eslint:recommended' ] ,
'ignorePatterns': [ "*.min.js" ] ,
'rules': {
/*
Bad code -- detect anything that can be broken or lead to bugs
*/
'strict': [ 'error' , 'global' ] ,
'unicode-bom': [ 'error' , 'never' ] ,
'radix': 'error' ,
'eqeqeq': 'error' ,
'consistent-return': 'off' ,
'valid-typeof': 'error' ,
'no-unneeded-ternary': 'error' ,
'no-unused-vars': 'warn' , // During development phase, it's boring to clean unused var since they can be used later
'no-lonely-if': 'off' , // Can hurt semantic programming
'no-nested-ternary': 'off' , // Now I use the streamlined ternary operator a lot
'no-shadow': 'error' ,
'no-shadow-restricted-names': 'error' ,
'require-atomic-updates': 'off' , // check for possible race condition on assignment, interesting but too nitpicky
/*
Code preferences
*/
'prefer-arrow-callback': 'error' ,
'prefer-spread': 'warn' ,
'prefer-rest-params': 'warn' ,
'no-control-regex': 'off' , // because thing like \x00 are considered like a control even if escaped...
'no-fallthrough': 'off' ,
'no-empty': [ 'error' , {
'allowEmptyCatch': true
} ] ,
/*
Coding styles -- cosmetic rules and opinionated preferences
*/
// Indent & spaces (general)
'indent': [ 'error' , 'tab' , {
'SwitchCase': 1 ,
'MemberExpression': 1 ,
'flatTernaryExpressions': true
} ] ,
'newline-per-chained-call': 'off',
'no-multi-spaces': 'off' ,
'block-spacing': 'error' ,
'comma-spacing': [ 'error' , {
'before': true ,
'after': true
} ] ,
'no-whitespace-before-property': 'error' ,
'space-before-blocks': 'error' ,
'space-before-function-paren': [ 'error' , {
'anonymous': 'never',
'named': 'never',
'asyncArrow': 'always'
} ] ,
'space-infix-ops': 'error' ,
'space-unary-ops': [ 'error' , {
'words': true ,
'nonwords': true ,
'overrides': {
//'-': false ,
}
} ] ,
'space-in-parens': [ 'error' , 'always' , {
'exceptions': [ 'empty' ]
} ] ,
'no-trailing-spaces': 'error' ,
'switch-colon-spacing': [ 'error' , {
'after': true ,
'before': true
} ] ,
'arrow-spacing': 'error' ,
'rest-spread-spacing': [ 'error' , 'always' ] ,
/* Troublesome with commented line of code
'spaced-comment': [ 'error' , 'always' , {
'line': {
'markers': [ '/' ],
'exceptions': [ '-', '*', '/' ]
} ,
'block': {
'exceptions': [ '*' ] ,
'balanced': true
}
} ] ,
*/
// Semi-colon
'semi': [ 'error' , 'always' ] ,
'semi-style': [ 'error' , 'last' ] ,
'semi-spacing': [ 'error' , {
'before': true ,
'after': true
} ] ,
// Objects
'key-spacing': [ 'error' , {
'beforeColon': false ,
'afterColon': true ,
'mode': 'strict'
} ] ,
'object-curly-newline': [ 'error' , {
'ObjectExpression' : {
'consistent': true ,
'minProperties': 4
} ,
'ObjectPattern' : {
// object destructuring assigment
'consistent': true ,
'minProperties': 8
}
} ] ,
'object-curly-spacing': [ 'error' , 'always' ] ,
'object-property-newline': [ 'error' , { 'allowMultiplePropertiesPerLine': true } ] ,
// Arrays
'array-bracket-newline': [ 'error' , 'consistent' ] ,
//'array-element-newline': [ 'error' , { 'multiline': true , 'minItems': 5 } ] ,
'array-bracket-spacing': [ 'error' , 'always' ],
'brace-style': [ 'error' , 'stroustrup' , {
'allowSingleLine': true
} ] ,
// Misc style
'no-else-return': 'warn' ,
'comma-dangle': [ 'error' , 'never' ] ,
'quotes': 'off' ,
'camelcase': 'warn' ,
/*
Method limitation
*/
'no-console': 'off'
}
} ;