@w5s/eslint-config 3.27.0 → 3.29.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.27.0",
3
+ "version": "3.29.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.2",
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,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.18.0",
50
- "@w5s/eslint-config-ignore": "^1.17.0",
51
- "@w5s/prettier-config": "^3.12.0",
49
+ "@w5s/dev": "^3.20.0",
50
+ "@w5s/eslint-config-ignore": "^1.19.0",
51
+ "@w5s/prettier-config": "^3.14.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-import": "~2.32.0",
54
- "eslint-plugin-jsdoc": "~63.3.0",
54
+ "eslint-plugin-jsdoc": "~64.1.0",
55
55
  "eslint-plugin-jsonc": "~3.4.0",
56
- "eslint-plugin-n": "~18.2.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
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": "bfd01fd3fa35ecd40db35a2be0873860839c9c62"
88
+ "gitHead": "453a787db3d7e7897ed62c5bc74f4dd98a1ad0c7"
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',
@@ -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 }],
@@ -1,17 +1,18 @@
1
- import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
1
+ import { 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';
5
5
 
6
+ import { sourceGlob } from '../glob.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
+ import { looseRules } from '../rules/looseRules.js';
7
9
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
10
 
9
11
  const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`];
10
12
 
11
13
  export async function markdown(options: markdown.Options = {}) {
12
- const [markdownPlugin, tsPlugin] = await Promise.all([
14
+ const [markdownPlugin] = await Promise.all([
13
15
  interopDefault(import('@eslint/markdown')),
14
- interopDefault(import('@typescript-eslint/eslint-plugin')),
15
16
  ] as const);
16
17
  const {
17
18
  files,
@@ -48,18 +49,36 @@ export async function markdown(options: markdown.Options = {}) {
48
49
  },
49
50
  },
50
51
  {
51
- files: resolvedFiles.map((f) => `${f}/**/*`),
52
+ files: resolvedFiles.map((f) => `${f}/${sourceGlob}`),
52
53
  languageOptions: {
53
54
  parserOptions: {
54
55
  project: false,
55
56
  projectService: false,
56
57
  },
57
58
  },
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
- }),
59
+ name: 'w5s/markdown/embed-code',
60
+ rules: {
61
+ ...looseRules(),
62
+ 'no-alert': 'off',
63
+ 'no-console': 'off',
64
+ 'no-labels': 'off',
65
+ 'no-lone-blocks': 'off',
66
+ 'no-restricted-syntax': 'off',
67
+ 'no-undef': 'off',
68
+ 'no-unused-expressions': 'off',
69
+ 'no-unused-labels': 'off',
70
+ 'no-unused-vars': 'off',
71
+ 'node/prefer-global/process': 'off',
72
+ 'style/eol-last': 'off',
73
+ 'ts/consistent-type-imports': 'off',
74
+ 'ts/no-redeclare': 'off',
75
+ 'ts/no-require-imports': 'off',
76
+ 'ts/no-unused-expressions': 'off',
77
+ 'ts/no-unused-vars': 'off',
78
+ 'unicode-bom': 'off',
79
+ 'unused-imports/no-unused-imports': 'off',
80
+ 'unused-imports/no-unused-vars': 'off',
81
+ },
63
82
  },
64
83
  ] as [Config, Config, Config] satisfies Array<Config>;
65
84
  }
@@ -3,15 +3,15 @@ import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/test.js';
4
4
 
5
5
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
6
+ import { looseRules } from '../rules/looseRules.js';
6
7
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
7
8
 
8
9
  const defaultFiles = Project.extensionsToTestGlob(Project.sourceExtensions());
9
10
 
10
11
  export async function test(options: test.Options = {}) {
11
- const [vitestPlugin, tsPlugin] = await Promise.all([
12
+ const [vitestPlugin] = await Promise.all(([
12
13
  interopDefault(import('@vitest/eslint-plugin')),
13
- interopDefault(import('@typescript-eslint/eslint-plugin')),
14
- ] as const);
14
+ ]) as const);
15
15
  const { files, recommended = true, rules = {}, stylistic = true } = options;
16
16
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
17
17
 
@@ -31,28 +31,11 @@ export async function test(options: test.Options = {}) {
31
31
  ...ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, {
32
32
  vitest: 'test',
33
33
  }),
34
- // Loose rules
35
- 'e18e/prefer-static-regex': 'off',
34
+ ...looseRules(),
35
+
36
36
  // Improve some rules
37
37
  'test/expect-expect': ['error', { assertFunctionNames: ['expect*', 'assert*'] }],
38
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',
56
39
  }
57
40
  : {}),
58
41
  ...(stylisticEnabled
@@ -0,0 +1,12 @@
1
+ export function lazy<T>(fn: () => T): () => T {
2
+ let isSet = false;
3
+ let value: T | undefined;
4
+ return () => {
5
+ if (!isSet) {
6
+ value = fn();
7
+ isSet = true;
8
+ }
9
+ // eslint-disable-next-line ts/no-non-null-assertion
10
+ return value!;
11
+ };
12
+ }
@@ -1,3 +1,4 @@
1
+ import { lazy } from '../internal/lazy.js';
1
2
  import { bestPractices } from './esRules/bestPractices.js';
2
3
  import { errors } from './esRules/errors.js';
3
4
  import { es6 } from './esRules/es6.js';
@@ -5,7 +6,7 @@ import { overrides } from './esRules/overrides.js';
5
6
  import { strict } from './esRules/strict.js';
6
7
  import { variables } from './esRules/variables.js';
7
8
 
8
- export const esRules = () => ({
9
+ export const esRules = lazy(() => ({
9
10
  ...bestPractices(),
10
11
  ...errors(),
11
12
  ...es6(),
@@ -14,4 +15,4 @@ export const esRules = () => ({
14
15
 
15
16
  // Must be last
16
17
  ...overrides(),
17
- });
18
+ }));
@@ -0,0 +1,29 @@
1
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
2
+ import { ESLintConfig } from '@w5s/dev';
3
+
4
+ import { lazy } from '../internal/lazy.js';
5
+
6
+ export const looseRules = lazy(() => {
7
+ // eslint-disable-next-line ts/no-non-null-assertion
8
+ return Object.assign(ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
9
+ '@typescript-eslint': 'ts',
10
+ }), {
11
+ // Loose rules
12
+ 'e18e/prefer-static-regex': 'off',
13
+ // TypeScript loose rules
14
+ 'ts/explicit-function-return-type': 'off',
15
+ 'ts/explicit-module-boundary-types': 'off',
16
+ 'ts/no-empty-function': 'off',
17
+ 'ts/no-explicit-any': 'off',
18
+ 'ts/no-namespace': 'off',
19
+ 'ts/no-non-null-assertion': 'off',
20
+ 'ts/no-unsafe-argument': 'off',
21
+ 'ts/no-unsafe-assignment': 'off',
22
+ 'ts/no-unsafe-call': 'off',
23
+ 'ts/no-unsafe-member-access': 'off',
24
+ 'ts/no-unsafe-return': 'off',
25
+ 'ts/no-use-before-define': 'off',
26
+ 'ts/require-await': 'off',
27
+ 'ts/unbound-method': 'off',
28
+ });
29
+ });
@@ -1,8 +1,9 @@
1
1
  import { ESLintConfig } from '@w5s/dev';
2
2
 
3
+ import { lazy } from '../internal/lazy.js';
3
4
  import { esRules } from './esRules.js';
4
5
 
5
- export const tsRules = () => {
6
+ export const tsRules = lazy(() => {
6
7
  const baseRules = esRules();
7
8
 
8
9
  return ESLintConfig.renameRules(
@@ -68,4 +69,4 @@ export const tsRules = () => {
68
69
  '@typescript-eslint': 'ts',
69
70
  },
70
71
  );
71
- };
72
+ });
@@ -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?: ({