@frontify/eslint-config-basic 0.20.5 → 1.0.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.
Files changed (3) hide show
  1. package/eslint.config.mjs +433 -0
  2. package/package.json +32 -25
  3. package/index.js +0 -424
@@ -0,0 +1,433 @@
1
+ /* (c) Copyright Frontify Ltd., all rights reserved. */
2
+
3
+ // @ts-check
4
+
5
+ import eslint from '@eslint/js';
6
+ // @ts-expect-error No types available
7
+ import eslintPluginComments from '@eslint-community/eslint-plugin-eslint-comments/configs';
8
+ import eslintPluginStylistic from '@stylistic/eslint-plugin';
9
+ import eslintPluginImport from 'eslint-plugin-import';
10
+ import eslintPluginJsonc from 'eslint-plugin-jsonc';
11
+ // @ts-expect-error No types available
12
+ import eslintPluginLodash from 'eslint-plugin-lodash';
13
+ // @ts-expect-error No types available
14
+ import eslintPluginMarkdown from 'eslint-plugin-markdown';
15
+ // @ts-expect-error No types available
16
+ import eslintPluginNoOnlyTests from 'eslint-plugin-no-only-tests';
17
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
18
+ // @ts-expect-error No types available
19
+ import eslintPluginPromise from 'eslint-plugin-promise';
20
+ import eslintPluginRegexp from 'eslint-plugin-regexp';
21
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn';
22
+ import eslintPluginYml from 'eslint-plugin-yml';
23
+ import globals from 'globals';
24
+ import tseslint from 'typescript-eslint';
25
+
26
+ export default tseslint.config(
27
+ eslint.configs.recommended,
28
+ tseslint.configs.recommendedTypeChecked,
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
30
+ eslintPluginPromise.configs['flat/recommended'],
31
+ eslintPluginRegexp.configs['flat/recommended'],
32
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
33
+ eslintPluginComments.recommended,
34
+ eslintPluginJsonc.configs['flat/recommended-with-json'],
35
+ eslintPluginJsonc.configs['flat/prettier'],
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
37
+ eslintPluginMarkdown.configs.recommended,
38
+ eslintPluginYml.configs['flat/recommended'],
39
+ {
40
+ // General configuration for all files
41
+ linterOptions: {
42
+ reportUnusedDisableDirectives: true,
43
+ },
44
+ extends: [eslintPluginImport.flatConfigs.typescript],
45
+ plugins: {
46
+ // Where we want to customize few part and not use recommended
47
+ unicorn: eslintPluginUnicorn,
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
49
+ lodash: eslintPluginLodash,
50
+ '@stylistic': eslintPluginStylistic,
51
+ },
52
+ languageOptions: {
53
+ ecmaVersion: 'latest',
54
+ sourceType: 'module',
55
+ globals: {
56
+ ...globals.browser,
57
+ ...globals.node,
58
+ },
59
+ parserOptions: {
60
+ projectService: true,
61
+ },
62
+ },
63
+ settings: {
64
+ 'import/resolver': {
65
+ typescript: true,
66
+ node: true,
67
+ },
68
+ },
69
+ rules: {
70
+ // Eslint (base)
71
+ '@stylistic/linebreak-style': ['error', 'unix'],
72
+ '@stylistic/eol-last': ['error', 'always'],
73
+ 'prefer-template': 'error',
74
+ '@stylistic/template-curly-spacing': 'error',
75
+ 'no-var': 'error',
76
+ eqeqeq: 'error',
77
+ 'no-eval': 'error',
78
+ 'no-extra-bind': 'error',
79
+ curly: ['error', 'all'],
80
+ semi: ['error', 'always'],
81
+ quotes: ['error', 'single', { avoidEscape: true }],
82
+ 'vars-on-top': 'error',
83
+ 'block-scoped-var': 'error',
84
+ 'array-callback-return': 'error',
85
+ 'no-use-before-define': 'off',
86
+ 'object-shorthand': [
87
+ 'error',
88
+ 'always',
89
+ {
90
+ ignoreConstructors: false,
91
+ avoidQuotes: true,
92
+ },
93
+ ],
94
+ 'no-case-declarations': 'error',
95
+ 'no-multi-spaces': 'error',
96
+ 'no-multi-str': 'error',
97
+ 'no-void': 'error',
98
+ 'no-invalid-this': 'error',
99
+ 'require-await': 'off',
100
+ 'no-return-assign': 'off',
101
+ 'max-statements-per-line': ['error', { max: 1 }],
102
+ 'prefer-exponentiation-operator': 'error',
103
+ 'prefer-rest-params': 'error',
104
+ 'prefer-spread': 'error',
105
+ 'generator-star-spacing': 'off',
106
+ 'no-debugger': 'error',
107
+ 'no-constant-condition': 'warn',
108
+ 'object-curly-spacing': ['error', 'always'],
109
+ 'prefer-const': [
110
+ 'error',
111
+ {
112
+ destructuring: 'all',
113
+ ignoreReadBeforeAssign: true,
114
+ },
115
+ ],
116
+ 'no-unreachable': 'error',
117
+ 'no-unused-labels': 'error',
118
+ 'no-useless-computed-key': 'error',
119
+ 'no-useless-concat': 'error',
120
+ 'no-useless-escape': 'error',
121
+ 'no-useless-rename': [
122
+ 'error',
123
+ {
124
+ ignoreDestructuring: false,
125
+ ignoreImport: false,
126
+ ignoreExport: false,
127
+ },
128
+ ],
129
+ 'no-with': 'error',
130
+ 'no-whitespace-before-property': 'error',
131
+ 'no-undef': 'off', // Doesn't works well with TypeScript
132
+
133
+ // Comments
134
+ '@stylistic/spaced-comment': [
135
+ 'error',
136
+ 'always',
137
+ {
138
+ line: {
139
+ markers: ['/'],
140
+ exceptions: ['/', '#'],
141
+ },
142
+ block: {
143
+ markers: ['!'],
144
+ exceptions: ['*'],
145
+ balanced: true,
146
+ },
147
+ },
148
+ ],
149
+
150
+ // Eslint Import
151
+ 'import/no-unresolved': 'off',
152
+ 'import/no-internal-modules': 'off',
153
+ 'import/no-relative-parent-imports': 'off',
154
+ 'import/no-named-as-default': 'off',
155
+ 'import/exports-last': 'off',
156
+ 'import/no-namespace': 'off',
157
+ 'import/extensions': 'off',
158
+ 'import/namespace': 'off',
159
+ 'import/default': 'off',
160
+ 'import/order': [
161
+ 'error',
162
+ {
163
+ groups: [
164
+ // node builtin
165
+ 'builtin',
166
+ // npm libraries
167
+ 'external',
168
+ // same scope libraries
169
+ 'internal',
170
+ // parent imports
171
+ 'parent',
172
+ // siblings imports
173
+ 'sibling',
174
+ 'index',
175
+ 'object',
176
+ 'type',
177
+ ],
178
+ 'newlines-between': 'always',
179
+ alphabetize: {
180
+ order: 'asc',
181
+ caseInsensitive: false,
182
+ },
183
+ },
184
+ ],
185
+ 'import/prefer-default-export': 'off',
186
+ 'import/max-dependencies': 'off',
187
+ 'import/no-unassigned-import': 'off',
188
+ 'import/no-default-export': 'off',
189
+ 'import/no-named-export': 'off',
190
+ 'import/group-exports': 'off',
191
+ 'import/no-duplicates': ['error', { 'prefer-inline': true }],
192
+ 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
193
+
194
+ // Unicorn
195
+ // Pass error message when throwing errors
196
+ 'unicorn/error-message': 'error',
197
+ // Uppercase regex escapes
198
+ 'unicorn/escape-case': 'error',
199
+ // Array.isArray instead of instanceof
200
+ 'unicorn/no-instanceof-array': 'error',
201
+ // Prevent deprecated `new Buffer()`
202
+ 'unicorn/no-new-buffer': 'error',
203
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
204
+ 'unicorn/number-literal-case': 'error',
205
+ // use find when possible
206
+ 'unicorn/prefer-array-find': 'error',
207
+ // use default param instead of foo = foo || 'bar';
208
+ 'unicorn/prefer-default-parameters': 'error',
209
+ // includes over indexOf when checking for existence
210
+ 'unicorn/prefer-includes': 'error',
211
+ // String methods startsWith/endsWith instead of more complicated stuff
212
+ 'unicorn/prefer-string-starts-ends-with': 'error',
213
+ // Use replaceAll instead of replace with regex
214
+ 'unicorn/prefer-string-replace-all': 'error',
215
+ // textContent instead of innerText
216
+ 'unicorn/prefer-dom-node-text-content': 'error',
217
+ // Enforce throwing type error when throwing error while checking typeof
218
+ 'unicorn/prefer-type-error': 'error',
219
+ // Use new when throwing error
220
+ 'unicorn/throw-new-error': 'error',
221
+ // Prefer using the `node:` protocol
222
+ 'unicorn/prefer-node-protocol': 'error',
223
+ 'unicorn/no-array-for-each': 'error',
224
+ 'unicorn/custom-error-definition': 'error',
225
+ 'unicorn/explicit-length-check': 'error',
226
+ 'unicorn/no-await-expression-member': 'error',
227
+ 'unicorn/no-nested-ternary': 'off', // Conflict with prettier
228
+ 'unicorn/no-new-array': 'error',
229
+ 'unicorn/no-this-assignment': 'error',
230
+ 'unicorn/no-useless-length-check': 'error',
231
+ 'unicorn/catch-error-name': 'error',
232
+
233
+ // Eslint Promise
234
+ 'promise/param-names': 'error',
235
+ },
236
+ },
237
+ {
238
+ // TypeScript files
239
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
240
+ rules: {
241
+ // As we're using @typescript-eslint it's recommended to turn off
242
+ // the standard eslint rule for unused variables and use the @typescript-eslint rule instead.
243
+ // See here: https://typescript-eslint.io/rules/no-unused-vars/
244
+ 'no-unused-vars': 'off',
245
+ '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
246
+
247
+ // Allow overload of functions: https://typescript-eslint.io/rules/no-dupe-class-members/
248
+ 'no-dupe-class-members': 'off',
249
+ '@typescript-eslint/no-dupe-class-members': 'error',
250
+
251
+ '@typescript-eslint/no-explicit-any': 'warn',
252
+ 'no-implied-eval': 'off',
253
+ '@typescript-eslint/no-implied-eval': 'error',
254
+ 'dot-notation': 'off',
255
+ '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
256
+ '@typescript-eslint/await-thenable': 'error',
257
+ '@typescript-eslint/no-for-in-array': 'error',
258
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
259
+ '@typescript-eslint/no-unsafe-argument': 'error',
260
+ '@typescript-eslint/no-unsafe-call': 'error',
261
+ '@typescript-eslint/no-unsafe-return': 'error',
262
+ 'require-await': 'off',
263
+ '@typescript-eslint/require-await': 'error',
264
+ '@typescript-eslint/restrict-plus-operands': 'error',
265
+ '@typescript-eslint/restrict-template-expressions': 'error',
266
+ '@typescript-eslint/unbound-method': 'off',
267
+ '@typescript-eslint/consistent-type-imports': [
268
+ 'error',
269
+ { prefer: 'type-imports', fixStyle: 'inline-type-imports' },
270
+ ],
271
+ '@typescript-eslint/no-misused-promises': [2, { checksVoidReturn: { attributes: false } }],
272
+ },
273
+ },
274
+ {
275
+ // JSON files
276
+ files: ['**/*.json'],
277
+ extends: [tseslint.configs.disableTypeChecked],
278
+ rules: {
279
+ quotes: ['error', 'double'],
280
+ 'quote-props': ['error', 'always'],
281
+ 'comma-dangle': ['error', 'never'],
282
+ semi: 'off',
283
+ 'jsonc/array-bracket-spacing': ['error', 'never'],
284
+ 'jsonc/comma-dangle': ['error', 'never'],
285
+ 'jsonc/comma-style': ['error', 'last'],
286
+ 'jsonc/key-spacing': ['error', { beforeColon: false, afterColon: true }],
287
+ 'jsonc/no-octal-escape': 'error',
288
+ 'jsonc/object-curly-newline': ['error', { multiline: true, consistent: true }],
289
+ 'jsonc/object-curly-spacing': ['error', 'always'],
290
+ 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
291
+ 'jsonc/no-dupe-keys': 'error',
292
+ 'jsonc/sort-keys': ['warn', 'asc'],
293
+ },
294
+ },
295
+ {
296
+ // YAML files rules
297
+ files: ['**/*.yaml', '**/*.yml'],
298
+ extends: [tseslint.configs.disableTypeChecked],
299
+ rules: {
300
+ 'spaced-comment': 'off',
301
+ 'yml/quotes': ['error', { prefer: 'single', avoidEscape: false }],
302
+ 'yml/no-empty-document': 'off',
303
+ 'yml/indent': ['error', 4, { indicatorValueIndent: 2 }],
304
+ },
305
+ },
306
+ {
307
+ // package.json rules
308
+ files: ['package.json'],
309
+ extends: [tseslint.configs.disableTypeChecked],
310
+ rules: {
311
+ 'jsonc/sort-keys': [
312
+ 'error',
313
+ {
314
+ pathPattern: '^$',
315
+ order: [
316
+ 'publisher',
317
+ 'name',
318
+ 'displayName',
319
+ 'type',
320
+ 'version',
321
+ 'private',
322
+ 'packageManager',
323
+ 'description',
324
+ 'author',
325
+ 'license',
326
+ 'funding',
327
+ 'homepage',
328
+ 'repository',
329
+ 'bugs',
330
+ 'keywords',
331
+ 'categories',
332
+ 'sideEffects',
333
+ 'exports',
334
+ 'main',
335
+ 'module',
336
+ 'unpkg',
337
+ 'jsdelivr',
338
+ 'types',
339
+ 'typesVersions',
340
+ 'bin',
341
+ 'icon',
342
+ 'files',
343
+ 'engines',
344
+ 'activationEvents',
345
+ 'contributes',
346
+ 'scripts',
347
+ 'peerDependencies',
348
+ 'peerDependenciesMeta',
349
+ 'dependencies',
350
+ 'optionalDependencies',
351
+ 'devDependencies',
352
+ 'pnpm',
353
+ 'overrides',
354
+ 'resolutions',
355
+ 'eslintConfig',
356
+ ],
357
+ },
358
+ {
359
+ pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
360
+ order: { type: 'asc' },
361
+ },
362
+ {
363
+ pathPattern: '^exports.*$',
364
+ order: ['types', 'require', 'import'],
365
+ },
366
+ ],
367
+ },
368
+ },
369
+ {
370
+ // d.ts files
371
+ files: ['**/*.d.ts'],
372
+ rules: {
373
+ 'import/no-duplicates': 'off',
374
+ },
375
+ },
376
+ {
377
+ // Scripts and cli files
378
+ files: ['scripts/**/*', 'cli/**/*'],
379
+ rules: {
380
+ 'no-console': 'off',
381
+ },
382
+ },
383
+ {
384
+ // Test files
385
+ files: [
386
+ '**/*.test.ts',
387
+ '**/*.test.tsx',
388
+ '**/*.test.js',
389
+ '**/*.test.jsx',
390
+ '**/*.spec.ts',
391
+ '**/*.spec.tsx',
392
+ '**/*.spec.js',
393
+ '**/*.spec.jsx',
394
+ '**/*.spec.cy.ts',
395
+ '**/*.spec.cy.tsx',
396
+ '**/*.spec.cy.js',
397
+ '**/*.spec.cy.jsx',
398
+ '**/*.spec.ct.ts',
399
+ '**/*.spec.ct.tsx',
400
+ '**/*.spec.ct.js',
401
+ '**/*.spec.ct.jsx',
402
+ ],
403
+ plugins: {
404
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
405
+ 'no-only-tests': eslintPluginNoOnlyTests,
406
+ },
407
+ rules: {
408
+ 'no-unused-expressions': 'off',
409
+ 'no-only-tests/no-only-tests': 'error',
410
+ '@typescript-eslint/unbound-method': 'off', // Allows to use `vi.fn()` or spy/mock in tests
411
+ },
412
+ },
413
+ {
414
+ ignores: [
415
+ '.next',
416
+ '*.min.*',
417
+ '*.d.ts',
418
+ 'CHANGELOG.md',
419
+ 'dist',
420
+ 'LICENSE*',
421
+ 'output',
422
+ 'out',
423
+ 'coverage',
424
+ 'public',
425
+ 'temp',
426
+ 'package-lock.json',
427
+ 'pnpm-lock.yaml',
428
+ 'yarn.lock',
429
+ '__snapshots__',
430
+ ],
431
+ },
432
+ eslintPluginPrettierRecommended,
433
+ );
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@frontify/eslint-config-basic",
3
- "version": "0.20.5",
3
+ "type": "module",
4
+ "version": "1.0.0",
4
5
  "author": "Frontify Developers <developers@frontify.com>",
5
6
  "license": "MIT",
6
7
  "repository": {
@@ -8,39 +9,45 @@
8
9
  "url": "https://github.com/Frontify/eslint-config",
9
10
  "directory": "packages/basic"
10
11
  },
11
- "main": "index.js",
12
- "files": [
13
- "index.js"
14
- ],
15
12
  "publishConfig": {
16
13
  "access": "public"
17
14
  },
15
+ "main": "eslint.config.mjs",
16
+ "files": [
17
+ "eslint.config.mjs"
18
+ ],
18
19
  "peerDependencies": {
19
- "eslint": "^8.56.0",
20
- "prettier": "^3.0.0"
20
+ "eslint": "^9.0.0",
21
+ "prettier": "^3.0.0",
22
+ "typescript": "^5.0.0"
21
23
  },
22
24
  "dependencies": {
23
- "@typescript-eslint/eslint-plugin": "^7.4.0",
24
- "@typescript-eslint/parser": "^7.4.0",
25
- "eslint-config-prettier": "^9.1.0",
26
- "eslint-import-resolver-typescript": "^3.6.1",
27
- "eslint-plugin-eslint-comments": "^3.2.0",
28
- "eslint-plugin-import": "^2.29.1",
29
- "eslint-plugin-jsonc": "^2.14.1",
30
- "eslint-plugin-lodash": "^7.4.0",
31
- "eslint-plugin-markdown": "^4.0.1",
32
- "eslint-plugin-no-only-tests": "^3.1.0",
33
- "eslint-plugin-prettier": "^5.1.3",
34
- "eslint-plugin-promise": "^6.1.1",
35
- "eslint-plugin-unicorn": "^51.0.1",
36
- "eslint-plugin-yml": "^1.13.2",
37
- "yaml-eslint-parser": "^1.2.2"
25
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
26
+ "@stylistic/eslint-plugin": "^5.2.3",
27
+ "@typescript-eslint/eslint-plugin": "^8.39.0",
28
+ "@typescript-eslint/parser": "^8.39.0",
29
+ "eslint-config-prettier": "^10.1.8",
30
+ "eslint-import-resolver-typescript": "^4.4.4",
31
+ "eslint-plugin-import": "^2.32.0",
32
+ "eslint-plugin-jsonc": "^2.20.1",
33
+ "eslint-plugin-lodash": "^8.0.0",
34
+ "eslint-plugin-markdown": "^5.1.0",
35
+ "eslint-plugin-no-only-tests": "^3.3.0",
36
+ "eslint-plugin-prettier": "^5.5.4",
37
+ "eslint-plugin-promise": "^7.2.1",
38
+ "eslint-plugin-regexp": "^2.10.0",
39
+ "eslint-plugin-unicorn": "^60.0.0",
40
+ "eslint-plugin-yml": "^1.18.0",
41
+ "globals": "^16.3.0",
42
+ "typescript-eslint": "^8.39.0",
43
+ "yaml-eslint-parser": "^1.3.0"
38
44
  },
39
45
  "devDependencies": {
40
- "eslint": "^8.57.0",
41
- "prettier": "^3.2.5"
46
+ "eslint": "^9.32.0",
47
+ "prettier": "^3.6.2",
48
+ "typescript": "^5.9.2"
42
49
  },
43
50
  "scripts": {
44
- "lint": "eslint . --config=index.js"
51
+ "lint": "eslint ."
45
52
  }
46
53
  }
package/index.js DELETED
@@ -1,424 +0,0 @@
1
- /* (c) Copyright Frontify Ltd., all rights reserved. */
2
-
3
- module.exports = {
4
- reportUnusedDisableDirectives: true,
5
- env: {
6
- es6: true,
7
- browser: true,
8
- node: true,
9
- },
10
- plugins: ['@typescript-eslint', 'unicorn', 'no-only-tests', 'promise', 'lodash', 'prettier'],
11
- extends: [
12
- 'eslint:recommended',
13
- 'plugin:@typescript-eslint/recommended',
14
- 'plugin:@typescript-eslint/recommended-type-checked',
15
- 'plugin:eslint-comments/recommended',
16
- 'plugin:jsonc/recommended-with-json',
17
- 'plugin:yml/standard',
18
- 'plugin:markdown/recommended-legacy',
19
- 'plugin:import/recommended',
20
- 'plugin:import/typescript',
21
- 'prettier',
22
- ],
23
- ignorePatterns: [
24
- '.next',
25
- '*.min.*',
26
- '*.d.ts',
27
- 'CHANGELOG.md',
28
- 'dist',
29
- 'LICENSE*',
30
- 'output',
31
- 'out',
32
- 'coverage',
33
- 'public',
34
- 'temp',
35
- 'package-lock.json',
36
- 'pnpm-lock.yaml',
37
- 'yarn.lock',
38
- '__snapshots__',
39
- ],
40
- parserOptions: {
41
- project: true,
42
- },
43
- parser: '@typescript-eslint/parser',
44
- settings: {
45
- 'import/resolver': {
46
- typescript: true,
47
- node: true,
48
- },
49
- 'import/parsers': {
50
- '@typescript-eslint/parser': ['.ts', '.tsx'],
51
- },
52
- },
53
- overrides: [
54
- {
55
- excludedFiles: ['**/*.md/*.*'],
56
- files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
57
- parserOptions: {
58
- project: true,
59
- },
60
- parser: '@typescript-eslint/parser',
61
- rules: {
62
- // As we're using @typescript-eslint it's recommended to turn off
63
- // the standard eslint rule for unused variables and use the @typescript-eslint rule instead.
64
- // See here: https://typescript-eslint.io/rules/no-unused-vars/
65
- 'no-unused-vars': 'off',
66
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
67
-
68
- // Allow overload of functions: https://typescript-eslint.io/rules/no-dupe-class-members/
69
- 'no-dupe-class-members': 'off',
70
- '@typescript-eslint/no-dupe-class-members': 'error',
71
-
72
- '@typescript-eslint/no-explicit-any': 'warn',
73
- 'no-implied-eval': 'off',
74
- '@typescript-eslint/no-implied-eval': 'error',
75
- 'dot-notation': 'off',
76
- '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
77
- '@typescript-eslint/await-thenable': 'error',
78
- '@typescript-eslint/no-for-in-array': 'error',
79
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
80
- '@typescript-eslint/no-unsafe-argument': 'error',
81
- '@typescript-eslint/no-unsafe-call': 'error',
82
- '@typescript-eslint/no-unsafe-return': 'error',
83
- 'require-await': 'off',
84
- '@typescript-eslint/require-await': 'error',
85
- '@typescript-eslint/restrict-plus-operands': 'error',
86
- '@typescript-eslint/restrict-template-expressions': 'error',
87
- '@typescript-eslint/unbound-method': 'off',
88
- '@typescript-eslint/consistent-type-imports': [
89
- 'error',
90
- { prefer: 'type-imports', fixStyle: 'inline-type-imports' },
91
- ],
92
- '@typescript-eslint/no-misused-promises': [2, { checksVoidReturn: { attributes: false } }],
93
- },
94
- },
95
- {
96
- files: ['*.json'],
97
- extends: ['plugin:@typescript-eslint/disable-type-checked'],
98
- parser: 'jsonc-eslint-parser',
99
- rules: {
100
- quotes: ['error', 'double'],
101
- 'quote-props': ['error', 'always'],
102
- 'comma-dangle': ['error', 'never'],
103
- semi: 'off',
104
- 'jsonc/array-bracket-spacing': ['error', 'never'],
105
- 'jsonc/comma-dangle': ['error', 'never'],
106
- 'jsonc/comma-style': ['error', 'last'],
107
- 'jsonc/key-spacing': ['error', { beforeColon: false, afterColon: true }],
108
- 'jsonc/no-octal-escape': 'error',
109
- 'jsonc/object-curly-newline': ['error', { multiline: true, consistent: true }],
110
- 'jsonc/object-curly-spacing': ['error', 'always'],
111
- 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
112
- },
113
- },
114
- {
115
- files: ['*.yaml', '*.yml'],
116
- parser: 'yaml-eslint-parser',
117
- rules: {
118
- 'spaced-comment': 'off',
119
- 'yml/quotes': ['error', { prefer: 'single', avoidEscape: false }],
120
- 'yml/no-empty-document': 'off',
121
- 'yml/indent': ['error', 4, { indicatorValueIndent: 2 }],
122
- },
123
- },
124
- {
125
- files: ['package.json'],
126
- parser: 'jsonc-eslint-parser',
127
- extends: ['plugin:@typescript-eslint/disable-type-checked'],
128
- rules: {
129
- 'jsonc/sort-keys': [
130
- 'error',
131
- {
132
- pathPattern: '^$',
133
- order: [
134
- 'publisher',
135
- 'name',
136
- 'displayName',
137
- 'type',
138
- 'version',
139
- 'private',
140
- 'packageManager',
141
- 'description',
142
- 'author',
143
- 'license',
144
- 'funding',
145
- 'homepage',
146
- 'repository',
147
- 'bugs',
148
- 'keywords',
149
- 'categories',
150
- 'sideEffects',
151
- 'exports',
152
- 'main',
153
- 'module',
154
- 'unpkg',
155
- 'jsdelivr',
156
- 'types',
157
- 'typesVersions',
158
- 'bin',
159
- 'icon',
160
- 'files',
161
- 'engines',
162
- 'activationEvents',
163
- 'contributes',
164
- 'scripts',
165
- 'peerDependencies',
166
- 'peerDependenciesMeta',
167
- 'dependencies',
168
- 'optionalDependencies',
169
- 'devDependencies',
170
- 'pnpm',
171
- 'overrides',
172
- 'resolutions',
173
- 'eslintConfig',
174
- ],
175
- },
176
- {
177
- pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
178
- order: { type: 'asc' },
179
- },
180
- {
181
- pathPattern: '^exports.*$',
182
- order: ['types', 'require', 'import'],
183
- },
184
- ],
185
- },
186
- },
187
- {
188
- files: ['*.js', '*.cjs', '*.jsx'],
189
- rules: {
190
- '@typescript-eslint/no-var-requires': 'off',
191
- '@typescript-eslint/no-require-imports': 'off',
192
- },
193
- },
194
- {
195
- files: ['*.d.ts'],
196
- rules: {
197
- 'import/no-duplicates': 'off',
198
- },
199
- },
200
- {
201
- files: ['scripts/**/*.*', 'cli/**/*.*'],
202
- rules: {
203
- 'no-console': 'off',
204
- },
205
- },
206
- {
207
- files: [
208
- '*.test.ts',
209
- '*.test.tsx',
210
- '*.test.js',
211
- '*.test.jsx',
212
- '*.spec.ts',
213
- '*.spec.tsx',
214
- '*.spec.js',
215
- '*.spec.jsx',
216
- '*.spec.cy.ts',
217
- '*.spec.cy.tsx',
218
- '*.spec.cy.js',
219
- '*.spec.cy.jsx',
220
- '*.spec.ct.ts',
221
- '*.spec.ct.tsx',
222
- '*.spec.ct.js',
223
- '*.spec.ct.jsx',
224
- ],
225
- rules: {
226
- 'no-unused-expressions': 'off',
227
- 'no-only-tests/no-only-tests': 'error',
228
- '@typescript-eslint/unbound-method': 'off', // Allows to use `vi.fn()` or spy/mock in tests
229
- },
230
- },
231
- {
232
- // Code blocks in markdown file
233
- files: ['**/*.md/*.*'],
234
- rules: {
235
- '@typescript-eslint/no-redeclare': 'off',
236
- '@typescript-eslint/no-unused-vars': 'off',
237
- '@typescript-eslint/no-use-before-define': 'off',
238
- '@typescript-eslint/no-var-requires': 'off',
239
- '@typescript-eslint/comma-dangle': 'off',
240
- '@typescript-eslint/consistent-type-imports': 'off',
241
- 'import/no-unresolved': 'off',
242
- 'unused-imports/no-unused-imports': 'off',
243
- 'unused-imports/no-unused-vars': 'off',
244
- 'no-alert': 'off',
245
- 'no-console': 'off',
246
- 'no-restricted-imports': 'off',
247
- 'no-unused-expressions': 'off',
248
- 'no-unused-vars': 'off',
249
- },
250
- },
251
- ],
252
- rules: {
253
- // Eslint prettier
254
- 'prettier/prettier': 'error',
255
- 'arrow-body-style': 'off', // Problematic with Prettier
256
-
257
- // Eslint (base)
258
- 'linebreak-style': ['error', 'unix'],
259
- 'prefer-template': 'error',
260
- 'template-curly-spacing': 'error',
261
- 'no-var': 'error',
262
- eqeqeq: 'error',
263
- 'no-eval': 'error',
264
- 'no-extra-bind': 'error',
265
- curly: ['error', 'all'],
266
- semi: ['error', 'always'],
267
- quotes: ['error', 'single', { avoidEscape: true }],
268
- 'vars-on-top': 'error',
269
- 'block-scoped-var': 'error',
270
- 'array-callback-return': 'error',
271
- 'no-use-before-define': 'off',
272
- 'object-shorthand': [
273
- 'error',
274
- 'always',
275
- {
276
- ignoreConstructors: false,
277
- avoidQuotes: true,
278
- },
279
- ],
280
- 'no-case-declarations': 'error',
281
- 'no-multi-spaces': 'error',
282
- 'no-multi-str': 'error',
283
- 'no-void': 'error',
284
- 'no-invalid-this': 'error',
285
- 'require-await': 'off',
286
- 'no-return-assign': 'off',
287
- 'max-statements-per-line': ['error', { max: 1 }],
288
- 'prefer-exponentiation-operator': 'error',
289
- 'prefer-rest-params': 'error',
290
- 'prefer-spread': 'error',
291
- 'generator-star-spacing': 'off',
292
- 'no-debugger': 'error',
293
- 'no-constant-condition': 'warn',
294
- 'object-curly-spacing': ['error', 'always'],
295
- 'prefer-const': [
296
- 'error',
297
- {
298
- destructuring: 'all',
299
- ignoreReadBeforeAssign: true,
300
- },
301
- ],
302
- 'prefer-arrow-callback': [
303
- 'error',
304
- {
305
- allowNamedFunctions: false,
306
- allowUnboundThis: true,
307
- },
308
- ],
309
- 'no-unreachable': 'error',
310
- 'no-unused-labels': 'error',
311
- 'no-useless-computed-key': 'error',
312
- 'no-useless-concat': 'error',
313
- 'no-useless-escape': 'error',
314
- 'no-useless-rename': [
315
- 'error',
316
- {
317
- ignoreDestructuring: false,
318
- ignoreImport: false,
319
- ignoreExport: false,
320
- },
321
- ],
322
- 'no-with': 'error',
323
- 'no-whitespace-before-property': 'error',
324
- 'no-undef': 'off', // Doesn't works well with TypeScript
325
-
326
- // Eslint Comments
327
- 'spaced-comment': [
328
- 'error',
329
- 'always',
330
- {
331
- line: {
332
- markers: ['/'],
333
- exceptions: ['/', '#'],
334
- },
335
- block: {
336
- markers: ['!'],
337
- exceptions: ['*'],
338
- balanced: true,
339
- },
340
- },
341
- ],
342
-
343
- // Eslint Import
344
- 'import/no-unresolved': 'off',
345
- 'import/no-internal-modules': 'off',
346
- 'import/no-relative-parent-imports': 'off',
347
- 'import/no-named-as-default': 'off',
348
- 'import/exports-last': 'off',
349
- 'import/no-namespace': 'off',
350
- 'import/extensions': 'off',
351
- 'import/namespace': 'off',
352
- 'import/default': 'off',
353
- 'import/order': [
354
- 'error',
355
- {
356
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
357
- 'newlines-between': 'always',
358
- alphabetize: {
359
- order: 'asc',
360
- caseInsensitive: false,
361
- },
362
- },
363
- ],
364
- 'import/prefer-default-export': 'off',
365
- 'import/max-dependencies': 'off',
366
- 'import/no-unassigned-import': 'off',
367
- 'import/no-default-export': 'off',
368
- 'import/no-named-export': 'off',
369
- 'import/group-exports': 'off',
370
- 'import/no-duplicates': ['error', { 'prefer-inline': true }],
371
- 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
372
-
373
- // Unicorn
374
- // Pass error message when throwing errors
375
- 'unicorn/error-message': 'error',
376
- // Uppercase regex escapes
377
- 'unicorn/escape-case': 'error',
378
- // Array.isArray instead of instanceof
379
- 'unicorn/no-instanceof-array': 'error',
380
- // Prevent deprecated `new Buffer()`
381
- 'unicorn/no-new-buffer': 'error',
382
- // Keep regex literals safe!
383
- 'unicorn/no-unsafe-regex': 'error',
384
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
385
- 'unicorn/number-literal-case': 'error',
386
- // use find when possible
387
- 'unicorn/prefer-array-find': 'error',
388
- // use default param instead of foo = foo || 'bar';
389
- 'unicorn/prefer-default-parameters': 'error',
390
- // includes over indexOf when checking for existence
391
- 'unicorn/prefer-includes': 'error',
392
- // String methods startsWith/endsWith instead of more complicated stuff
393
- 'unicorn/prefer-string-starts-ends-with': 'error',
394
- // Use replaceAll instead of replace with regex
395
- 'unicorn/prefer-string-replace-all': 'error',
396
- // textContent instead of innerText
397
- 'unicorn/prefer-text-content': 'error',
398
- // Enforce throwing type error when throwing error while checking typeof
399
- 'unicorn/prefer-type-error': 'error',
400
- // Use new when throwing error
401
- 'unicorn/throw-new-error': 'error',
402
- // Prefer using the `node:` protocol
403
- 'unicorn/prefer-node-protocol': 'error',
404
- 'unicorn/no-array-for-each': 'error',
405
- 'unicorn/custom-error-definition': 'error',
406
- 'unicorn/better-regex': 'error',
407
- 'unicorn/explicit-length-check': 'error',
408
- 'unicorn/no-await-expression-member': 'error',
409
- 'unicorn/no-nested-ternary': 'off', // Conflict with prettier
410
- 'unicorn/no-new-array': 'error',
411
- 'unicorn/no-this-assignment': 'error',
412
- 'unicorn/no-useless-length-check': 'error',
413
- 'unicorn/catch-error-name': 'error',
414
-
415
- // Eslint Promise
416
- 'promise/param-names': 'error',
417
-
418
- // Eslint Jsonc
419
- 'jsonc/no-dupe-keys': 'error',
420
-
421
- // Eslint Lodash
422
- 'lodash/import-scope': [2, 'method'],
423
- },
424
- };