-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy patheslint.config.js
317 lines (288 loc) · 10.2 KB
/
eslint.config.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
// const myConfig = require('./.eslintrc');
// const airbnbBaseConfig = require('eslint-config-airbnb-base');
// const utils = require('./packages/eslint/src/utils');
// console.log(convertExtends(require('@tunnckocore/eslint-config').extends));
/*
'eslint-config-airbnb-base/rules/best-practices',
'eslint-config-airbnb-base/rules/errors',
'eslint-config-airbnb-base/rules/node',
'eslint-config-airbnb-base/rules/style',
'eslint-config-airbnb-base/rules/variables',
'eslint-config-airbnb-base/rules/es6',
'eslint-config-airbnb-base/rules/imports',
'eslint-config-airbnb-base/rules/strict',
'plugin:prettier/recommended',
'prettier',
'@tunnckocore/eslint-config/mdx',
'@tunnckocore/eslint-config/jest',
'@tunnckocore/eslint-config/node',
'@tunnckocore/eslint-config/promise',
'plugin:promise/recommended',
'@tunnckocore/eslint-config/unicorn',
'plugin:unicorn/recommended',
*/
module.exports = [
'eslint:recommended',
require('eslint-config-airbnb-base/rules/best-practices'),
require('eslint-config-airbnb-base/rules/errors'),
require('eslint-config-airbnb-base/rules/node'),
require('eslint-config-airbnb-base/rules/style'),
require('eslint-config-airbnb-base/rules/variables'),
require('eslint-config-airbnb-base/rules/es6'),
require('eslint-config-airbnb-base/rules/imports'),
require('eslint-config-airbnb-base/rules/strict'),
{
name: 'enabled-prettier',
plugins: {
prettier: require('eslint-plugin-prettier'),
},
rules: {
...require('eslint-config-prettier').rules,
'prettier/prettier': 'error',
},
},
{
name: 'tunnckocore-base-config',
plugins: {
'no-use-extend-native': require('eslint-plugin-no-use-extend-native'),
},
rules: require('@tunnckocore/eslint-config/base').rules,
},
// require('@tunnckocore/eslint-config/mdx'),
// require('@tunnckocore/eslint-config/jest'),
{
name: 'node-plugin-and-rules',
plugins: {
node: require('eslint-plugin-node'),
},
rules: {
'node/no-deprecated-api': 'error',
'node/no-exports-assign': 'error',
'node/no-unpublished-bin': 'error',
// Redundant with import/no-extraneous-dependencies
// 'node/no-extraneous-import': 'error',
// 'node/no-extraneous-require': 'error',
// Redundant with import/no-unresolved
// 'node/no-missing-import': 'error',
// 'node/no-missing-require': 'error',
'node/no-unsupported-features/es-builtins': 'error',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-unsupported-features/node-builtins': 'error',
'no-process-exit': 'off',
'node/process-exit-as-throw': 'error',
'node/shebang': 'error',
'node/exports-style': 'off',
'node/file-extension-in-import': [
'error',
'never',
{
'.css': 'always',
'.scss': 'always',
'.sass': 'always',
'.less': 'always',
'.json': 'always',
},
],
'node/prefer-global/buffer': 'error',
'node/prefer-global/console': 'error',
'node/prefer-global/process': 'error',
// These below will be enabled in XO when it targets Node.js 10
'node/prefer-global/text-decoder': 'error',
'node/prefer-global/text-encoder': 'error',
'node/prefer-global/url-search-params': 'error',
'node/prefer-global/url': 'error',
'node/prefer-promises/dns': 'error',
'node/prefer-promises/fs': 'error',
},
},
{
name: 'promise-plugin-and-rules',
plugins: {
promise: require('eslint-plugin-promise'),
},
rules: {
...require('eslint-plugin-promise').configs.recommended.rules,
// These below are to ensure not changes
// inside upstream XO and the plugin:promise/recommended configs
'promise/catch-or-return': 'off',
'promise/always-return': 'off',
'promise/no-native': 'off',
'promise/no-nesting': 'off',
'promise/no-promise-in-callback': 'off',
'promise/no-callback-in-promise': 'off',
'promise/avoid-new': 'off',
'promise/prefer-await-to-then': 'error',
'promise/prefer-await-to-callbacks': 'error',
// These are the same as in XO CLI, but they are not in the eslint-config-xo
'promise/no-return-wrap': ['error', { allowReject: true }],
'promise/param-names': 'error',
'promise/no-new-statics': 'error',
'promise/no-return-in-finally': 'error',
'promise/valid-params': 'error',
},
},
{
name: 'unicorn-plugin-and-rules',
plugins: {
unicorn: require('eslint-plugin-unicorn'),
},
rules: {
...require('eslint-plugin-unicorn').configs.recommended.rules,
// It is too much annoyance for me. It's a good thing, but generally
// after so many years we already name things properly,
// so please don't mess with me and don't correct me.
'unicorn/prevent-abbreviations': 'off',
// These below are intentional & explicit overrides of XO and Unicorn
// ! needed for `unicorn/no-unreadable-array-destructuring`
'prefer-destructuring': ['error', { object: true, array: false }],
'unicorn/no-unreadable-array-destructuring': 'error', // default in recommended
'unicorn/no-unused-properties': 'error',
// Disallow unsafe regular expressions.
// Don't allow potential catastrophic crashes, slow behaving and downtimes.
// You still can disable that and do whatever you want,
// but that will be explicit and visible.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-unsafe-regex.md
'unicorn/no-unsafe-regex': 'error',
// Enforce importing index files with `.` instead of `./index`. (fixable)
// But we should be explicit. We know it is working without that,
// but at least it is good for newcomers.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/import-index.md
'unicorn/import-index': 'off',
// Enforce proper Error subclassing. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/custom-error-definition.md
'unicorn/custom-error-definition': 'error',
// Pretty useful rule, but it depends.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/filename-case.md
'unicorn/filename-case': 'off',
// It is pretty common to name it `err`, and there is almost no reason to be any other.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/catch-error-name.md
'unicorn/catch-error-name': ['error', { name: 'err' }],
// Doesn't work well in node-land. We have `.on/.off` emitters in Nodejs.
'unicorn/prefer-add-event-listener': 'off',
'unicorn/no-process-exit': 'error',
},
},
{
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
settings: require('@tunnckocore/eslint-config/settings'),
},
].concat({
name: 'lint-sources',
files: 'packages/*/src/**/*.js',
rules: {
'import/no-unresolved': 'off',
'import/no-dynamic-require': 'off',
'global-require': 'off',
// strict: ['error', 'always'],
},
});
// module.exports = utils.createItemsFromExtends(myConfig.extends).concat({
// name: 'lint-sources',
// files: 'packages/*/src/**/*.js',
// ...myConfig,
// // rules: {
// // ...myConfig.rules,
// // 'import/no-unresolved': 'off',
// // 'import/no-dynamic-require': 'off',
// // 'global-require': 'off',
// // },
// });
// module.exports = [
// // {
// // files: 'packages/*/src/**/*.js',
// // plugins: {
// // unicorn: require('eslint-plugin-unicorn'),
// // 'custom-plugin': require('./custom-eslint-plugin'),
// // },
// // languageOptions: {
// // // directly requiring the parser
// // // parser: require('babel-eslint'),
// // // or: through the loaded plugin
// // parser: 'custom-plugin/eslint-esnext',
// // ecmaVersion: 2020,
// // sourceType: 'module',
// // },
// // rules: {
// // ...require('eslint-config-airbnb').rules,
// // 'unicorn/no-process-exit': ['error'],
// // 'unicorn/consistent-function-scoping': 'off',
// // semi: 'error',
// // },
// // },
// // {
// // files: '**/__tests__/**/*.{js,jsx}',
// // plugins: {
// // unicorn: require('eslint-plugin-unicorn'),
// // 'custom-plugin': require('./custom-eslint-plugin'),
// // react: require('eslint-plugin-react'),
// // },
// // languageOptions: {
// // // directly requiring the parser
// // // parser: require('babel-eslint'),
// // // or: through the loaded plugin
// // parser: 'custom-plugin/eslint-esnext',
// // ecmaVersion: 2020,
// // sourceType: 'module',
// // },
// // rules: {
// // ...require('eslint-config-airbnb').rules,
// // 'unicorn/no-process-exit': ['error'],
// // 'unicorn/consistent-function-scoping': 'off',
// // semi: 'error',
// // 'react/jsx-uses-react': 'error',
// // 'global-require': 'error',
// // },
// // },
// {
// name: 'loading-babel-eslint-parser-through-custom-plugin',
// plugins: {
// 'custom-plugin': require('./custom-eslint-plugin'),
// },
// },
// // example using the custom loaded parser
// {
// name: 'use-parser-from-custom-plugin',
// plugins: {
// baw: require('eslint-plugin-import'),
// },
// languageOptions: {
// globals: {
// qwqwqw: true,
// },
// // directly requiring the parser
// // parser: require('babel-eslint'),
// // or: through the loaded plugin
// parser: 'custom-plugin/eslint-esnext',
// },
// },
// {
// name: 'lint-sources',
// files: 'packages/*/src/**/*.js',
// ...myConfig,
// },
// {
// name: 'lang-options',
// languageOptions: {
// ecmaVersion: 2020,
// sourceType: 'commonjs',
// },
// },
// {
// name: 'lint-tests',
// files: '**/__tests__/**/*.{js,jsx}',
// ...myConfig,
// // {
// // plugins: {
// // react: require('eslint-plugin-react'),
// // },
// // rules: {
// // 'react/jsx-uses-react': 'error',
// // 'global-require': 'error',
// // },
// // },
// },
// ];