forked from MALSync/MALSync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
221 lines (219 loc) · 5.93 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/**
* @type {import("eslint").Linter.RulesRecord}
*/
const COMMON_RULES = {
// Import rules
'import/no-webpack-loader-syntax': 'off',
'import/prefer-default-export': 'off',
'import/extensions': ['error', 'ignorePackages', { js: 'never', ts: 'never' }],
// General rules
'block-scoped-var': 'warn', // TODO
'no-await-in-loop': 'warn', // TODO
'prefer-destructuring': 'warn', // TODO
'no-continue': 'off',
'no-throw-literal': 'off',
'guard-for-in': 'off',
'no-param-reassign': 'warn',
'no-underscore-dangle': 'off',
'class-methods-use-this': 'off',
'no-fallthrough': 'off',
'no-plusplus': 0,
'vue/no-useless-template-attributes': 'off',
'no-constructor-return': 'off',
'import/no-unresolved': ['error', { ignore: ['style\\.less$', 'quicklinks\\.json$'] }],
'no-restricted-syntax': [
'error',
// TODO: Reenable rule
// {
// "selector": "ForInStatement",
// "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
// },
{
selector: 'ForOfStatement',
message:
'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
};
/**
* @type {import("eslint").Linter.RulesRecord}
*/
const TYPESCRIPT_RULES = {
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/ban-types': [
'off',
{
types: {
// add a custom message to help explain why not to use it
Object: '',
'{}': '',
object: '',
},
extendDefaults: true,
},
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
};
/**
* @type {import("eslint").Linter.Config}
*/
module.exports = {
env: {
es6: true,
greasemonkey: true,
jquery: true,
'shared-node-browser': true,
webextensions: true,
browser: true,
},
extends: ['airbnb-base', 'plugin:es/restrict-to-es2018'],
globals: {
api: 'readonly',
con: 'readonly',
j: 'readonly',
utils: 'readonly',
__MAL_SYNC_KEYS__: 'readonly',
},
ignorePatterns: [
'dist/',
'node_modules/',
'test/dist',
'*.min.js',
'docs/',
'package/',
'eslint/',
'test/', // TODO
'webpackConfig/', // TODO
],
overrides: [
{
extends: [
'eslint:recommended',
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier',
],
files: ['*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'jquery-unsafe-malsync', 'no-unsanitized'],
rules: {
...COMMON_RULES,
// Import rules
'import/no-cycle': 'warn', // TODO
'import/no-self-import': 'warn',
// TS rules
...TYPESCRIPT_RULES,
// General rules
camelcase: ['error', { allow: ['_'] }],
'vars-on-top': 'off',
'global-require': 'warn',
'no-inner-declarations': 'warn', // TODO
'no-unreachable': 'warn',
'no-use-before-define': 'off',
'no-unsanitized/method': [
'error',
{
escape: {
methods: ['j.html'],
},
},
],
'no-unsanitized/property': [
'error',
{
escape: {
methods: ['j.html'],
},
},
],
'es/no-nullish-coalescing-operators': 'off',
'es/no-optional-chaining': 'warn',
'es/no-regexp-lookbehind-assertions': 'error',
// Custom rules
'jquery-unsafe-malsync/no-xss-jquery': 2,
},
settings: {
'import/extensions': ['.js', '.ts'],
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.vue'],
},
},
},
},
{
extends: [
'plugin:vue/vue3-recommended',
'@vue/prettier',
'@vue/eslint-config-typescript/recommended',
],
files: ['*.vue'],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
plugins: ['vue', 'prettier'],
rules: {
...COMMON_RULES,
...TYPESCRIPT_RULES,
'prettier/prettier': ['error', { singleQuote: true }],
'vue/component-tags-order': 'off',
'vue/no-v-for-template-key-on-child': 'off',
'vue/no-deprecated-destroyed-lifecycle': 'off',
'vue/no-v-html': 'error',
'vue/multi-word-component-names': 'off',
'vue/no-deprecated-filter': 'off',
'vue/no-setup-props-destructure': 'warn',
},
},
{
extends: ['plugin:prettier/recommended'],
files: ['*.js'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
},
},
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
root: true,
rules: {
'prettier/prettier': ['error', { singleQuote: true }],
...COMMON_RULES,
eqeqeq: ['error', 'always'],
'no-extend-native': 'off',
'prefer-template': 'error',
'no-console': 'off',
radix: ['error', 'as-needed'],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.vue'],
},
},
},
};