-
Notifications
You must be signed in to change notification settings - Fork 4
/
.eslintrc.js
166 lines (166 loc) · 4.13 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
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
},
rules: {
/* Dangling commas enforce consistency and make diffs easy on the eye. */
'comma-dangle': [
'error',
'always-multiline',
],
/* Disallows weird comma placement. */
'comma-spacing': [
'error',
{
before: false,
after: true,
},
],
/*
* Curly braces denote new basic blocks. Since control flow statements lead to Turing completeness, keywords like
* `if` statements should be clearly delineated.
*/
curly: [
'error',
'all',
],
/* Files should end with a newline. */
'eol-last': [
'error',
'always',
],
/* If you are using type coercion of any kind with `==`, you're not in control of the code. */
'eqeqeq': [
'error',
'always',
],
/* Four spaces is too extravagant. */
indent: [
'error',
2,
{
/*
* `switch` cases need another level of indentation since they might have their own lexical scope and `switch`
* itself demands curly braces.
*/
SwitchCase: 1,
/* A workaround for `https://github.com/babel/babel-eslint/issues/681`. */
ignoredNodes: ['TemplateLiteral'],
},
],
/* Improves readability of keywords. */
'keyword-spacing': [
'error',
{after: true},
],
/* We work on Unix-like systems. Also, Windows is weird and non-compliant. */
'linebreak-style': [
'error',
'unix',
],
/*
* This is a multiline starred block comment. This is a multiline starred block comment. This is a multiline starred
* block comment. This is a multiline starred block comment. This is a multiline starred block comment. This is a...
*/
'multiline-comment-style': [
'error',
'starred-block',
],
/* Helps the user identify stray `console.log`s. */
'no-console': [
'error',
{allow: ['warn', 'error']},
],
/* Disallows too many empty lines. */
'no-multiple-empty-lines': [
'error',
{
max: 2,
maxBOF: 0,
maxEOF: 0,
},
],
/* Disallows trailing spaces outside of comments. */
'no-trailing-spaces': [
'error',
{ignoreComments: true},
],
/* Disallows unused variables. */
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
/*
* Disallows spaces inside of curly braces for consistency.
*/
'object-curly-spacing': [
'error',
'never',
],
/* Use of multiline declarations in curly braces should have consistent spacing. */
'object-curly-newline': [
'error',
{consistent: true},
],
/*
* Single and double quotes are equivalent in JavaScript, except using single quotes frees us up to not escape
* double-quoted HTML attribute values in strings. See
* `https://www.reddit.com/r/javascript/comments/4m715v/should_i_use_or/d3tpk1o`.
*/
'quotes': [
'error',
'single',
],
/* Semicolons terminate statements, and they should do just that. */
semi: [
'error',
'always',
],
/* Semicolons should appear at the end of statements. */
'semi-style': [
'error',
'last',
],
/* Control flow statements used to delineate new basic blocks should be treated care: See the `curly` rule. */
'space-before-blocks': [
'error',
'always',
],
/*
* Parentheses should be separated from keywords in the case of `function () {}` and `async () => {}` for
* readability.
*/
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
},
],
/*
* Disallows spaces inside of parentheses for consistency.
*/
'space-in-parens': [
'error',
'never',
],
},
};