@w5s/eslint-config 3.25.0 → 3.27.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/dist/index.d.ts +39 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -70
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/config/es.ts +1 -0
- package/src/config/jsx.ts +1 -0
- package/src/config/markdown.ts +24 -6
- package/src/config/test.ts +21 -1
- package/src/config/ts.ts +47 -28
- package/src/meta.ts +1 -1
- package/src/typegen/jsonc.d.ts +12 -4
- package/src/typegen/yml.d.ts +12 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.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.6.0",
|
|
41
|
-
"@eslint-react/eslint-plugin": "5.18.
|
|
41
|
+
"@eslint-react/eslint-plugin": "5.18.2",
|
|
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.
|
|
50
|
-
"@w5s/eslint-config-ignore": "^1.
|
|
51
|
-
"@w5s/prettier-config": "^3.
|
|
49
|
+
"@w5s/dev": "^3.18.0",
|
|
50
|
+
"@w5s/eslint-config-ignore": "^1.17.0",
|
|
51
|
+
"@w5s/prettier-config": "^3.12.0",
|
|
52
52
|
"eslint-merge-processors": "^2.0.0",
|
|
53
53
|
"eslint-plugin-import": "~2.32.0",
|
|
54
54
|
"eslint-plugin-jsdoc": "~63.3.0",
|
|
55
|
-
"eslint-plugin-jsonc": "~3.
|
|
55
|
+
"eslint-plugin-jsonc": "~3.4.0",
|
|
56
56
|
"eslint-plugin-n": "~18.2.0",
|
|
57
57
|
"eslint-plugin-perfectionist": "~5.10.0",
|
|
58
58
|
"eslint-plugin-unicorn": "~72.0.0",
|
|
59
59
|
"eslint-plugin-unused-imports": "~4.4.1",
|
|
60
|
-
"eslint-plugin-yml": "~3.
|
|
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": "
|
|
88
|
+
"gitHead": "bfd01fd3fa35ecd40db35a2be0873860839c9c62"
|
|
89
89
|
}
|
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
|
|
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);
|
package/src/config/markdown.ts
CHANGED
|
@@ -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([
|
|
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:
|
|
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
|
-
|
|
39
|
-
processor: mergeProcessors([markdownPlugin.processors
|
|
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
|
-
|
|
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 {
|
package/src/config/test.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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,
|
|
54
|
-
...ESLintConfig.renameRules(tsStrictRules,
|
|
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!,
|
|
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:
|
|
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
|
package/src/typegen/jsonc.d.ts
CHANGED
|
@@ -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
|
package/src/typegen/yml.d.ts
CHANGED
|
@@ -304,15 +304,19 @@ type YmlSortKeys = ([{
|
|
|
304
304
|
hasProperties?: string[]
|
|
305
305
|
order: ((string | {
|
|
306
306
|
keyPattern?: string
|
|
307
|
-
order?: {
|
|
307
|
+
order?: ({
|
|
308
308
|
type?: ("asc" | "desc")
|
|
309
309
|
caseSensitive?: boolean
|
|
310
310
|
natural?: boolean
|
|
311
|
-
}
|
|
311
|
+
} | {
|
|
312
|
+
type: "ignore"
|
|
313
|
+
})
|
|
312
314
|
})[] | {
|
|
313
315
|
type?: ("asc" | "desc")
|
|
314
316
|
caseSensitive?: boolean
|
|
315
317
|
natural?: boolean
|
|
318
|
+
} | {
|
|
319
|
+
type: "ignore"
|
|
316
320
|
})
|
|
317
321
|
minKeys?: number
|
|
318
322
|
allowLineSeparatedGroups?: boolean
|
|
@@ -321,15 +325,19 @@ type YmlSortKeys = ([{
|
|
|
321
325
|
hasProperties?: string[]
|
|
322
326
|
order: ((string | {
|
|
323
327
|
keyPattern?: string
|
|
324
|
-
order?: {
|
|
328
|
+
order?: ({
|
|
325
329
|
type?: ("asc" | "desc")
|
|
326
330
|
caseSensitive?: boolean
|
|
327
331
|
natural?: boolean
|
|
328
|
-
}
|
|
332
|
+
} | {
|
|
333
|
+
type: "ignore"
|
|
334
|
+
})
|
|
329
335
|
})[] | {
|
|
330
336
|
type?: ("asc" | "desc")
|
|
331
337
|
caseSensitive?: boolean
|
|
332
338
|
natural?: boolean
|
|
339
|
+
} | {
|
|
340
|
+
type: "ignore"
|
|
333
341
|
})
|
|
334
342
|
minKeys?: number
|
|
335
343
|
allowLineSeparatedGroups?: boolean
|