@w5s/eslint-config 3.26.0 → 3.28.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.26.0",
3
+ "version": "3.28.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -37,8 +37,8 @@
37
37
  "postpack": "clean-package restore"
38
38
  },
39
39
  "dependencies": {
40
- "@e18e/eslint-plugin": "^0.6.0",
41
- "@eslint-react/eslint-plugin": "5.18.1",
40
+ "@e18e/eslint-plugin": "^0.8.0",
41
+ "@eslint-react/eslint-plugin": "5.18.3",
42
42
  "@eslint/js": "^10.0.0",
43
43
  "@eslint/markdown": "^8.0.0",
44
44
  "@next/eslint-plugin-next": "^16.0.0",
@@ -46,18 +46,18 @@
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.17.0",
50
- "@w5s/eslint-config-ignore": "^1.16.0",
51
- "@w5s/prettier-config": "^3.11.0",
49
+ "@w5s/dev": "^3.19.0",
50
+ "@w5s/eslint-config-ignore": "^1.18.0",
51
+ "@w5s/prettier-config": "^3.13.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-import": "~2.32.0",
54
- "eslint-plugin-jsdoc": "~63.3.0",
55
- "eslint-plugin-jsonc": "~3.3.0",
56
- "eslint-plugin-n": "~18.2.0",
54
+ "eslint-plugin-jsdoc": "~64.1.0",
55
+ "eslint-plugin-jsonc": "~3.4.0",
56
+ "eslint-plugin-n": "~18.3.0",
57
57
  "eslint-plugin-perfectionist": "~5.10.0",
58
- "eslint-plugin-unicorn": "~72.0.0",
58
+ "eslint-plugin-unicorn": "~73.0.0",
59
59
  "eslint-plugin-unused-imports": "~4.4.1",
60
- "eslint-plugin-yml": "~3.7.0",
60
+ "eslint-plugin-yml": "~3.8.0",
61
61
  "globals": "^17.0.0",
62
62
  "jsonc-eslint-parser": "^3.0.0",
63
63
  "parse-gitignore": "^2.0.0",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "dcf9e4d187060ae2e9c33250078634bd88735d0b"
88
+ "gitHead": "86fbbb9dc5e541529173a897bda1c0aa3efa0ec1"
89
89
  }
@@ -33,6 +33,7 @@ export async function e18e(options: e18e.Options = {}) {
33
33
  ...performanceImprovements ? e18ePlugin.configs.performanceImprovements.rules : {},
34
34
 
35
35
  // Disable dangerous (also prefer unicorn)
36
+ 'e18e/prefer-array-at': 'off',
36
37
  'e18e/prefer-array-from-map': 'off',
37
38
  'e18e/prefer-array-to-reversed': 'off',
38
39
  'e18e/prefer-array-to-sorted': 'off',
package/src/config/es.ts CHANGED
@@ -10,6 +10,7 @@ import { type Config, type PluginOptionsBase } from '../type.js';
10
10
 
11
11
  const defaultFiles = [esSourceGlob];
12
12
 
13
+ // eslint-disable-next-line ts/require-await
13
14
  export async function es(options: es.Options) {
14
15
  const { recommended = true, rules = {} } = options;
15
16
 
@@ -24,7 +24,7 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<
24
24
  : {};
25
25
  const stylisticRules = stylisticEnabled
26
26
  ? {
27
- ...jsdocPlugin.configs['flat/stylistic-typescript'].rules,
27
+ ...jsdocPlugin.configs['flat/stylistic-typescript-flavor'].rules,
28
28
  'jsdoc/check-alignment': 'warn',
29
29
  'jsdoc/multiline-blocks': 'warn',
30
30
  'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
package/src/config/jsx.ts CHANGED
@@ -10,6 +10,7 @@ const defaultFiles = [jsxSourceGlob];
10
10
 
11
11
  export async function jsx(options: jsx.Options = {}) {
12
12
  const { files, jsxA11y = false, recommended = true, rules = {} } = options;
13
+ // eslint-disable-next-line ts/await-thenable
13
14
  const [jsxA11yPlugin] = await Promise.all([
14
15
  jsxA11y ? interopDefault(import('eslint-plugin-jsx-a11y')) : undefined,
15
16
  ] as const);
@@ -1,4 +1,4 @@
1
- import { interopDefault, Project } from '@w5s/dev';
1
+ import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
2
2
  import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
3
3
 
4
4
  import type { RuleOptions } from '../typegen/markdown.js';
@@ -9,7 +9,10 @@ import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js
9
9
  const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`];
10
10
 
11
11
  export async function markdown(options: markdown.Options = {}) {
12
- const [markdownPlugin] = await Promise.all([interopDefault(import('@eslint/markdown'))] as const);
12
+ const [markdownPlugin, tsPlugin] = await Promise.all([
13
+ interopDefault(import('@eslint/markdown')),
14
+ interopDefault(import('@typescript-eslint/eslint-plugin')),
15
+ ] as const);
13
16
  const {
14
17
  files,
15
18
  language = 'markdown/gfm',
@@ -20,6 +23,7 @@ export async function markdown(options: markdown.Options = {}) {
20
23
  } = options;
21
24
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
22
25
 
26
+ const resolvedFiles = withDefaultFiles(files, defaultFiles);
23
27
  return [
24
28
  {
25
29
  name: 'w5s/markdown/setup',
@@ -28,22 +32,36 @@ export async function markdown(options: markdown.Options = {}) {
28
32
  },
29
33
  },
30
34
  {
31
- files: withDefaultFiles(files, defaultFiles),
35
+ files: resolvedFiles,
32
36
  language,
33
37
  languageOptions: {
34
38
  frontmatter: 'yaml',
35
39
  ...languageOptions,
36
40
  },
37
41
  name: 'w5s/markdown/rules',
38
- // eslint-disable-next-line ts/no-non-null-assertion
39
- processor: mergeProcessors([markdownPlugin.processors!.markdown, processorPassThrough]),
42
+
43
+ processor: mergeProcessors([markdownPlugin.processors.markdown, processorPassThrough]),
40
44
  rules: {
41
45
  ...(recommended ? markdownPlugin.configs.recommended.at(0)?.rules : {}),
42
46
  ...(stylisticEnabled ? {} : {}),
43
47
  ...rules,
44
48
  },
45
49
  },
46
- ] as [Config, Config] satisfies Array<Config>;
50
+ {
51
+ files: resolvedFiles.map((f) => `${f}/**/*`),
52
+ languageOptions: {
53
+ parserOptions: {
54
+ project: false,
55
+ projectService: false,
56
+ },
57
+ },
58
+ name: 'w5s/markdown/embed',
59
+ // eslint-disable-next-line ts/no-non-null-assertion
60
+ rules: ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
61
+ '@typescript-eslint': 'ts',
62
+ }),
63
+ },
64
+ ] as [Config, Config, Config] satisfies Array<Config>;
47
65
  }
48
66
 
49
67
  export namespace markdown {
@@ -8,8 +8,9 @@ import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js
8
8
  const defaultFiles = Project.extensionsToTestGlob(Project.sourceExtensions());
9
9
 
10
10
  export async function test(options: test.Options = {}) {
11
- const [vitestPlugin] = await Promise.all([
11
+ const [vitestPlugin, tsPlugin] = await Promise.all([
12
12
  interopDefault(import('@vitest/eslint-plugin')),
13
+ interopDefault(import('@typescript-eslint/eslint-plugin')),
13
14
  ] as const);
14
15
  const { files, recommended = true, rules = {}, stylistic = true } = options;
15
16
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
@@ -30,9 +31,28 @@ export async function test(options: test.Options = {}) {
30
31
  ...ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, {
31
32
  vitest: 'test',
32
33
  }),
34
+ // Loose rules
33
35
  'e18e/prefer-static-regex': 'off',
36
+ // Improve some rules
34
37
  'test/expect-expect': ['error', { assertFunctionNames: ['expect*', 'assert*'] }],
35
38
  'test/valid-title': ESLintConfig.fixme(undefined),
39
+ // Loose typing
40
+ // eslint-disable-next-line ts/no-non-null-assertion
41
+ ...ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
42
+ '@typescript-eslint': 'ts',
43
+ }),
44
+
45
+ 'ts/explicit-module-boundary-types': 'off',
46
+ 'ts/no-empty-function': 'off',
47
+ 'ts/no-explicit-any': 'off',
48
+ 'ts/no-non-null-assertion': 'off',
49
+ 'ts/no-unsafe-argument': 'off',
50
+ 'ts/no-unsafe-assignment': 'off',
51
+ 'ts/no-unsafe-call': 'off',
52
+ 'ts/no-unsafe-member-access': 'off',
53
+ 'ts/no-unsafe-return': 'off',
54
+ 'ts/require-await': 'off',
55
+ 'ts/unbound-method': 'off',
36
56
  }
37
57
  : {}),
38
58
  ...(stylisticEnabled
package/src/config/ts.ts CHANGED
@@ -8,6 +8,9 @@ import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
8
  import { tsRules } from '../rules/tsRules.js';
9
9
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
10
10
 
11
+ const tsRenameMap = {
12
+ '@typescript-eslint': 'ts',
13
+ };
11
14
  const defaultFiles = [tsSourceGlob];
12
15
 
13
16
  export async function ts(options: ts.Options = {}) {
@@ -18,9 +21,18 @@ export async function ts(options: ts.Options = {}) {
18
21
  const tsRecommendedRules = tsPlugin.configs['eslint-recommended']!.overrides![0]!.rules!;
19
22
  const tsStrictRules = tsPlugin.configs['strict']!.rules!;
20
23
  const tsTypeCheckedRules = tsPlugin.configs['recommended-type-checked-only']!.rules!;
21
- const { files, rules = {}, stylistic = true, typeChecked = false } = options;
24
+ const {
25
+ files,
26
+ parserOptions = {},
27
+ recommended = true,
28
+ rules = {},
29
+ stylistic = true,
30
+ tsconfigPath = './tsconfig.json',
31
+ typeChecked = true,
32
+ } = options;
22
33
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
23
34
  const tsCustomRules = tsRules();
35
+ const resolvedFiles = withDefaultFiles(files, defaultFiles);
24
36
 
25
37
  return [
26
38
  {
@@ -30,33 +42,34 @@ export async function ts(options: ts.Options = {}) {
30
42
  },
31
43
  },
32
44
  {
33
- files: withDefaultFiles(files, defaultFiles),
45
+ files: resolvedFiles,
34
46
  languageOptions: {
35
47
  parser: tsParser,
36
48
  parserOptions: {
37
49
  sourceType: 'module',
38
50
  // extraFileExtensions: componentExts.map(ext => `.${ext}`),
39
- // ...typeAware
40
- // ? {
41
- // projectService: {
42
- // allowDefaultProject: ['./*.js'],
43
- // defaultProject: tsconfigPath,
44
- // },
45
- // tsconfigRootDir: process.cwd(),
46
- // }
47
- // : {},
48
- // ...parserOptions as any,
51
+ ...typeChecked
52
+ ? {
53
+ projectService: {
54
+ allowDefaultProject: ['./*.js'],
55
+ defaultProject: tsconfigPath,
56
+ },
57
+ tsconfigRootDir: process.cwd(),
58
+ }
59
+ : {},
60
+ ...parserOptions,
49
61
  },
50
62
  },
51
63
  name: 'w5s/ts/rules',
52
64
  rules: {
53
- ...ESLintConfig.renameRules(tsRecommendedRules, { '@typescript-eslint': 'ts' }),
54
- ...ESLintConfig.renameRules(tsStrictRules, { '@typescript-eslint': 'ts' }),
55
- ...tsCustomRules,
65
+ ...(recommended ? ESLintConfig.renameRules(tsRecommendedRules, tsRenameMap) : {}),
66
+ ...(recommended ? ESLintConfig.renameRules(tsStrictRules, tsRenameMap) : {}),
67
+ ...(recommended ? tsCustomRules : {}),
68
+ ...(recommended && typeChecked ? ESLintConfig.renameRules(tsTypeCheckedRules, tsRenameMap) : {}),
56
69
  ...(stylisticEnabled
57
70
  ? {
58
71
  // eslint-disable-next-line ts/no-non-null-asserted-optional-chain
59
- ...ESLintConfig.renameRules(tsPlugin.configs['stylistic']?.rules!, { '@typescript-eslint': 'ts' }),
72
+ ...ESLintConfig.renameRules(tsPlugin.configs['stylistic']?.rules!, tsRenameMap),
60
73
  'ts/array-type': ['error', { default: 'generic' }],
61
74
  'ts/consistent-type-assertions': [
62
75
  'error',
@@ -90,25 +103,31 @@ export async function ts(options: ts.Options = {}) {
90
103
  'ts/no-empty-function': tsCustomRules['ts/no-empty-function'],
91
104
  }
92
105
  : {}),
106
+
93
107
  ...rules,
94
108
  },
95
109
  },
96
- ...(typeChecked
97
- ? ([
98
- {
99
- files: defaultFiles,
100
- // ignores: ignoresTypeAware,
101
- name: 'w5s/ts/rules-type-checked',
102
- rules: {
103
- ...ESLintConfig.renameRules(tsTypeCheckedRules, { '@typescript-eslint': 'ts' }),
104
- },
105
- },
106
- ] as const)
107
- : []),
108
110
  ] as [Config, Config, Config] | [Config, Config] satisfies Array<Config>;
109
111
  }
110
112
  export namespace ts {
111
113
  export interface Options extends PluginOptionsBase<Rules> {
114
+ /**
115
+ * Parser options for TypeScript ESLint parser
116
+ */
117
+ // TODO: find real type for parserOptions
118
+ parserOptions?: Record<string, unknown>;
119
+
120
+ /**
121
+ * Path to the tsconfig.json file.
122
+ * This must be to enable type aware rules.
123
+ *
124
+ * @default './tsconfig.json'
125
+ */
126
+ tsconfigPath?: string;
127
+
128
+ /**
129
+ * Whether to enable type aware rules
130
+ */
112
131
  typeChecked?: boolean;
113
132
  }
114
133
 
package/src/meta.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export const meta = Object.freeze({
2
2
  // @ts-ignore - these variables are injected at build time
3
- buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
3
+ buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
4
4
  // @ts-ignore - these variables are injected at build time
5
5
  name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,
6
6
  // @ts-ignore - these variables are injected at build time
@@ -459,15 +459,19 @@ type JsoncSortKeys = ([{
459
459
  hasProperties?: string[]
460
460
  order: ((string | {
461
461
  keyPattern?: string
462
- order?: {
462
+ order?: ({
463
463
  type?: ("asc" | "desc")
464
464
  caseSensitive?: boolean
465
465
  natural?: boolean
466
- }
466
+ } | {
467
+ type: "ignore"
468
+ })
467
469
  })[] | {
468
470
  type?: ("asc" | "desc")
469
471
  caseSensitive?: boolean
470
472
  natural?: boolean
473
+ } | {
474
+ type: "ignore"
471
475
  })
472
476
  minKeys?: number
473
477
  allowLineSeparatedGroups?: boolean
@@ -476,15 +480,19 @@ type JsoncSortKeys = ([{
476
480
  hasProperties?: string[]
477
481
  order: ((string | {
478
482
  keyPattern?: string
479
- order?: {
483
+ order?: ({
480
484
  type?: ("asc" | "desc")
481
485
  caseSensitive?: boolean
482
486
  natural?: boolean
483
- }
487
+ } | {
488
+ type: "ignore"
489
+ })
484
490
  })[] | {
485
491
  type?: ("asc" | "desc")
486
492
  caseSensitive?: boolean
487
493
  natural?: boolean
494
+ } | {
495
+ type: "ignore"
488
496
  })
489
497
  minKeys?: number
490
498
  allowLineSeparatedGroups?: boolean
@@ -91,7 +91,7 @@ export interface RuleOptions {
91
91
  */
92
92
  'node/no-new-require'?: Linter.RuleEntry<[]>
93
93
  /**
94
- * disallow string concatenation with `__dirname` and `__filename`
94
+ * disallow string concatenation with `__dirname`, `__filename`, and `import.meta` paths
95
95
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-path-concat.md
96
96
  */
97
97
  'node/no-path-concat'?: Linter.RuleEntry<[]>
@@ -200,11 +200,21 @@ export interface RuleOptions {
200
200
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/url-search-params.md
201
201
  */
202
202
  'node/prefer-global/url-search-params'?: Linter.RuleEntry<NodePreferGlobalUrlSearchParams>
203
+ /**
204
+ * enforce using `node:assert/strict` instead of `node:assert`.
205
+ * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-import/assert-strict.md
206
+ */
207
+ 'node/prefer-import/assert-strict'?: Linter.RuleEntry<[]>
203
208
  /**
204
209
  * enforce using the `node:` protocol when importing Node.js builtin modules.
205
210
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
206
211
  */
207
212
  'node/prefer-node-protocol'?: Linter.RuleEntry<NodePreferNodeProtocol>
213
+ /**
214
+ * enforce using `process.getBuiltinModule()` to load Node.js built-in modules
215
+ * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-process-get-builtin-module.md
216
+ */
217
+ 'node/prefer-process-get-builtin-module'?: Linter.RuleEntry<NodePreferProcessGetBuiltinModule>
208
218
  /**
209
219
  * enforce `require("dns").promises`
210
220
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/dns.md
@@ -515,6 +525,10 @@ type NodePreferGlobalUrlSearchParams = []|[("always" | "never")]
515
525
  type NodePreferNodeProtocol = []|[{
516
526
  version?: string
517
527
  }]
528
+ // ----- node/prefer-process-get-builtin-module -----
529
+ type NodePreferProcessGetBuiltinModule = []|[{
530
+ version?: string
531
+ }]
518
532
  // ----- node/shebang -----
519
533
  type NodeShebang = []|[{
520
534
  convertPath?: ({