@naturalcycles/dev-lib 20.39.0 → 20.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,13 +19,13 @@ import { exec2 } from '@naturalcycles/nodejs-lib/exec2'
19
19
  import picomatch from 'picomatch'
20
20
  import { prettierExtensionsAll, lintExclude, minActionlintVersion } from './_cnst.js'
21
21
 
22
- const oxfmtConfigPath = ['.oxfmtrc.jsonc', '.oxfmtrc.json'].find(fs.existsSync)
22
+ const oxfmtConfigPath = ['oxfmt.config.ts'].find(fs.existsSync)
23
23
 
24
24
  const stylelintConfigPath = [`stylelint.config.js`].find(fs.existsSync)
25
25
 
26
26
  const eslintConfigPath = ['eslint.config.js'].find(fs.existsSync)
27
27
 
28
- const oxlintConfigPath = ['.oxlintrc.json'].find(fs.existsSync)
28
+ const oxlintConfigPath = ['oxlint.config.ts'].find(fs.existsSync)
29
29
 
30
30
  let oxfmtCmd = undefined
31
31
 
@@ -0,0 +1,5 @@
1
+ import type { OxfmtConfig } from 'oxfmt'
2
+
3
+ export function defineOxfmtConfig(config: OxfmtConfig): OxfmtConfig
4
+
5
+ export const sharedConfig: OxfmtConfig
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from 'oxfmt'
2
+
3
+ export function defineOxfmtConfig(config) {
4
+ return defineConfig({
5
+ ...sharedConfig,
6
+ ...config,
7
+ ignorePatterns: [...sharedConfig.ignorePatterns, ...(config.ignorePatterns || [])],
8
+ })
9
+ }
10
+
11
+ export const sharedConfig = {
12
+ ignorePatterns: ['__exclude', '*.compact.json', '*.mock.json'],
13
+ arrowParens: 'avoid',
14
+ proseWrap: 'always',
15
+ semi: false,
16
+ singleQuote: true,
17
+ tabWidth: 2,
18
+ sortPackageJson: false,
19
+ sortImports: {
20
+ newlinesBetween: false,
21
+ groups: [
22
+ 'side_effect',
23
+ 'side_effect-style',
24
+ 'builtin',
25
+ 'external',
26
+ ['internal', 'parent', 'sibling', 'index'],
27
+ 'unknown',
28
+ ],
29
+ },
30
+ }
@@ -0,0 +1,5 @@
1
+ import type { OxlintConfig } from 'oxlint'
2
+
3
+ export function defineOxlintConfig(config: OxlintConfig): OxlintConfig
4
+
5
+ export const sharedConfig: OxlintConfig
@@ -0,0 +1,401 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export function defineOxlintConfig(config) {
4
+ return defineConfig({
5
+ ...sharedConfig,
6
+ ...config,
7
+ ignorePatterns: [...sharedConfig.ignorePatterns, ...(config.ignorePatterns || [])],
8
+ rules: {
9
+ ...sharedConfig.rules,
10
+ ...config.rules,
11
+ },
12
+ settings: {
13
+ ...sharedConfig.settings,
14
+ ...config.settings,
15
+ },
16
+ })
17
+ }
18
+
19
+ export const sharedConfig = {
20
+ ignorePatterns: ['__exclude'],
21
+ plugins: [
22
+ 'oxc',
23
+ 'eslint',
24
+ 'typescript',
25
+ 'unicorn',
26
+ 'import',
27
+ 'jsdoc',
28
+ 'node',
29
+ 'promise',
30
+ // enable as needed
31
+ // "react",
32
+ // "react-perf",
33
+ // "jsx-a11y",
34
+ // "vue",
35
+ 'vitest',
36
+ ],
37
+ jsPlugins: [`${import.meta.dirname}/oxlint-plugin-stylistic.mjs`],
38
+ options: {
39
+ reportUnusedDisableDirectives: 'deny',
40
+ maxWarnings: 0,
41
+ denyWarnings: true,
42
+ typeAware: true,
43
+ typeCheck: true,
44
+ },
45
+ rules: {
46
+ 'no-unused-vars': [
47
+ 'error',
48
+ {
49
+ fix: {
50
+ imports: 'fix',
51
+ variables: 'suggestion',
52
+ },
53
+ varsIgnorePattern: '^(_$|__)',
54
+ argsIgnorePattern: '^_',
55
+ destructuredArrayIgnorePattern: '^_',
56
+ },
57
+ ],
58
+ '@stylistic/padding-line-between-statements': [
59
+ 2,
60
+ { blankLine: 'always', prev: 'function', next: '*' },
61
+ { blankLine: 'always', prev: '*', next: 'function' },
62
+ { blankLine: 'always', prev: 'class', next: '*' },
63
+ { blankLine: 'always', prev: '*', next: 'class' },
64
+ ],
65
+ '@stylistic/lines-between-class-members': [2, 'always', { exceptAfterSingleLine: true }],
66
+ complexity: [2, { max: 40 }],
67
+ 'no-this-alias': 0,
68
+ 'no-shadow': 0, // too many shadows in the codebase already
69
+ 'no-async-promise-executor': 0,
70
+ 'no-standalone-expect': 0,
71
+ 'no-conditional-expect': 0,
72
+ 'expect-expect': 0,
73
+ 'no-disabled-tests': 0,
74
+ 'valid-expect': 0,
75
+ 'valid-title': 0,
76
+ 'valid-describe-callback': 0,
77
+ 'jsdoc/require-yields': 0,
78
+ 'no-new-wrappers': 2,
79
+ 'no-useless-call': 2,
80
+ 'no-accumulating-spread': 2,
81
+ 'no-map-spread': 0, // todo: consider, check the effect
82
+ 'prefer-array-find': 2,
83
+ 'prefer-array-flat-map': 2,
84
+ 'prefer-set-has': 2,
85
+ 'prefer-const': [2, { destructuring: 'all' }],
86
+ 'no-array-constructor': 2,
87
+ 'no-useless-return': 0, // not useful
88
+ 'no-bitwise': 2,
89
+ 'no-empty': [2, { allowEmptyCatch: true }],
90
+ 'no-regex-spaces': 2,
91
+ 'no-sequences': 2,
92
+ 'no-implicit-coercion': [2, { allow: ['!!'] }],
93
+ 'no-restricted-globals': [2, 'event', '__dirname', '__filename'],
94
+ 'no-unused-expressions': 2,
95
+ 'no-var': 2,
96
+ 'unicode-bom': 2,
97
+ 'no-extend-native': 2,
98
+ 'no-extra-bind': 2,
99
+ 'no-duplicate-imports': [
100
+ 0, // disabled until auto-fix is there
101
+ {
102
+ allowSeparateTypeImports: true,
103
+ },
104
+ ],
105
+ 'no-new': 2,
106
+ 'no-unexpected-multiline': 2,
107
+ 'no-unneeded-ternary': 2,
108
+ 'no-useless-concat': 2,
109
+ 'no-useless-constructor': 2,
110
+ 'preserve-caught-error': 2,
111
+ eqeqeq: [2, 'smart'],
112
+ curly: [2, 'multi-line'],
113
+ 'guard-for-in': 2,
114
+ 'max-params': [2, { max: 5 }],
115
+ 'prefer-spread': 2,
116
+ 'import/extensions': [0, 'always', { ignorePackages: true }], // disabled as it's buggy; would be nice to enable eventually
117
+ 'import/no-amd': 2,
118
+ 'import/no-commonjs': 2,
119
+ 'import/no-cycle': 2,
120
+ 'import/no-default-export': 2,
121
+ 'import/no-webpack-loader-syntax': 2,
122
+ 'import/no-duplicates': [2, { 'prefer-inline': false }],
123
+ // "import/export": 2, // todo: adopt when it graduates
124
+ 'import/no-empty-named-blocks': 2,
125
+ 'import/no-absolute-path': 2,
126
+ 'import/no-named-as-default': 2,
127
+ 'import/no-named-as-default-member': 0,
128
+ 'import/no-self-import': 2,
129
+ 'import/no-unassigned-import': 0,
130
+ 'oxc/bad-bitwise-operator': 2,
131
+ 'oxc/no-const-enum': 2,
132
+ 'oxc/approx-constant': 2,
133
+ 'oxc/misrefactored-assign-op': 2,
134
+ 'promise/spec-only': 2,
135
+ 'typescript/class-literal-property-style': 2,
136
+ 'typescript/explicit-function-return-type': [2, { allowExpressions: true }],
137
+ // "typescript/explicit-module-boundary-types": [2, {"allowArgumentsExplicitlyTypedAsAny": true}]
138
+ 'typescript/no-empty-object-type': [2, { allowInterfaces: 'always' }],
139
+ 'typescript/no-import-type-side-effects': 2,
140
+ // "typescript/no-namespace": 2,
141
+ 'typescript/no-non-null-asserted-nullish-coalescing': 2,
142
+ 'typescript/no-require-imports': 2,
143
+ 'typescript/no-var-requires': 2,
144
+ 'typescript/no-unnecessary-template-expression': 2,
145
+ 'typescript/no-unnecessary-type-arguments': 0, // not good in the end
146
+ 'typescript/no-unnecessary-type-constraint': 2,
147
+ // "typescript/no-unsafe-argument": 2, // looks good, but too strict for now
148
+ // "typescript/no-dynamic-delete": 2,
149
+ 'typescript/prefer-optional-chain': 0, // buggy
150
+ 'typescript/non-nullable-type-assertion-style': 2,
151
+ 'typescript/prefer-literal-enum-member': 2,
152
+ 'typescript/prefer-reduce-type-parameter': 2,
153
+ 'typescript/promise-function-async': [
154
+ 2,
155
+ {
156
+ checkArrowFunctions: false,
157
+ checkFunctionDeclarations: true,
158
+ checkFunctionExpressions: true,
159
+ checkMethodDeclarations: true,
160
+ },
161
+ ],
162
+ 'typescript/prefer-for-of': 2,
163
+ 'typescript/no-confusing-non-null-assertion': 2,
164
+ 'typescript/ban-ts-comment': [
165
+ 2,
166
+ {
167
+ minimumDescriptionLength: 2,
168
+ 'ts-expect-error': 'allow-with-description',
169
+ 'ts-nocheck': 'allow-with-description',
170
+ 'ts-check': false,
171
+ 'ts-ignore': true,
172
+ },
173
+ ],
174
+ 'typescript/ban-tslint-comment': 2,
175
+ 'typescript/prefer-function-type': 2,
176
+ 'typescript/prefer-namespace-keyword': 2,
177
+ 'typescript/consistent-generic-constructors': [2, 'constructor'],
178
+ 'typescript/consistent-type-definitions': [2, 'interface'],
179
+ 'typescript/consistent-type-imports': 2,
180
+ 'typescript/consistent-type-assertions': [
181
+ 2,
182
+ {
183
+ assertionStyle: 'as',
184
+ },
185
+ ],
186
+ 'typescript/no-inferrable-types': [
187
+ 2,
188
+ {
189
+ ignoreParameters: true,
190
+ },
191
+ ],
192
+ 'typescript/adjacent-overload-signatures': 2,
193
+ 'typescript/array-type': 2,
194
+ 'typescript/prefer-enum-initializers': 2,
195
+ 'typescript/prefer-promise-reject-errors': 2,
196
+ 'typescript/prefer-ts-expect-error': 2,
197
+ 'typescript/require-await': 0, // not good yet
198
+ 'typescript/restrict-plus-operands': 2,
199
+ 'typescript/return-await': [2, 'error-handling-correctness-only'],
200
+ 'typescript/only-throw-error': 2,
201
+ 'typescript/no-unsafe-function-type': 2,
202
+ 'typescript/no-misused-promises': [
203
+ 2,
204
+ {
205
+ checksVoidReturn: {
206
+ // "variables": false,
207
+ // "inheritedMethods": false,
208
+ // "returns": false
209
+ arguments: false,
210
+ properties: false,
211
+ },
212
+ },
213
+ ],
214
+ 'typescript/no-mixed-enums': 2,
215
+ 'typescript/no-unnecessary-type-assertion': 2,
216
+ 'typescript/no-unnecessary-boolean-literal-compare': 2,
217
+ 'typescript/no-base-to-string': 2,
218
+ // disabled, as it fails on legit unit test patterns
219
+ 'typescript/unbound-method': [
220
+ 0,
221
+ {
222
+ ignoreStatic: true,
223
+ },
224
+ ],
225
+ 'typescript/switch-exhaustiveness-check': 0, // not good
226
+ 'typescript/require-array-sort-compare': 0, // not good
227
+ 'typescript/restrict-template-expressions': 0, // not good
228
+ 'typescript/no-redundant-type-constituents': 0, // `'a' | string` is still useful for DX
229
+ 'typescript/no-restricted-types': [
230
+ 2,
231
+ {
232
+ types: {
233
+ Boolean: {
234
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
235
+ },
236
+ Number: {
237
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
238
+ },
239
+ object: {
240
+ message:
241
+ 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).\nConsider using `Record<string, any>` instead, as it allows you to more easily inspect and use the keys.',
242
+ },
243
+ Object: {
244
+ message:
245
+ 'Avoid using the `Object` type. Did you mean `object`? Consider using Record<string, any> instead',
246
+ },
247
+ String: {
248
+ message: 'Avoid using the `String` type. Did you mean `string`?',
249
+ },
250
+ Symbol: {
251
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
252
+ },
253
+ },
254
+ },
255
+ ],
256
+ 'unicorn/no-anonymous-default-export': 2,
257
+ 'unicorn/no-immediate-mutation': 2,
258
+ 'unicorn/no-array-reduce': 2,
259
+ 'unicorn/no-document-cookie': 2,
260
+ 'unicorn/no-length-as-slice-end': 2,
261
+ 'unicorn/no-magic-array-flat-depth': 2,
262
+ 'unicorn/prefer-modern-math-apis': 2,
263
+ 'unicorn/prefer-node-protocol': 2,
264
+ 'unicorn/require-module-specifiers': 2,
265
+ 'unicorn/require-module-attributes': 2,
266
+ 'unicorn/prefer-classlist-toggle': 2,
267
+ 'unicorn/no-unnecessary-array-splice-count': 2,
268
+ 'unicorn/no-useless-error-capture-stack-trace': 2,
269
+ 'unicorn/prefer-top-level-await': 2,
270
+ 'unicorn/prefer-class-fields': 2,
271
+ 'unicorn/consistent-assert': 2,
272
+ 'unicorn/consistent-date-clone': 2,
273
+ 'unicorn/consistent-empty-array-spread': 2,
274
+ 'unicorn/consistent-existence-index-check': 2,
275
+ 'unicorn/escape-case': 2,
276
+ 'unicorn/prefer-keyboard-event-key': 2,
277
+ 'unicorn/prefer-default-parameters': 2,
278
+ 'unicorn/no-console-spaces': 2,
279
+ 'unicorn/no-hex-escape': 2,
280
+ 'unicorn/no-instanceof-builtins': 2,
281
+ 'unicorn/no-lonely-if': 2,
282
+ 'unicorn/no-negation-in-equality-check': 2,
283
+ 'unicorn/no-new-buffer': 2,
284
+ 'unicorn/prefer-string-replace-all': 2,
285
+ 'unicorn/prefer-math-min-max': 2,
286
+ 'unicorn/prefer-code-point': 2,
287
+ 'unicorn/prefer-global-this': 2,
288
+ 'unicorn/error-message': 2,
289
+ 'unicorn/no-zero-fractions': 2,
290
+ 'unicorn/prefer-array-some': 2,
291
+ 'unicorn/prefer-math-trunc': 2,
292
+ 'unicorn/prefer-includes': 2,
293
+ 'unicorn/prefer-response-static-json': 2,
294
+ 'import/no-named-default': 2,
295
+ 'import/consistent-type-specifier-style': 2,
296
+ 'unicorn/no-new-array': 0, // it's actually ok
297
+ 'unicorn/catch-error-name': [
298
+ 2,
299
+ {
300
+ name: 'err',
301
+ ignore: [String.raw`^err\d*$`, '^_'],
302
+ },
303
+ ],
304
+ 'unicorn/no-accessor-recursion': 2,
305
+ 'unicorn/prefer-string-slice': 2,
306
+ 'unicorn/no-unnecessary-array-flat-depth': 2,
307
+ 'unicorn/no-unnecessary-slice-end': 2,
308
+ 'unicorn/no-unreadable-array-destructuring': 2,
309
+ 'unicorn/no-unreadable-iife': 2,
310
+ 'unicorn/no-useless-collection-argument': 2,
311
+ 'unicorn/no-useless-promise-resolve-reject': 2,
312
+ 'unicorn/numeric-separators-style': [
313
+ 2,
314
+ {
315
+ binary: {
316
+ groupLength: 4,
317
+ minimumDigits: 0,
318
+ },
319
+ hexadecimal: {
320
+ groupLength: 2,
321
+ minimumDigits: 0,
322
+ },
323
+ number: {
324
+ groupLength: 3,
325
+ minimumDigits: 5,
326
+ },
327
+ octal: {
328
+ groupLength: 4,
329
+ minimumDigits: 0,
330
+ },
331
+ onlyIfContainsSeparator: true,
332
+ },
333
+ ],
334
+ 'unicorn/prefer-add-event-listener': 2,
335
+ 'unicorn/prefer-array-index-of': 2,
336
+ 'unicorn/prefer-bigint-literals': 2,
337
+ 'unicorn/prefer-blob-reading-methods': 2,
338
+ 'unicorn/prefer-dom-node-append': 2,
339
+ 'unicorn/prefer-dom-node-dataset': 2,
340
+ 'unicorn/prefer-dom-node-remove': 2,
341
+ 'unicorn/prefer-dom-node-text-content': 2,
342
+ 'unicorn/prefer-event-target': 2,
343
+ 'unicorn/prefer-logical-operator-over-ternary': 2,
344
+ 'unicorn/prefer-modern-dom-apis': 2,
345
+ 'unicorn/prefer-native-coercion-functions': 2,
346
+ 'unicorn/prefer-object-from-entries': 2,
347
+ 'unicorn/prefer-optional-catch-binding': 2,
348
+ 'unicorn/prefer-reflect-apply': 2,
349
+ 'unicorn/prefer-string-raw': 2,
350
+ 'unicorn/prefer-string-trim-start-end': 2,
351
+ 'unicorn/prefer-type-error': 2,
352
+ 'unicorn/require-array-join-separator': 2,
353
+ 'unicorn/switch-case-braces': [2, 'always'],
354
+ 'unicorn/text-encoding-identifier-case': [
355
+ 2,
356
+ {
357
+ withDash: false,
358
+ },
359
+ ],
360
+ 'vitest/no-duplicate-hooks': 2,
361
+ 'vitest/consistent-vitest-vi': 2,
362
+ 'vitest/no-focused-tests': 2,
363
+ 'vitest/no-identical-title': 2,
364
+ 'vitest/no-test-return-statement': 2,
365
+ 'vitest/prefer-hooks-in-order': 2,
366
+ 'vitest/prefer-hooks-on-top': 2,
367
+ 'vitest/prefer-mock-promise-shorthand': 2,
368
+ 'vitest/prefer-to-have-length': 2,
369
+ 'vitest/require-to-throw-message': 2,
370
+ 'vitest/valid-describe-callback': 0,
371
+ 'vitest/valid-expect': 0,
372
+ 'vitest/no-import-node-test': 2,
373
+ 'vitest/no-mocks-import': 2,
374
+ 'vitest/prefer-spy-on': 2,
375
+ 'vitest/prefer-to-be': 2,
376
+ 'vitest/prefer-to-contain': 2,
377
+ 'vitest/consistent-test-filename': 2,
378
+ 'vitest/warn-todo': 0,
379
+ 'jest/consistent-test-it': [
380
+ 2,
381
+ {
382
+ fn: 'test',
383
+ withinDescribe: 'test',
384
+ },
385
+ ],
386
+ 'jest/max-nested-describe': [0, { max: 4 }], // not good
387
+ 'jest/no-alias-methods': 2,
388
+ 'jest/prefer-mock-return-shorthand': 2,
389
+ 'vue/no-multiple-slot-args': 2,
390
+ 'vue/no-deprecated-destroyed-lifecycle': 2,
391
+ 'vue/define-emits-declaration': [2, 'type-based'],
392
+ 'vue/define-props-declaration': 2,
393
+ },
394
+ settings: {
395
+ jsdoc: {
396
+ tagNamePreference: {
397
+ experimental: 'experimental',
398
+ },
399
+ },
400
+ },
401
+ }
@@ -196,7 +196,7 @@ function runESLint(extensions = eslintExtensions.split(','), fix = true) {
196
196
  */
197
197
  export function runOxlint(fix = true) {
198
198
  if (!hasOxlintConfig()) {
199
- console.log('.oxlintrc.json is not found, skipping to run oxlint');
199
+ console.log('oxlint.config.ts is not found, skipping to run oxlint');
200
200
  return false;
201
201
  }
202
202
  const oxlintPath = findPackageBinPath('oxlint', 'oxlint');
@@ -212,7 +212,7 @@ export function runOxlint(fix = true) {
212
212
  */
213
213
  export function runOxfmt(fix = true) {
214
214
  if (!hasOxfmtConfig()) {
215
- console.log('.oxfmtrc.json(c) is not found, skipping to run oxfmt');
215
+ console.log('oxfmt.config.ts is not found, skipping to run oxfmt');
216
216
  return false;
217
217
  }
218
218
  const oxlintPath = findPackageBinPath('oxfmt', 'oxfmt');
@@ -224,14 +224,14 @@ export function runOxfmt(fix = true) {
224
224
  return true;
225
225
  }
226
226
  export function requireOxlintConfig() {
227
- _assert(hasOxlintConfig(), '.oxlintrc.json config is not found');
227
+ _assert(hasOxlintConfig(), 'oxlint.config.ts config is not found');
228
228
  }
229
229
  export function hasOxlintConfig() {
230
- const oxlintConfigPath = `.oxlintrc.json`;
230
+ const oxlintConfigPath = `oxlint.config.ts`;
231
231
  return existsSync(oxlintConfigPath);
232
232
  }
233
233
  export function hasOxfmtConfig() {
234
- return ['.oxfmtrc.jsonc', '.oxfmtrc.json'].some(existsSync);
234
+ return ['oxfmt.config.ts'].some(existsSync);
235
235
  }
236
236
  const stylelintPaths = [
237
237
  // Everything inside these folders
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.39.0",
4
+ "version": "20.40.0",
5
5
  "dependencies": {
6
6
  "prompts": "^2",
7
7
  "@naturalcycles/js-lib": "^15",
@@ -53,7 +53,8 @@
53
53
  "exports": {
54
54
  "./cfg/": "./cfg/",
55
55
  "./cfg/eslint.config.js": "./cfg/eslint.config.js",
56
- "./cfg/oxlint.config.json": "./cfg/oxlint.config.json",
56
+ "./cfg/oxfmt.config.js": "./cfg/oxfmt.config.js",
57
+ "./cfg/oxlint.config.js": "./cfg/oxlint.config.js",
57
58
  "./cfg/stylelint.config.js": "./cfg/stylelint.config.js",
58
59
  "./cfg/tsconfig.src.json": "./cfg/tsconfig.src.json",
59
60
  "./cfg/tsconfig.scripts.json": "./cfg/tsconfig.scripts.json",
@@ -1,375 +0,0 @@
1
- {
2
- "$schema": "../node_modules/oxlint/configuration_schema.json",
3
- "plugins": [
4
- "oxc",
5
- "eslint",
6
- "typescript",
7
- "unicorn",
8
- "import",
9
- "jsdoc",
10
- "node",
11
- "promise",
12
- // enable as needed
13
- // "react",
14
- // "react-perf",
15
- // "jsx-a11y",
16
- // "vue",
17
- "vitest"
18
- ],
19
- "jsPlugins": ["./oxlint-plugin-stylistic.mjs"],
20
- "options": {
21
- "reportUnusedDisableDirectives": "deny",
22
- "maxWarnings": 0,
23
- "denyWarnings": true,
24
- "typeAware": true,
25
- "typeCheck": true
26
- },
27
- "rules": {
28
- "no-unused-vars": [
29
- "error",
30
- {
31
- "fix": {
32
- "imports": "fix",
33
- "variables": "suggestion"
34
- },
35
- "varsIgnorePattern": "^(_$|__)",
36
- "argsIgnorePattern": "^_",
37
- "destructuredArrayIgnorePattern": "^_"
38
- }
39
- ],
40
- "@stylistic/padding-line-between-statements": [
41
- 2,
42
- { "blankLine": "always", "prev": "function", "next": "*" },
43
- { "blankLine": "always", "prev": "*", "next": "function" },
44
- { "blankLine": "always", "prev": "class", "next": "*" },
45
- { "blankLine": "always", "prev": "*", "next": "class" }
46
- ],
47
- "@stylistic/lines-between-class-members": [2, "always", { "exceptAfterSingleLine": true }],
48
- "complexity": [2, { "max": 40 }],
49
- "no-this-alias": 0,
50
- "no-shadow": 0, // too many shadows in the codebase already
51
- "no-async-promise-executor": 0,
52
- "no-standalone-expect": 0,
53
- "no-conditional-expect": 0,
54
- "expect-expect": 0,
55
- "no-disabled-tests": 0,
56
- "valid-expect": 0,
57
- "valid-title": 0,
58
- "valid-describe-callback": 0,
59
- "jsdoc/require-yields": 0,
60
- "no-new-wrappers": 2,
61
- "no-useless-call": 2,
62
- "no-accumulating-spread": 2,
63
- "no-map-spread": 0, // todo: consider, check the effect
64
- "prefer-array-find": 2,
65
- "prefer-array-flat-map": 2,
66
- "prefer-set-has": 2,
67
- "prefer-const": [2, { "destructuring": "all" }],
68
- "no-array-constructor": 2,
69
- "no-useless-return": 0, // not useful
70
- "no-bitwise": 2,
71
- "no-empty": [2, { "allowEmptyCatch": true }],
72
- "no-regex-spaces": 2,
73
- "no-sequences": 2,
74
- "no-implicit-coercion": [2, { "allow": ["!!"] }],
75
- "no-restricted-globals": [2, "event", "__dirname", "__filename"],
76
- "no-unused-expressions": 2,
77
- "no-var": 2,
78
- "unicode-bom": 2,
79
- "no-extend-native": 2,
80
- "no-extra-bind": 2,
81
- "no-new": 2,
82
- "no-unexpected-multiline": 2,
83
- "no-unneeded-ternary": 2,
84
- "no-useless-concat": 2,
85
- "no-useless-constructor": 2,
86
- "preserve-caught-error": 2,
87
- "eqeqeq": [2, "smart"],
88
- "curly": [2, "multi-line"],
89
- "guard-for-in": 2,
90
- "max-params": [2, { "max": 5 }],
91
- "prefer-spread": 2,
92
- "import/extensions": [0, "always", { "ignorePackages": true }], // disabled as it's buggy; would be nice to enable eventually
93
- "import/no-amd": 2,
94
- "import/no-commonjs": 2,
95
- "import/no-cycle": 2,
96
- "import/no-default-export": 2,
97
- "import/no-webpack-loader-syntax": 2,
98
- "import/no-duplicates": [2, { "prefer-inline": false }],
99
- // "import/export": 2, // todo: adopt when it graduates
100
- "import/no-empty-named-blocks": 2,
101
- "import/no-absolute-path": 2,
102
- "import/no-named-as-default": 2,
103
- "import/no-named-as-default-member": 0,
104
- "import/no-self-import": 2,
105
- "import/no-unassigned-import": 0,
106
- "oxc/bad-bitwise-operator": 2,
107
- "oxc/no-const-enum": 2,
108
- "oxc/approx-constant": 2,
109
- "oxc/misrefactored-assign-op": 2,
110
- "promise/spec-only": 2,
111
- "typescript/class-literal-property-style": 2,
112
- "typescript/explicit-function-return-type": [2, { "allowExpressions": true }],
113
- // "typescript/explicit-module-boundary-types": [2, {"allowArgumentsExplicitlyTypedAsAny": true}]
114
- "typescript/no-empty-object-type": [2, { "allowInterfaces": "always" }],
115
- "typescript/no-import-type-side-effects": 2,
116
- // "typescript/no-namespace": 2,
117
- "typescript/no-non-null-asserted-nullish-coalescing": 2,
118
- "typescript/no-require-imports": 2,
119
- "typescript/no-var-requires": 2,
120
- "typescript/no-unnecessary-template-expression": 2,
121
- "typescript/no-unnecessary-type-arguments": 0, // not good in the end
122
- "typescript/no-unnecessary-type-constraint": 2,
123
- // "typescript/no-unsafe-argument": 2, // looks good, but too strict for now
124
- // "typescript/no-dynamic-delete": 2,
125
- "typescript/prefer-optional-chain": 0, // buggy
126
- "typescript/non-nullable-type-assertion-style": 2,
127
- "typescript/prefer-literal-enum-member": 2,
128
- "typescript/prefer-reduce-type-parameter": 2,
129
- "typescript/promise-function-async": [
130
- 2,
131
- {
132
- "checkArrowFunctions": false,
133
- "checkFunctionDeclarations": true,
134
- "checkFunctionExpressions": true,
135
- "checkMethodDeclarations": true
136
- }
137
- ],
138
- "typescript/prefer-for-of": 2,
139
- "typescript/no-confusing-non-null-assertion": 2,
140
- "typescript/ban-ts-comment": [
141
- 2,
142
- {
143
- "minimumDescriptionLength": 2,
144
- "ts-expect-error": "allow-with-description",
145
- "ts-nocheck": "allow-with-description",
146
- "ts-check": false,
147
- "ts-ignore": true
148
- }
149
- ],
150
- "typescript/ban-tslint-comment": 2,
151
- "typescript/prefer-function-type": 2,
152
- "typescript/prefer-namespace-keyword": 2,
153
- "typescript/consistent-generic-constructors": [2, "constructor"],
154
- "typescript/consistent-type-definitions": [2, "interface"],
155
- "typescript/consistent-type-imports": 2,
156
- "typescript/consistent-type-assertions": [
157
- 2,
158
- {
159
- "assertionStyle": "as"
160
- }
161
- ],
162
- "typescript/no-inferrable-types": [
163
- 2,
164
- {
165
- "ignoreParameters": true
166
- }
167
- ],
168
- "typescript/adjacent-overload-signatures": 2,
169
- "typescript/array-type": 2,
170
- "typescript/prefer-enum-initializers": 2,
171
- "typescript/prefer-promise-reject-errors": 2,
172
- "typescript/prefer-ts-expect-error": 2,
173
- "typescript/require-await": 0, // not good yet
174
- "typescript/restrict-plus-operands": 2,
175
- "typescript/return-await": [2, "error-handling-correctness-only"],
176
- "typescript/only-throw-error": 2,
177
- "typescript/no-unsafe-function-type": 2,
178
- "typescript/no-misused-promises": [
179
- 2,
180
- {
181
- "checksVoidReturn": {
182
- // "variables": false,
183
- // "inheritedMethods": false,
184
- // "returns": false
185
- "arguments": false,
186
- "properties": false
187
- }
188
- }
189
- ],
190
- "typescript/no-mixed-enums": 2,
191
- "typescript/no-unnecessary-type-assertion": 2,
192
- "typescript/no-unnecessary-boolean-literal-compare": 2,
193
- "typescript/no-base-to-string": 2,
194
- // disabled, as it fails on legit unit test patterns
195
- "typescript/unbound-method": [
196
- 0,
197
- {
198
- "ignoreStatic": true
199
- }
200
- ],
201
- "typescript/switch-exhaustiveness-check": 0, // not good
202
- "typescript/require-array-sort-compare": 0, // not good
203
- "typescript/restrict-template-expressions": 0, // not good
204
- "typescript/no-redundant-type-constituents": 0, // `'a' | string` is still useful for DX
205
- "typescript/no-restricted-types": [
206
- 2,
207
- {
208
- "types": {
209
- "Boolean": {
210
- "message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
211
- },
212
- "Number": {
213
- "message": "Avoid using the `Number` type. Did you mean `number`?"
214
- },
215
- "object": {
216
- "message": "The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).\nConsider using `Record<string, any>` instead, as it allows you to more easily inspect and use the keys."
217
- },
218
- "Object": {
219
- "message": "Avoid using the `Object` type. Did you mean `object`? Consider using Record<string, any> instead"
220
- },
221
- "String": {
222
- "message": "Avoid using the `String` type. Did you mean `string`?"
223
- },
224
- "Symbol": {
225
- "message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
226
- }
227
- }
228
- }
229
- ],
230
- "unicorn/no-anonymous-default-export": 2,
231
- "unicorn/no-immediate-mutation": 2,
232
- "unicorn/no-array-reduce": 2,
233
- "unicorn/no-document-cookie": 2,
234
- "unicorn/no-length-as-slice-end": 2,
235
- "unicorn/no-magic-array-flat-depth": 2,
236
- "unicorn/prefer-modern-math-apis": 2,
237
- "unicorn/prefer-node-protocol": 2,
238
- "unicorn/require-module-specifiers": 2,
239
- "unicorn/require-module-attributes": 2,
240
- "unicorn/prefer-classlist-toggle": 2,
241
- "unicorn/no-unnecessary-array-splice-count": 2,
242
- "unicorn/no-useless-error-capture-stack-trace": 2,
243
- "unicorn/prefer-top-level-await": 2,
244
- "unicorn/prefer-class-fields": 2,
245
- "unicorn/consistent-assert": 2,
246
- "unicorn/consistent-date-clone": 2,
247
- "unicorn/consistent-empty-array-spread": 2,
248
- "unicorn/consistent-existence-index-check": 2,
249
- "unicorn/escape-case": 2,
250
- "unicorn/prefer-keyboard-event-key": 2,
251
- "unicorn/prefer-default-parameters": 2,
252
- "unicorn/no-console-spaces": 2,
253
- "unicorn/no-hex-escape": 2,
254
- "unicorn/no-instanceof-builtins": 2,
255
- "unicorn/no-lonely-if": 2,
256
- "unicorn/no-negation-in-equality-check": 2,
257
- "unicorn/no-new-buffer": 2,
258
- "unicorn/prefer-string-replace-all": 2,
259
- "unicorn/prefer-math-min-max": 2,
260
- "unicorn/prefer-code-point": 2,
261
- "unicorn/prefer-global-this": 2,
262
- "unicorn/error-message": 2,
263
- "unicorn/no-zero-fractions": 2,
264
- "unicorn/prefer-array-some": 2,
265
- "unicorn/prefer-math-trunc": 2,
266
- "unicorn/prefer-includes": 2,
267
- "unicorn/prefer-response-static-json": 2,
268
- "import/no-named-default": 2,
269
- "import/consistent-type-specifier-style": 2,
270
- "unicorn/no-new-array": 0, // it's actually ok
271
- "unicorn/catch-error-name": [
272
- 2,
273
- {
274
- "name": "err",
275
- "ignore": ["^err\\d*$", "^_"]
276
- }
277
- ],
278
- "unicorn/no-accessor-recursion": 2,
279
- "unicorn/prefer-string-slice": 2,
280
- "unicorn/no-unnecessary-array-flat-depth": 2,
281
- "unicorn/no-unnecessary-slice-end": 2,
282
- "unicorn/no-unreadable-array-destructuring": 2,
283
- "unicorn/no-unreadable-iife": 2,
284
- "unicorn/no-useless-collection-argument": 2,
285
- "unicorn/no-useless-promise-resolve-reject": 2,
286
- "unicorn/numeric-separators-style": [
287
- 2,
288
- {
289
- "binary": {
290
- "groupLength": 4,
291
- "minimumDigits": 0
292
- },
293
- "hexadecimal": {
294
- "groupLength": 2,
295
- "minimumDigits": 0
296
- },
297
- "number": {
298
- "groupLength": 3,
299
- "minimumDigits": 5
300
- },
301
- "octal": {
302
- "groupLength": 4,
303
- "minimumDigits": 0
304
- },
305
- "onlyIfContainsSeparator": true
306
- }
307
- ],
308
- "unicorn/prefer-add-event-listener": 2,
309
- "unicorn/prefer-array-index-of": 2,
310
- "unicorn/prefer-bigint-literals": 2,
311
- "unicorn/prefer-blob-reading-methods": 2,
312
- "unicorn/prefer-dom-node-append": 2,
313
- "unicorn/prefer-dom-node-dataset": 2,
314
- "unicorn/prefer-dom-node-remove": 2,
315
- "unicorn/prefer-dom-node-text-content": 2,
316
- "unicorn/prefer-event-target": 2,
317
- "unicorn/prefer-logical-operator-over-ternary": 2,
318
- "unicorn/prefer-modern-dom-apis": 2,
319
- "unicorn/prefer-native-coercion-functions": 2,
320
- "unicorn/prefer-object-from-entries": 2,
321
- "unicorn/prefer-optional-catch-binding": 2,
322
- "unicorn/prefer-reflect-apply": 2,
323
- "unicorn/prefer-string-raw": 2,
324
- "unicorn/prefer-string-trim-start-end": 2,
325
- "unicorn/prefer-type-error": 2,
326
- "unicorn/require-array-join-separator": 2,
327
- "unicorn/switch-case-braces": [2, "always"],
328
- "unicorn/text-encoding-identifier-case": [
329
- 2,
330
- {
331
- "withDash": false
332
- }
333
- ],
334
- "vitest/no-duplicate-hooks": 2,
335
- "vitest/consistent-vitest-vi": 2,
336
- "vitest/no-focused-tests": 2,
337
- "vitest/no-identical-title": 2,
338
- "vitest/no-test-return-statement": 2,
339
- "vitest/prefer-hooks-in-order": 2,
340
- "vitest/prefer-hooks-on-top": 2,
341
- "vitest/prefer-mock-promise-shorthand": 2,
342
- "vitest/prefer-to-have-length": 2,
343
- "vitest/require-to-throw-message": 2,
344
- "vitest/valid-describe-callback": 0,
345
- "vitest/valid-expect": 0,
346
- "vitest/no-import-node-test": 2,
347
- "vitest/no-mocks-import": 2,
348
- "vitest/prefer-spy-on": 2,
349
- "vitest/prefer-to-be": 2,
350
- "vitest/prefer-to-contain": 2,
351
- "vitest/consistent-test-filename": 2,
352
- "vitest/warn-todo": 0,
353
- "jest/consistent-test-it": [
354
- 2,
355
- {
356
- "fn": "test",
357
- "withinDescribe": "test"
358
- }
359
- ],
360
- "jest/max-nested-describe": [0, { "max": 4 }], // not good
361
- "jest/no-alias-methods": 2,
362
- "jest/prefer-mock-return-shorthand": 2,
363
- "vue/no-multiple-slot-args": 2,
364
- "vue/no-deprecated-destroyed-lifecycle": 2,
365
- "vue/define-emits-declaration": [2, "type-based"],
366
- "vue/define-props-declaration": 2
367
- },
368
- "settings": {
369
- "jsdoc": {
370
- "tagNamePreference": {
371
- "experimental": "experimental"
372
- }
373
- }
374
- }
375
- }