-
Notifications
You must be signed in to change notification settings - Fork 38
/
.eslintrc.js
145 lines (130 loc) · 3.57 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
module.exports = {
env: {
browser: true,
},
settings: {
"import/resolver": {
webpack: { config: "webpack.config.js" },
},
},
extends: [
"airbnb-base",
"plugin:compat/recommended",
],
rules: {
// basic style modifications
indent: ["error", 2, { SwitchCase: 1 }],
quotes: ["error", "double"],
// redundant "else" can help readablity
"no-else-return": "off",
// ternary ops aren't that unreadable IMO
"no-nested-ternary": "off",
// bitwise ops are sometimes useful
"no-bitwise": "off",
// "continue" can help readablity as like "early-return"
"no-continue": "off",
// allow named export
"import/prefer-default-export": "off",
// allow importing devDependencies from inside "tests" dir
"import/no-extraneous-dependencies": ["error", {
devDependencies: [
"tests/**/*",
"webpack.config.js",
"playwright.config.ts",
],
optionalDependencies: false,
}],
// fns and classes can be referred before defined
"no-use-before-define": ["error", {
// functions: true,
// classes: true,
functions: false,
classes: false,
variables: true,
}],
// do not enforce destructuring for arrays (since they can be rather unreadable sometime)
"prefer-destructuring": ["error", {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
// array: true,
array: false,
object: false,
},
}, {
enforceForRenamedProperties: false,
}],
// arithmetic ops (eccept for "%" and "**") can be mixed without parens
"no-mixed-operators": ["error", {
groups: [
["%", "**"],
// ['%', '+'],
// ['%', '-'],
["%", "*"],
["%", "/"],
// ['/', '*'],
["&", "|", "<<", ">>", ">>>"],
["==", "!=", "===", "!=="],
["&&", "||"],
],
allowSamePrecedence: false,
}],
// labels are allowed to break nested loops
"no-restricted-syntax": [
"error",
"ForInStatement",
"ForOfStatement",
// 'LabeledStatement',
"WithStatement",
],
"no-labels": ["error", {
// allowLoop: false,
allowLoop: true,
allowSwitch: false,
}],
// omit extensions
"import/extensions": ["error", {
js: "never",
ts: "never",
}],
// newline around curly braces can be omitted as long as they are consistent
"object-curly-newline": ["error", {
ObjectExpression: { consistent: true },
ObjectPattern: { consistent: true },
ImportDeclaration: { consistent: true },
ExportDeclaration: { consistent: true },
}],
},
overrides: [
{
files: ["**/*.ts", "**/*.vue"],
parser: "vue-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
},
plugins: ["@typescript-eslint"],
extends: [
"plugin:vue/vue3-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
// vue template styles
"vue/html-indent": ["error", 2, {
attribute: 2,
baseIndent: 1,
alignAttributesVertically: true,
}],
"vue/html-closing-bracket-newline": ["error", {
singleline: "never",
multiline: "never",
}],
// non-null assertion is allowed as long as we are sure that it's non-null
"@typescript-eslint/no-non-null-assertion": "off",
// allow multiple attrs per line
"vue/max-attributes-per-line": "off",
},
},
],
};