-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
174 lines (138 loc) · 5.26 KB
/
index.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
169
170
171
172
173
174
module.exports = {
"extends": [
"eslint:recommended",
"airbnb-base/rules/best-practices",
"airbnb-base/rules/errors",
"airbnb-base/rules/node",
"airbnb-base/rules/style",
"airbnb-base/rules/variables",
"airbnb-base/rules/es6",
],
parserOptions: {
ecmaVersion: 2020,
},
"env": {
"es6": true,
"node": true,
"mocha": true
},
"plugins": [
"mocha"
],
"rules": {
// Do not require yield, goes against Koa v1 style.
"require-yield": "off",
// Single quotes instead of double quotes
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
// Allow leading underscores for "private" methods
"no-underscore-dangle": "off",
// Don't require source files to include "use strict"
// as babel enforces that automatically
"strict": ["error", "never"],
// Destructuring siblings are okay
"no-unused-vars": ["error", { "ignoreRestSiblings": true }],
// {bar: baz} bad; { bar: baz } good
"object-curly-spacing": ["error", "always"],
// Place spaces after keywords
"keyword-spacing": "error",
// Unreachable code is an error
"no-unreachable": "error",
// blocks must at least have a comment, except `catch(e) { }`
"no-empty": ["error", { "allowEmptyCatch": true }],
// statements must end with a semicolon
"semi": "error",
// `a+b` bad; `a + b` good
"space-infix-ops": "error",
// `var a = 1` bad; `var a = 1` good
"no-multi-spaces": "error",
// all files should end with a newline
"eol-last": "error",
// One true brace style:
//
// if (bloop) {
// bloop();
// } else {
// bleep();
// }
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
// 2 spaces
"indent": ["error", 2, { "SwitchCase": 1 }],
// Intentional overrides to airbnb's configs
// Allow multiple variable declarations for a single var/let/const statement.
"one-var": "off",
// We do not usually follow the functional style, and so it's normal to write functions that
// have side effects on arguments. Also, reassigning arguments for defensive argument validation
// and coersion is a frequent use case.
"no-param-reassign": "off",
// It's often better to order code in files by most important/relevant to least
// important/relevant rather than by declaration. For example, you might have multiple less
// important helper functions that are used before they are defined because the usage is much
// more important than the helpers themselves. Take advantage of function/class hoisting rather
// than banning it. Var hoisting is almost universally confusing though, so keep that disabled.
"no-use-before-define": ["error", {
"functions": false,
"classes": false
}],
// disallow certain syntax forms
// http://eslint.org/docs/rules/no-restricted-syntax
// This relaxes the disallow ForInStatement and ForOfStatemnet in airbnb. It would be a lot of
// work to refactor where we use those loops. And also, for...of statements allow us to stay in
// the co() or async context and use yield/await, whereas the functional alternatives don't.
// TODO(yunchi): We should eventually disallow for...in loops since they are mostly strictly
// worse than for...of loops.
'no-restricted-syntax': [
'error',
'LabeledStatement',
'WithStatement',
],
'comma-dangle': ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"functions": "never", // This is a syntax error...
}],
// This is too difficult to refactor and provides little value.
"no-shadow": "off",
// We use ++ and -- all over the place and it seems innocuous enough?
"no-plusplus": "off",
// Don't require function brackets: `const foo = (a) => true;` is okay
"arrow-body-style": "off",
// Don't require parameter parens: `const foo = a => true;` is okay
"arrow-parens": "off",
// Anonymous functions are okay
"func-names": "off",
// No blacklisted object / attribute names
"no-restricted-properties": "off",
// `a && b()` is okay; `a ? b() : c()` is okay
"no-unused-expressions": ["error", {
"allowShortCircuit": true,
"allowTernary": true
}],
// Allow member functions to not access `this`
"class-methods-use-this": "off",
// `<Foo ref={x => this.x = x} />` is okay
"no-return-assign": "off",
// `bloop.select('.bleep').map(a => a.bork)` is okay
"newline-per-chained-call": "off",
// Man line length is 100
"max-len": ["error", 100, {
"ignoreTemplateLiterals": true,
"ignoreStrings": true,
"ignoreUrls": true,
}],
// Mocha functions should use function expressions, not arrow functions
"mocha/no-mocha-arrows": "error",
// Either function expressions or arrow callbacks can be used
"prefer-arrow-callback": "off",
// No multiple blank lines.
"no-multiple-empty-lines": ["error", {
"max": 2,
"maxEOF": 1,
"maxBOF": 0
}],
// `function foo(x) {}` is okay
"space-before-function-paren": "off",
// `it.only`, `describe.only` et. al. will error. Not helpful if you run
// your lint rule as a mocha test case itself.
"mocha/no-exclusive-tests": "error"
}
};