@remcohaszing/eslint 11.2.0 → 12.0.1

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.
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  > A strict ESLint configuration
4
4
 
5
- [![build status](https://github.com/remcohaszing/@remcohaszing/eslint/workflows/ci/badge.svg)](https://github.com/remcohaszing/@remcohaszing/eslint/actions)
6
- [![codecov](https://codecov.io/gh/remcohaszing/@remcohaszing/eslint/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/@remcohaszing/eslint)
5
+ [![build status](https://github.com/remcohaszing/eslint/workflows/ci/badge.svg)](https://github.com/remcohaszing/eslint/actions)
6
+ [![codecov](https://codecov.io/gh/remcohaszing/eslint/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/eslint)
7
7
  [![npm](https://img.shields.io/npm/v/@remcohaszing/eslint)](https://www.npmjs.com/package/@remcohaszing/eslint)
8
8
  [![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
9
9
 
@@ -74,9 +74,9 @@ enabled. Unfortunately, this makes ESLint slow. Enabling these rules is recommen
74
74
  projects only. To enable this, add the following to `eslint.config.js`:
75
75
 
76
76
  ```js
77
- import config, { typechecking } from '@remcohaszing/eslint'
77
+ import { define, typechecking } from '@remcohaszing/eslint'
78
78
 
79
- export default [...config, ...typechecking]
79
+ export default define(typechecking)
80
80
  ```
81
81
 
82
82
  ### Markdown
@@ -96,16 +96,15 @@ Rules can be disabled by adding an extra ESLint configuration item to the config
96
96
  example:
97
97
 
98
98
  ```js
99
- import config from '@remcohaszing/eslint'
99
+ import { define } from '@remcohaszing/eslint'
100
100
 
101
- export default [
102
- ...config,
101
+ export default define([
103
102
  {
104
103
  rules: {
105
104
  'no-console': 'off'
106
105
  }
107
106
  }
108
- ]
107
+ ])
109
108
  ```
110
109
 
111
110
  ## Ignored files
@@ -115,7 +114,7 @@ the patterns from `.gitignore`.
115
114
 
116
115
  ## Warnings
117
116
 
118
- All ESLint that are turned on will trigger error, not warnings. The notable exceptions is
117
+ All ESLint that are turned on will trigger error, not warnings. The notable exception is
119
118
  `@typescript-eslint/no-deprecated`.
120
119
 
121
120
  This is to allow a smooth migration if a dependency decides to deprecate an API. To turn make
package/lib/config.js CHANGED
@@ -2,6 +2,9 @@
2
2
  * @import {Linter} from 'eslint'
3
3
  */
4
4
 
5
+ import { dirname, join } from 'node:path'
6
+
7
+ import { includeIgnoreFile } from '@eslint/compat'
5
8
  import markdown from '@eslint/markdown'
6
9
  // @ts-expect-error
7
10
  import eslintCommunityEslintComments from '@eslint-community/eslint-plugin-eslint-comments'
@@ -19,11 +22,68 @@ import perfectionist from 'eslint-plugin-perfectionist'
19
22
  import { Alphabet } from 'eslint-plugin-perfectionist/alphabet'
20
23
  import prettier from 'eslint-plugin-prettier'
21
24
  import unicorn from 'eslint-plugin-unicorn'
25
+ import findUp from 'find-up'
22
26
  import globals from 'globals'
23
27
 
24
- import { allowedProperties } from './allowedProperties.js'
25
- import { typesOnlyPackages } from './constants.js'
26
- import { getIgnorePatterns } from './getIgnorePatterns.js'
28
+ /**
29
+ * These property names are allowed, because exist in commonly used specifications.
30
+ */
31
+ const allowedProperties = [
32
+ // OAuth2
33
+ 'access_token',
34
+ 'client_id',
35
+ 'client_secret',
36
+ 'error_description',
37
+ 'error_uri',
38
+ 'expires_in',
39
+ 'grant_type',
40
+ 'redirect_uri',
41
+ 'refresh_token',
42
+ 'response_type',
43
+ 'token_type',
44
+
45
+ // OpenID
46
+ 'email_verified',
47
+ 'id_token',
48
+
49
+ // Web app manifest
50
+ 'background_color',
51
+ 'iarc_rating_id',
52
+ 'short_name',
53
+ 'prefer_related_applications',
54
+ 'related_applications',
55
+ 'start_url',
56
+ 'theme_color',
57
+
58
+ // React
59
+ '__html'
60
+ ]
61
+
62
+ /**
63
+ * Known packages that export only type definitions, but which don’t contain a JavaScript file.
64
+ */
65
+ const typesOnlyPackages = ['@fortawesome/fontawesome-common-types']
66
+
67
+ /**
68
+ * Determine the default ignore pattern based on `.gitignore`.
69
+ *
70
+ * @returns {Linter.Config}
71
+ * An array of ignore patterns accepted in an ESLint configuration.
72
+ */
73
+ function getIgnorePatterns() {
74
+ const gitDir = findUp.sync('.git', { type: 'directory' })
75
+
76
+ if (!gitDir) {
77
+ return {}
78
+ }
79
+
80
+ const gitIgnorePath = join(dirname(gitDir), '.gitignore')
81
+ try {
82
+ return includeIgnoreFile(gitIgnorePath)
83
+ } catch {
84
+ return {}
85
+ }
86
+ }
27
87
 
28
88
  const restrictedImports = [
29
89
  { name: 'node:assert', message: 'Use node:assert/strict instead.' },
@@ -67,7 +127,7 @@ const NON_COMPONENT_FUNCTION = 'FunctionDeclaration[id.name=/^[a-z]/]'
67
127
  const METHOD_DEFINITION = 'MethodDefinition'
68
128
 
69
129
  const config = defineConfig([
70
- getIgnorePatterns() ?? {},
130
+ getIgnorePatterns(),
71
131
  {
72
132
  name: 'base',
73
133
  languageOptions: {
@@ -198,7 +258,7 @@ const config = defineConfig([
198
258
  'always',
199
259
  {
200
260
  ignoreConsecutiveComments: true,
201
- ignorePattern: /^\s*(c8|type-coverage:|webpack\w)/.source
261
+ ignorePattern: /^\s*(c8|type-coverage:|webpack\w|([\w.-]+\.\w+$))/.source
202
262
  }
203
263
  ],
204
264
  'class-methods-use-this': 'error',
@@ -238,7 +298,7 @@ const config = defineConfig([
238
298
  'no-dupe-else-if': 'error',
239
299
  'no-dupe-keys': 'error',
240
300
  'no-duplicate-case': 'error',
241
- 'no-duplicate-imports': ['error', { includeExports: true }],
301
+ 'no-duplicate-imports': ['error', { allowSeparateTypeImports: true, includeExports: true }],
242
302
  'no-else-return': ['error', { allowElseIf: false }],
243
303
  'no-empty': 'error',
244
304
  'no-empty-character-class': 'error',
@@ -320,6 +380,7 @@ const config = defineConfig([
320
380
  'no-shadow-restricted-names': 'error',
321
381
  'no-this-before-super': 'error',
322
382
  'no-throw-literal': 'error',
383
+ 'no-unassigned-vars': 'error',
323
384
  'no-undef': 'error',
324
385
  'no-undef-init': 'error',
325
386
  'no-underscore-dangle': 'error',
@@ -420,7 +481,30 @@ const config = defineConfig([
420
481
  ],
421
482
  '@stylistic/multiline-comment-style': ['error', 'separate-lines'],
422
483
  '@stylistic/no-tabs': ['error', { allowIndentationTabs: true }],
423
- '@stylistic/padding-line-between-statements': 'error',
484
+ '@stylistic/padding-line-between-statements': [
485
+ 'error',
486
+ {
487
+ blankLine: 'always',
488
+ prev: ['cjs-import', 'import'],
489
+ next: '*'
490
+ },
491
+ {
492
+ blankLine: 'any',
493
+ prev: ['cjs-import', 'import'],
494
+ next: ['cjs-import', 'import']
495
+ },
496
+
497
+ {
498
+ blankLine: 'always',
499
+ prev: 'function',
500
+ next: '*'
501
+ },
502
+ {
503
+ blankLine: 'always',
504
+ prev: '*',
505
+ next: 'function'
506
+ }
507
+ ],
424
508
  '@stylistic/quotes': ['error', 'single', { avoidEscape: true, ignoreStringLiterals: true }],
425
509
  '@stylistic/spaced-comment': [
426
510
  'error',
@@ -432,15 +516,11 @@ const config = defineConfig([
432
516
  ],
433
517
 
434
518
  // https://github.com/un-ts/eslint-plugin-import-x
435
- 'import-x/consistent-type-specifier-style': ['error', 'prefer-inline'],
519
+ 'import-x/consistent-type-specifier-style': 'error',
436
520
  'import-x/export': 'error',
437
521
  'import-x/extensions': ['error', 'ignorePackages'],
438
522
  'import-x/first': 'error',
439
- 'import-x/named': 'error',
440
- 'import-x/namespace': 'error',
441
- 'import-x/newline-after-import': 'error',
442
523
  'import-x/no-absolute-path': 'error',
443
- 'import-x/no-amd': 'error',
444
524
  'import-x/no-anonymous-default-export': [
445
525
  'error',
446
526
  {
@@ -454,7 +534,6 @@ const config = defineConfig([
454
534
  allowObject: true
455
535
  }
456
536
  ],
457
- 'import-x/no-duplicates': ['error', { 'prefer-inline': true }],
458
537
  'import-x/no-extraneous-dependencies': [
459
538
  'error',
460
539
  {
@@ -478,7 +557,6 @@ const config = defineConfig([
478
557
  }
479
558
  ],
480
559
  'import-x/no-useless-path-segments': 'error',
481
- 'import-x/no-webpack-loader-syntax': 'error',
482
560
 
483
561
  // https://github.com/dangreenisrael/eslint-plugin-jest-formatting
484
562
  'jest-formatting/padding-around-after-all-blocks': 'error',
@@ -492,7 +570,7 @@ const config = defineConfig([
492
570
  'jsdoc/check-access': 'error',
493
571
  'jsdoc/check-indentation': [
494
572
  'error',
495
- { excludeTags: ['example', 'param', 'property', 'returns', 'throws', 'todo'] }
573
+ { excludeTags: ['example', 'param', 'property', 'returns', 'template', 'throws', 'todo'] }
496
574
  ],
497
575
  'jsdoc/check-line-alignment': ['error', 'never', { wrapIndent: ' ' }],
498
576
  'jsdoc/check-param-names': ['error', { checkDestructured: false }],
@@ -530,7 +608,31 @@ const config = defineConfig([
530
608
  contexts: [
531
609
  {
532
610
  comment: 'JsdocBlock:has(JsdocTag[tag=typedef][parsedType.value=/object/i])',
533
- message: 'Omit the object type from typedef'
611
+ message: 'Omit the object type from @typedef'
612
+ },
613
+
614
+ // https://github.com/gajus/eslint-plugin-jsdoc/issues/1314
615
+ {
616
+ comment: 'JsdocBlock:has(JsdocTag:has(JsdocTypeImport))',
617
+ context: 'any',
618
+ message: 'Use @import tag over import() statements'
619
+ },
620
+
621
+ // https://github.com/gajus/eslint-plugin-jsdoc/issues/1445
622
+ {
623
+ comment: 'JsdocBlock:has(JsdocTag[tag=typedef]):has(JsdocTag[tag=callback])',
624
+ context: 'any',
625
+ message: 'Use separate blocks for @typedef and @callback'
626
+ },
627
+ {
628
+ comment: 'JsdocBlock:has(JsdocTag[tag=typedef] ~ JsdocTag[tag=typedef])',
629
+ context: 'any',
630
+ message: 'Use separate blocks for multiple @typedef tags'
631
+ },
632
+ {
633
+ comment: 'JsdocBlock:has(JsdocTag[tag=callback] ~ JsdocTag[tag=callback])',
634
+ context: 'any',
635
+ message: 'Use separate blocks for multiple @typedef tags'
534
636
  }
535
637
  ]
536
638
  }
@@ -604,6 +706,13 @@ const config = defineConfig([
604
706
  internalPattern: [],
605
707
  groups: [
606
708
  'side-effect',
709
+ 'type-builtin',
710
+ 'type-external',
711
+ 'type-subpath',
712
+ 'type-internal',
713
+ 'type-parent',
714
+ { newlinesBetween: 'never' },
715
+ ['type-sibling', 'type-index'],
607
716
  'builtin',
608
717
  'external',
609
718
  'subpath',
@@ -657,6 +766,7 @@ const config = defineConfig([
657
766
  'node:fs/promises': { named: true },
658
767
  'node:os': { named: true },
659
768
  'node:path': { named: true },
769
+ 'node:test': { named: true },
660
770
  'node:url': { named: true },
661
771
  'node:util': { named: true },
662
772
  'node:zlib': { named: true },
@@ -672,7 +782,6 @@ const config = defineConfig([
672
782
  'unicorn/no-accessor-recursion': 'error',
673
783
  'unicorn/no-array-for-each': 'error',
674
784
  'unicorn/no-array-method-this-argument': 'error',
675
- 'unicorn/no-array-push-push': 'error',
676
785
  'unicorn/no-array-reduce': 'error',
677
786
  'unicorn/no-await-in-promise-methods': 'error',
678
787
  'unicorn/no-console-spaces': 'error',
@@ -683,7 +792,6 @@ const config = defineConfig([
683
792
  'unicorn/no-instanceof-builtins': 'error',
684
793
  'unicorn/no-invalid-fetch-options': 'error',
685
794
  'unicorn/no-invalid-remove-event-listener': 'error',
686
- 'unicorn/no-length-as-slice-end': 'error',
687
795
  'unicorn/no-lonely-if': 'error',
688
796
  'unicorn/no-named-default': 'error',
689
797
  'unicorn/no-negated-condition': 'error',
@@ -694,9 +802,13 @@ const config = defineConfig([
694
802
  'unicorn/no-static-only-class': 'error',
695
803
  'unicorn/no-this-assignment': 'error',
696
804
  'unicorn/no-typeof-undefined': 'error',
805
+ 'unicorn/no-unnecessary-array-flat-depth': 'error',
806
+ 'unicorn/no-unnecessary-array-splice-count': 'error',
697
807
  'unicorn/no-unnecessary-await': 'error',
808
+ 'unicorn/no-unnecessary-slice-end': 'error',
698
809
  'unicorn/no-unreadable-iife': 'error',
699
810
  'unicorn/no-unused-properties': 'error',
811
+ 'unicorn/no-useless-error-capture-stack-trace': 'error',
700
812
  'unicorn/no-useless-fallback-in-spread': 'error',
701
813
  'unicorn/no-useless-length-check': 'error',
702
814
  'unicorn/no-useless-promise-resolve-reject': 'error',
@@ -712,6 +824,7 @@ const config = defineConfig([
712
824
  'unicorn/prefer-array-some': 'error',
713
825
  'unicorn/prefer-at': 'error',
714
826
  'unicorn/prefer-blob-reading-methods': 'error',
827
+ 'unicorn/prefer-class-fields': 'error',
715
828
  'unicorn/prefer-date-now': 'error',
716
829
  'unicorn/prefer-default-parameters': 'error',
717
830
  'unicorn/prefer-dom-node-append': 'error',
@@ -721,6 +834,7 @@ const config = defineConfig([
721
834
  'unicorn/prefer-event-target': 'error',
722
835
  'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
723
836
  'unicorn/prefer-global-this': 'error',
837
+ 'unicorn/prefer-import-meta-properties': 'error',
724
838
  'unicorn/prefer-includes': 'error',
725
839
  'unicorn/prefer-json-parse-buffer': 'error',
726
840
  'unicorn/prefer-keyboard-event-key': 'error',
@@ -740,6 +854,7 @@ const config = defineConfig([
740
854
  'unicorn/prefer-regexp-test': 'error',
741
855
  'unicorn/prefer-set-has': 'error',
742
856
  'unicorn/prefer-set-size': 'error',
857
+ 'unicorn/prefer-single-call': 'error',
743
858
  'unicorn/prefer-string-replace-all': 'error',
744
859
  'unicorn/prefer-string-slice': 'error',
745
860
  'unicorn/prefer-string-starts-ends-with': 'error',
@@ -749,6 +864,7 @@ const config = defineConfig([
749
864
  'unicorn/prefer-top-level-await': 'error',
750
865
  'unicorn/prefer-type-error': 'error',
751
866
  'unicorn/relative-url-style': 'error',
867
+ 'unicorn/require-module-specifiers': 'error',
752
868
  'unicorn/require-post-message-target-origin': 'error',
753
869
  'unicorn/switch-case-braces': ['error', 'avoid'],
754
870
  'unicorn/template-indent': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remcohaszing/eslint",
3
- "version": "11.2.0",
3
+ "version": "12.0.1",
4
4
  "description": "A strict ESLint configuration.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -31,18 +31,18 @@
31
31
  "dependencies": {
32
32
  "@eslint-community/eslint-plugin-eslint-comments": "^4.0.0",
33
33
  "@eslint/compat": "^1.0.0",
34
- "@eslint/markdown": "^6.0.0",
35
- "@stylistic/eslint-plugin": "^4.0.0",
34
+ "@eslint/markdown": "^7.0.0",
35
+ "@stylistic/eslint-plugin": "^5.0.0",
36
36
  "@typescript-eslint/eslint-plugin": "^8.0.0",
37
37
  "@typescript-eslint/parser": "^8.0.0",
38
38
  "confusing-browser-globals": "^1.0.0",
39
39
  "eslint-plugin-import-x": "^4.0.0",
40
40
  "eslint-plugin-jest-formatting": "^3.0.0",
41
- "eslint-plugin-jsdoc": "^50.0.0",
41
+ "eslint-plugin-jsdoc": "^54.0.0",
42
42
  "eslint-plugin-n": "^17.0.0",
43
43
  "eslint-plugin-perfectionist": "^4.0.0",
44
44
  "eslint-plugin-prettier": "^5.0.0",
45
- "eslint-plugin-unicorn": "^58.0.0",
45
+ "eslint-plugin-unicorn": "^60.0.0",
46
46
  "find-up": "^5.0.0"
47
47
  },
48
48
  "devDependencies": {
@@ -50,6 +50,7 @@
50
50
  "prettier-plugin-packagejson": "^2.0.0",
51
51
  "remark-cli": "^12.0.0",
52
52
  "remark-preset-remcohaszing": "^3.0.0",
53
+ "type-fest": "^4.0.0",
53
54
  "typescript": "^5.0.0"
54
55
  },
55
56
  "peerDependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../lib/config.js"],"names":[],"mappings":"AAwkCA;;;;;;;GAOG;AACH,kCALW,aAAa,GAAG,aAAa,EAAE,GAE7B,aAAa,EAAE,CAK3B;;AAvFD,+DA2EE;4BArkCuB,QAAQ;AAmEjC,0DAm7BE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../lib/config.js"],"names":[],"mappings":"AA4rCA;;;;;;;GAOG;AACH,kCALW,aAAa,GAAG,aAAa,EAAE,GAE7B,aAAa,EAAE,CAK3B;;AAvFD,+DA2EE;4BAzrCuB,QAAQ;AA+HjC,0DA2+BE"}
@@ -1,33 +0,0 @@
1
- /**
2
- * These property names are allowed, because exist in commonly used specifications.
3
- */
4
- export const allowedProperties = [
5
- // OAuth2
6
- 'access_token',
7
- 'client_id',
8
- 'client_secret',
9
- 'error_description',
10
- 'error_uri',
11
- 'expires_in',
12
- 'grant_type',
13
- 'redirect_uri',
14
- 'refresh_token',
15
- 'response_type',
16
- 'token_type',
17
-
18
- // OpenID
19
- 'email_verified',
20
- 'id_token',
21
-
22
- // Web app manifest
23
- 'background_color',
24
- 'iarc_rating_id',
25
- 'short_name',
26
- 'prefer_related_applications',
27
- 'related_applications',
28
- 'start_url',
29
- 'theme_color',
30
-
31
- // React
32
- '__html'
33
- ]
package/lib/constants.js DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Known packages in on DefinitelyTyped that don’t describe an npm package.
3
- */
4
- export const dtOnlyPackages = [
5
- 'estree',
6
- 'estree-jsx',
7
- 'hast',
8
- 'mdast',
9
- 'unist',
10
- 'web-app-manifest',
11
- 'xast'
12
- ]
13
-
14
- /**
15
- * Known packages that export only type definitions, but which don’t contain a JavaScript file.
16
- */
17
- export const typesOnlyPackages = ['@fortawesome/fontawesome-common-types']
@@ -1,27 +0,0 @@
1
- /**
2
- * @import { Linter } from 'eslint'
3
- */
4
-
5
- import { dirname, join } from 'node:path'
6
-
7
- import { includeIgnoreFile } from '@eslint/compat'
8
- import findUp from 'find-up'
9
-
10
- /**
11
- * Determine the default ignore pattern based on `.gitignore`.
12
- *
13
- * @returns {Linter.Config | undefined}
14
- * An array of ignore patterns accepted in an ESLint configuration.
15
- */
16
- export function getIgnorePatterns() {
17
- const gitDir = findUp.sync('.git', { type: 'directory' })
18
-
19
- if (gitDir) {
20
- const gitIgnorePath = join(dirname(gitDir), '.gitignore')
21
- try {
22
- return includeIgnoreFile(gitIgnorePath)
23
- } catch {
24
- // Do nothing
25
- }
26
- }
27
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * These property names are allowed, because exist in commonly used specifications.
3
- */
4
- export const allowedProperties: string[];
5
- //# sourceMappingURL=allowedProperties.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"allowedProperties.d.ts","sourceRoot":"","sources":["../lib/allowedProperties.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,yCA6BC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Known packages in on DefinitelyTyped that don’t describe an npm package.
3
- */
4
- export const dtOnlyPackages: string[];
5
- /**
6
- * Known packages that export only type definitions, but which don’t contain a JavaScript file.
7
- */
8
- export const typesOnlyPackages: string[];
9
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,sCAQC;AAED;;GAEG;AACH,yCAA0E"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Determine the default ignore pattern based on `.gitignore`.
3
- *
4
- * @returns {Linter.Config | undefined}
5
- * An array of ignore patterns accepted in an ESLint configuration.
6
- */
7
- export function getIgnorePatterns(): Linter.Config | undefined;
8
- import type { Linter } from 'eslint';
9
- //# sourceMappingURL=getIgnorePatterns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getIgnorePatterns.d.ts","sourceRoot":"","sources":["../lib/getIgnorePatterns.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,qCAHa,aAAa,GAAG,SAAS,CAcrC;4BAzB0B,QAAQ"}