@w5s/eslint-config 3.35.0 → 3.36.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "3.35.0",
3
+ "version": "3.36.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@e18e/eslint-plugin": "^0.8.0",
41
- "@eslint-react/eslint-plugin": "5.18.6",
41
+ "@eslint-react/eslint-plugin": "5.18.7",
42
42
  "@eslint/js": "^10.0.0",
43
43
  "@eslint/markdown": "^8.0.0",
44
44
  "@next/eslint-plugin-next": "^16.0.0",
@@ -46,16 +46,16 @@
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
47
47
  "@typescript-eslint/parser": "^8.0.0",
48
48
  "@vitest/eslint-plugin": "~1.6.20",
49
- "@w5s/dev": "^3.26.0",
50
- "@w5s/eslint-config-ignore": "^1.25.0",
51
- "@w5s/prettier-config": "^3.20.0",
49
+ "@w5s/dev": "^3.27.0",
50
+ "@w5s/eslint-config-ignore": "^1.26.0",
51
+ "@w5s/prettier-config": "^3.21.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-import": "~2.32.0",
54
- "eslint-plugin-jsdoc": "~64.1.0",
54
+ "eslint-plugin-jsdoc": "~64.3.0",
55
55
  "eslint-plugin-jsonc": "~3.4.0",
56
56
  "eslint-plugin-n": "~18.3.0",
57
- "eslint-plugin-perfectionist": "~5.10.0",
58
- "eslint-plugin-unicorn": "~73.0.0",
57
+ "eslint-plugin-perfectionist": "~5.11.0",
58
+ "eslint-plugin-unicorn": "~74.0.0",
59
59
  "eslint-plugin-unused-imports": "~4.4.1",
60
60
  "eslint-plugin-yml": "~3.8.0",
61
61
  "globals": "^17.0.0",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "de5aba704f6744ba64973b010a848d2b2150341d"
88
+ "gitHead": "f01e374782fdf338f411115d7e82a0353540282b"
89
89
  }
package/src/config/es.ts CHANGED
@@ -7,8 +7,9 @@ import type { RuleOptions } from '../typegen/jsonc.js';
7
7
  import { esSourceGlob, sourceGlob } from '../glob.js';
8
8
  import { restrictedGlobals as defaultGlobalRestrictedGlobals } from '../restrictedGlobals.js';
9
9
  import { restrictedImportPaths as defaultGlobalRestrictedImportPaths } from '../restrictedImportPaths.js';
10
+ import { restrictedSyntax as defaultGlobalRestrictedSyntax } from '../restrictedSyntax.js';
10
11
  import { esRules } from '../rules/esRules.js';
11
- import { type Config, type PluginOptionsBase, type RestrictedGlobals, type RestrictedImportPaths } from '../type.js';
12
+ import { type Config, type PluginOptionsBase, type RestrictedGlobals, type RestrictedImportPaths, type RestrictedSyntax } from '../type.js';
12
13
 
13
14
  const defaultFiles = [esSourceGlob];
14
15
 
@@ -16,6 +17,7 @@ export async function es(options: es.Options) {
16
17
  const {
17
18
  defaultRestrictedGlobals = defaultGlobalRestrictedGlobals,
18
19
  defaultRestrictedImportPaths = defaultGlobalRestrictedImportPaths,
20
+ defaultRestrictedSyntax = defaultGlobalRestrictedSyntax,
19
21
  recommended = true,
20
22
  restrictedImportPaths: paths,
21
23
  rules = {},
@@ -26,7 +28,10 @@ export async function es(options: es.Options) {
26
28
  : options.restrictedGlobals ?? defaultRestrictedGlobals;
27
29
  const resolvedPaths =
28
30
  typeof paths === 'function' ? paths(defaultRestrictedImportPaths) : paths ?? defaultRestrictedImportPaths;
29
-
31
+ const resolvedSyntax =
32
+ typeof options.restrictedSyntax === 'function'
33
+ ? options.restrictedSyntax(defaultRestrictedSyntax)
34
+ : options.restrictedSyntax ?? defaultRestrictedSyntax;
30
35
  return [
31
36
  {
32
37
  languageOptions: {
@@ -70,6 +75,10 @@ export async function es(options: es.Options) {
70
75
  paths: resolvedPaths,
71
76
  },
72
77
  ],
78
+ 'no-restricted-syntax': [
79
+ 'error',
80
+ ...resolvedSyntax,
81
+ ],
73
82
  },
74
83
  },
75
84
  {
@@ -115,6 +124,17 @@ export namespace es {
115
124
  */
116
125
  defaultRestrictedImportPaths?: Readonly<RestrictedImportPaths> | undefined;
117
126
 
127
+ /**
128
+ * The default restricted syntax (used by restrictedSyntax).
129
+ *
130
+ * WARNING: prefer using restrictedSyntax
131
+ *
132
+ * You should use defaultRestrictedSyntax only for eslint shared configuration and should rarely be used in project configuration.
133
+ *
134
+ * @internal
135
+ */
136
+ defaultRestrictedSyntax?: Readonly<RestrictedSyntax> | undefined;
137
+
118
138
  /**
119
139
  * An array of restricted globals to override the default restricted globals.
120
140
  *
@@ -161,6 +181,29 @@ export namespace es {
161
181
  * ```
162
182
  */
163
183
  restrictedImportPaths?: ((currentPaths: Readonly<RestrictedImportPaths>) => RestrictedImportPaths) | RestrictedImportPaths | undefined;
184
+
185
+ /**
186
+ * An array of restricted syntax to override the default restricted syntax.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * // As object
191
+ * {
192
+ * restrictedSyntax: [
193
+ * { selector: 'ForInStatement', message: 'Please use for-of instead of for-in.' },
194
+ * ], // Will totally override the default restricted syntax
195
+ * }
196
+ * // as function
197
+ * {
198
+ * restrictedSyntax: (currentSyntax) => [
199
+ * ...currentSyntax.filter((syntax) => syntax.selector !== 'ForInStatement'),
200
+ * { selector: 'ForInStatement', message: 'Please use for-of instead of for-in.' },
201
+ * ], // Allow fine grained control over the default restricted syntax, you can filter or add new syntax rules.
202
+ * }
203
+ * @see https://eslint.org/docs/latest/rules/no-restricted-syntax
204
+ * ```
205
+ */
206
+ restrictedSyntax?: ((currentSyntax: Readonly<RestrictedSyntax>) => RestrictedSyntax) | RestrictedSyntax | undefined;
164
207
  }
165
208
 
166
209
  export type Rules = RuleOptions;
package/src/config/ts.ts CHANGED
@@ -105,7 +105,7 @@ export async function ts(options: ts.Options = {}) {
105
105
  ...rules,
106
106
  },
107
107
  },
108
- ] as [Config, Config, Config] | [Config, Config] satisfies Array<Config>;
108
+ ] as [Config, Config] satisfies Array<Config>;
109
109
  }
110
110
  export namespace ts {
111
111
  export interface Options extends PluginOptionsBase<Rules> {
@@ -73,6 +73,14 @@ export async function defineConfig(options: DefineConfigOptions = {}): Promise<A
73
73
  ...includeEnabled(config.react, toOption(plugins.react)),
74
74
  ...includeEnabled(config.unicorn, toOption(plugins.unicorn)),
75
75
  ...includeEnabled(config.test, toOption(plugins.test)),
76
+ // Stylistic
77
+ ...includeEnabled(config.stylistic, stylisticOptions),
78
+
79
+ // other languages
80
+ ...includeEnabled(config.jsonc, toOption(plugins.jsonc)),
81
+ ...includeEnabled(config.jsdoc, toOption(plugins.jsdoc)),
82
+ ...includeEnabled(config.markdown, toOption(plugins.markdown)),
83
+ ...includeEnabled(config.yml, toOption(plugins.yml)),
76
84
  ...(rules ? [{ rules }] : []),
77
85
  );
78
86
  }
package/src/index.ts CHANGED
@@ -3,4 +3,5 @@ export * from './defineConfig.js';
3
3
  export * from './meta.js';
4
4
  export * from './restrictedGlobals.js';
5
5
  export * from './restrictedImportPaths.js';
6
+ export * from './restrictedSyntax.js';
6
7
  export * from './type.js';
@@ -1,5 +1,10 @@
1
1
  import type { RestrictedGlobals } from './type.js';
2
2
 
3
+ /**
4
+ * Default restricted globals used by the ESLint rule no-restricted-globals.
5
+ *
6
+ * @see https://eslint.org/docs/latest/rules/no-restricted-globals
7
+ */
3
8
  export const restrictedGlobals: Readonly<RestrictedGlobals> = Object.freeze([
4
9
  // List of restricted globals
5
10
  {
@@ -3,6 +3,8 @@ import type { RestrictedImportPaths } from './type.js';
3
3
 
4
4
  /**
5
5
  * This file contains the list of restricted import paths used in the ESLint configuration.
6
+ *
7
+ * @see https://eslint.org/docs/latest/rules/no-restricted-imports
6
8
  */
7
9
  export const restrictedImportPaths: Readonly<RestrictedImportPaths> = Object.freeze([
8
10
  // List of restricted import
@@ -0,0 +1,11 @@
1
+ import type { RestrictedSyntax } from './type.js';
2
+
3
+ /**
4
+ * Default restricted syntax used by the ESLint rule no-restricted-syntax.
5
+ *
6
+ * @see https://eslint.org/docs/latest/rules/no-restricted-syntax
7
+ */
8
+ export const restrictedSyntax: Readonly<RestrictedSyntax> = Object.freeze([
9
+ // List of restricted syntax
10
+
11
+ ]);
@@ -11,12 +11,6 @@ export const overrides = () => ({
11
11
  'no-nested-ternary': 'off',
12
12
  // Too strict, for pure code prefer the functional plugin
13
13
  'no-param-reassign': ['error', { props: false }],
14
-
15
- // Allow for-of syntax
16
- // 'no-restricted-syntax': baseConfig.rules['no-restricted-syntax'].filter(
17
- // // @ts-ignore No typing available
18
- // ({ selector }) => selector !== 'ForOfStatement',
19
- // ),
20
14
  // underscore is often used (mongodb, etc)
21
15
  'no-underscore-dangle': 'off',
22
16
  // Ignore underscore case arguments
@@ -0,0 +1,12 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { ESLintRules } from 'eslint/rules';
3
+
4
+ /**
5
+ * This file contains the type definition for restricted globals used in the ESLint configuration.
6
+ */
7
+
8
+ export type RestrictedSyntax = Array<NonNullable<
9
+ ESLintRules['no-restricted-syntax'] extends Linter.RuleEntry<infer O>
10
+ ? O[number]
11
+ : never
12
+ >>;
package/src/type.ts CHANGED
@@ -2,4 +2,5 @@ export * from './type/Config.js';
2
2
  export * from './type/PluginOptionsBase.js';
3
3
  export * from './type/RestrictedGlobals.js';
4
4
  export * from './type/RestrictedImportPaths.js';
5
+ export * from './type/RestrictedSyntax.js';
5
6
  export * from './type/StylisticConfig.js';
@@ -164,6 +164,10 @@ export interface RuleOptions {
164
164
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md#repos-sticky-header
165
165
  */
166
166
  'jsdoc/no-undefined-types'?: Linter.RuleEntry<JsdocNoUndefinedTypes>
167
+ /**
168
+ * Reports redundant @type tags that match or broaden the naturally inferred TypeScript type.
169
+ */
170
+ 'jsdoc/no-unnecessary-type-assertion'?: Linter.RuleEntry<JsdocNoUnnecessaryTypeAssertion>
167
171
  /**
168
172
  * Normalizes labeled links in `@see` tags to a canonical `{@link}` form.
169
173
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/normalize-see-links.md#repos-sticky-header
@@ -455,6 +459,10 @@ type JsdocCheckParamNames = []|[{
455
459
 
456
460
  allowExtraTrailingParamDocs?: boolean
457
461
 
462
+ badParamNames?: boolean
463
+
464
+ badParamOrder?: boolean
465
+
458
466
  checkDestructured?: boolean
459
467
 
460
468
  checkRestProperty?: boolean
@@ -465,8 +473,12 @@ type JsdocCheckParamNames = []|[{
465
473
 
466
474
  disableMissingParamChecks?: boolean
467
475
 
476
+ duplicateParams?: boolean
477
+
468
478
  enableFixer?: boolean
469
479
 
480
+ extraParams?: boolean
481
+
470
482
  useDefaultObjectProperties?: boolean
471
483
  }]
472
484
  // ----- jsdoc/check-property-names -----
@@ -720,6 +732,17 @@ type JsdocNoUndefinedTypes = []|[{
720
732
 
721
733
  markVariablesAsUsed?: boolean
722
734
  }]
735
+ // ----- jsdoc/no-unnecessary-type-assertion -----
736
+ type JsdocNoUnnecessaryTypeAssertion = []|[{
737
+
738
+ checkLiteralConstAssertions?: boolean
739
+
740
+ enableFixer?: boolean
741
+
742
+ treatAnyAsRedundant?: boolean
743
+
744
+ typesToIgnore?: string[]
745
+ }]
723
746
  // ----- jsdoc/normalize-see-links -----
724
747
  type JsdocNormalizeSeeLinks = []|[{
725
748
 
@@ -2125,12 +2125,6 @@ type PerfectionistSortImports = {
2125
2125
  sortBy?: ("specifier" | "path")
2126
2126
  })[]
2127
2127
  newlinesBetween?: ("ignore" | number)
2128
- tsconfig?: {
2129
-
2130
- rootDir: string
2131
-
2132
- filename?: string
2133
- }
2134
2128
 
2135
2129
  maxLineLength?: number
2136
2130
 
@@ -2190,6 +2184,12 @@ type PerfectionistSortImports = {
2190
2184
 
2191
2185
  flags?: string
2192
2186
  } | string))
2187
+ tsconfig?: {
2188
+
2189
+ rootDir: string
2190
+
2191
+ filename?: string
2192
+ }
2193
2193
  }[]
2194
2194
  // ----- perfectionist/sort-interfaces -----
2195
2195
  type PerfectionistSortInterfaces = {
@@ -3159,6 +3159,8 @@ type PerfectionistSortModules = []|[{
3159
3159
  })[]
3160
3160
  newlinesBetween?: ("ignore" | number)
3161
3161
 
3162
+ additionalModuleBlockTypes?: string[]
3163
+
3162
3164
  useExperimentalDependencyDetection?: boolean
3163
3165
  newlinesBetweenOverloadSignatures?: ("ignore" | number)
3164
3166
 
@@ -3200,6 +3202,12 @@ type PerfectionistSortModules = []|[{
3200
3202
  })
3201
3203
 
3202
3204
  partitionByNewLine?: boolean
3205
+ tsconfig?: {
3206
+
3207
+ rootDir: string
3208
+
3209
+ filename?: string
3210
+ }
3203
3211
  }]
3204
3212
  // ----- perfectionist/sort-named-exports -----
3205
3213
  type PerfectionistSortNamedExports = {
@@ -4072,6 +4080,18 @@ type PerfectionistSortObjects = {
4072
4080
 
4073
4081
  useExperimentalDependencyDetection?: boolean
4074
4082
 
4083
+ ignoreCallbackDependenciesPatterns?: (({
4084
+
4085
+ pattern: string
4086
+
4087
+ flags?: string
4088
+ } | string)[] | ({
4089
+
4090
+ pattern: string
4091
+
4092
+ flags?: string
4093
+ } | string))
4094
+
4075
4095
  partitionByComment?: (boolean | (({
4076
4096
 
4077
4097
  pattern: string
@@ -4630,6 +4650,18 @@ type PerfectionistSortVariableDeclarations = {
4630
4650
 
4631
4651
  useExperimentalDependencyDetection?: boolean
4632
4652
 
4653
+ ignoreCallbackDependenciesPatterns?: (({
4654
+
4655
+ pattern: string
4656
+
4657
+ flags?: string
4658
+ } | string)[] | ({
4659
+
4660
+ pattern: string
4661
+
4662
+ flags?: string
4663
+ } | string))
4664
+
4633
4665
  partitionByComment?: (boolean | (({
4634
4666
 
4635
4667
  pattern: string