@w5s/eslint-config 3.6.0 → 3.7.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 +639 -14
- package/dist/index.js +137 -84
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/src/config/e18e.ts +71 -0
- package/src/config/es.ts +10 -3
- package/src/config/imports.ts +21 -11
- package/src/config/jsdoc.ts +20 -9
- package/src/config/jsonc.ts +7 -2
- package/src/config/markdown.ts +8 -2
- package/src/config/next.ts +50 -0
- package/src/config/node.ts +18 -13
- package/src/config/test.ts +10 -3
- package/src/config/unicorn.ts +2 -3
- package/src/config/yml.ts +8 -6
- package/src/config.ts +2 -0
- package/src/defineConfig.ts +22 -45
- package/src/type/PluginOptionsBase.ts +5 -0
- package/src/typegen/e18e.d.ts +123 -0
- package/src/typegen/next.d.ts +120 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { interopDefault } from '@w5s/dev';
|
|
2
|
+
import { StylisticConfig, type Config, type PluginOptionsBase } from '../type.js';
|
|
3
|
+
import type { RuleOptions } from '../typegen/e18e.js';
|
|
4
|
+
import { sourceGlob } from '../glob.js';
|
|
5
|
+
|
|
6
|
+
const defaultFiles = [sourceGlob];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @see https://e18e.dev
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
export async function e18e(options: e18e.Options = {}) {
|
|
13
|
+
const [e18ePlugin] = await Promise.all([interopDefault(import('@e18e/eslint-plugin'))] as const);
|
|
14
|
+
const { files = defaultFiles, rules = {}, stylistic = true, modernization = true, moduleReplacements = false, performanceImprovements = true } = options;
|
|
15
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
16
|
+
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: 'w5s/e18e/setup',
|
|
20
|
+
plugins: {
|
|
21
|
+
e18e: e18ePlugin,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'w5s/e18e/rules',
|
|
26
|
+
files,
|
|
27
|
+
rules: {
|
|
28
|
+
...modernization ? e18ePlugin.configs.modernization.rules : {},
|
|
29
|
+
...moduleReplacements ? e18ePlugin.configs.moduleReplacements.rules : {},
|
|
30
|
+
...performanceImprovements ? e18ePlugin.configs.performanceImprovements.rules : {},
|
|
31
|
+
|
|
32
|
+
// Disable dangerous (also prefer unicorn)
|
|
33
|
+
'e18e/prefer-array-from-map': 'off',
|
|
34
|
+
'e18e/prefer-array-to-reversed': 'off',
|
|
35
|
+
'e18e/prefer-array-to-sorted': 'off',
|
|
36
|
+
'e18e/prefer-array-to-spliced': 'off',
|
|
37
|
+
'e18e/prefer-spread-syntax': 'off',
|
|
38
|
+
|
|
39
|
+
...(stylisticEnabled ? {} : {}),
|
|
40
|
+
...rules,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export namespace e18e {
|
|
47
|
+
export type Rules = RuleOptions;
|
|
48
|
+
|
|
49
|
+
export interface Options extends PluginOptionsBase<Rules> {
|
|
50
|
+
/**
|
|
51
|
+
* Include modernization default configuration
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
modernization?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Include moduleReplacements default configuration
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
moduleReplacements?: boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Include performanceImprovements default configuration
|
|
66
|
+
*
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
performanceImprovements?: boolean;
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/config/es.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { esSourceGlob } from '../glob.js';
|
|
|
9
9
|
const defaultFiles = [esSourceGlob];
|
|
10
10
|
|
|
11
11
|
export async function es(options: es.Options) {
|
|
12
|
-
const { rules = {} } = options;
|
|
12
|
+
const { recommended = true, rules = {} } = options;
|
|
13
13
|
|
|
14
14
|
return [
|
|
15
15
|
{
|
|
@@ -44,14 +44,21 @@ export async function es(options: es.Options) {
|
|
|
44
44
|
name: 'w5s/es/rules',
|
|
45
45
|
files: defaultFiles,
|
|
46
46
|
rules: {
|
|
47
|
-
...
|
|
48
|
-
...esRules(),
|
|
47
|
+
...(recommended ? es['recommended'] : {}),
|
|
49
48
|
...rules,
|
|
50
49
|
},
|
|
51
50
|
},
|
|
52
51
|
] as [Config, Config] satisfies Array<Config>;
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Recommended rules
|
|
56
|
+
*/
|
|
57
|
+
es['recommended'] = {
|
|
58
|
+
...eslintConfig.configs.recommended.rules,
|
|
59
|
+
...esRules(),
|
|
60
|
+
};
|
|
61
|
+
|
|
55
62
|
export namespace es {
|
|
56
63
|
export type Rules = RuleOptions;
|
|
57
64
|
|
package/src/config/imports.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type PluginOptionsBase, StylisticConfig, type Config } from '../type.js
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/import.js';
|
|
4
4
|
|
|
5
5
|
export async function imports(options: imports.Options = {}) {
|
|
6
|
-
const { rules = {}, stylistic = true } = options;
|
|
6
|
+
const { rules = {}, recommended = true, stylistic = true } = options;
|
|
7
7
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
8
8
|
const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))] as const);
|
|
9
9
|
return [
|
|
@@ -13,17 +13,9 @@ export async function imports(options: imports.Options = {}) {
|
|
|
13
13
|
import: importPlugin,
|
|
14
14
|
},
|
|
15
15
|
rules: {
|
|
16
|
-
|
|
17
|
-
'import/first': 'error',
|
|
18
|
-
'import/no-duplicates': 'error',
|
|
19
|
-
'import/no-mutable-exports': 'error',
|
|
20
|
-
'import/no-named-default': 'error',
|
|
21
|
-
|
|
16
|
+
...(recommended ? imports['recommended'] : {}),
|
|
22
17
|
...(stylisticEnabled
|
|
23
|
-
?
|
|
24
|
-
// Stylistic rules
|
|
25
|
-
'import/newline-after-import': ['error', { count: 1 }],
|
|
26
|
-
}
|
|
18
|
+
? imports['stylistic']
|
|
27
19
|
: {}),
|
|
28
20
|
...rules,
|
|
29
21
|
},
|
|
@@ -31,6 +23,24 @@ export async function imports(options: imports.Options = {}) {
|
|
|
31
23
|
] as [Config] satisfies Array<Config>;
|
|
32
24
|
}
|
|
33
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Recommended rules
|
|
28
|
+
*/
|
|
29
|
+
imports['recommended'] = {
|
|
30
|
+
// 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
|
|
31
|
+
'import/first': 'error',
|
|
32
|
+
'import/no-duplicates': 'error',
|
|
33
|
+
'import/no-mutable-exports': 'error',
|
|
34
|
+
'import/no-named-default': 'error',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Stylistic rules
|
|
39
|
+
*/
|
|
40
|
+
imports['stylistic'] = {
|
|
41
|
+
'import/newline-after-import': ['error', { count: 1 }],
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
export namespace imports {
|
|
35
45
|
export type Rules = RuleOptions;
|
|
36
46
|
|
package/src/config/jsdoc.ts
CHANGED
|
@@ -7,7 +7,12 @@ const defaultFiles = [sourceGlob];
|
|
|
7
7
|
|
|
8
8
|
export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Config[]> {
|
|
9
9
|
const [jsdocPlugin] = await Promise.all([interopDefault(import('eslint-plugin-jsdoc'))] as const);
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
files = defaultFiles,
|
|
12
|
+
recommended = true,
|
|
13
|
+
rules = {},
|
|
14
|
+
stylistic = true,
|
|
15
|
+
} = options;
|
|
11
16
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
12
17
|
|
|
13
18
|
return [
|
|
@@ -21,14 +26,20 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
21
26
|
name: 'w5s/jsdoc/rules',
|
|
22
27
|
files,
|
|
23
28
|
rules: {
|
|
24
|
-
...jsdocPlugin.configs['flat/recommended-typescript-flavor'].rules,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
...(recommended ? jsdocPlugin.configs['flat/recommended-typescript-flavor'].rules : {}),
|
|
30
|
+
|
|
31
|
+
...(recommended
|
|
32
|
+
? {
|
|
33
|
+
'jsdoc/no-undefined-types': 'off', // https://github.com/gajus/eslint-plugin-jsdoc/issues/839
|
|
34
|
+
'jsdoc/require-hyphen-before-param-description': ['warn', 'always'],
|
|
35
|
+
'jsdoc/require-jsdoc': 'off',
|
|
36
|
+
'jsdoc/require-param-description': 'off',
|
|
37
|
+
'jsdoc/require-param-type': 'off',
|
|
38
|
+
'jsdoc/require-returns': 'off',
|
|
39
|
+
'jsdoc/valid-types': 'off', // FIXME: reports lots of false positive
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
|
|
32
43
|
// 'strict': ['error', 'safe'],
|
|
33
44
|
...(stylisticEnabled
|
|
34
45
|
? {
|
package/src/config/jsonc.ts
CHANGED
|
@@ -11,7 +11,12 @@ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Confi
|
|
|
11
11
|
interopDefault(import('eslint-plugin-jsonc')),
|
|
12
12
|
interopDefault(import('jsonc-eslint-parser')),
|
|
13
13
|
] as const);
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
files = defaultFiles,
|
|
16
|
+
recommended = true,
|
|
17
|
+
rules = {},
|
|
18
|
+
stylistic = true,
|
|
19
|
+
} = options;
|
|
15
20
|
const { enabled: stylisticEnabled, indent } = StylisticConfig.from(stylistic);
|
|
16
21
|
|
|
17
22
|
return [
|
|
@@ -28,7 +33,7 @@ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Confi
|
|
|
28
33
|
},
|
|
29
34
|
name: 'w5s/jsonc/rules',
|
|
30
35
|
rules: {
|
|
31
|
-
...jsoncPlugin.configs['flat/recommended-with-json'][0]?.rules,
|
|
36
|
+
...(recommended ? jsoncPlugin.configs['flat/recommended-with-json'][0]?.rules : {}),
|
|
32
37
|
...(stylisticEnabled
|
|
33
38
|
? {
|
|
34
39
|
'jsonc/array-bracket-spacing': ['error', 'never'],
|
package/src/config/markdown.ts
CHANGED
|
@@ -7,7 +7,13 @@ const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['m
|
|
|
7
7
|
|
|
8
8
|
export async function markdown(options: markdown.Options = {}) {
|
|
9
9
|
const [markdownPlugin] = await Promise.all([interopDefault(import('@eslint/markdown'))] as const);
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
language = 'markdown/gfm',
|
|
12
|
+
files = defaultFiles,
|
|
13
|
+
recommended = true,
|
|
14
|
+
rules = {},
|
|
15
|
+
stylistic = true,
|
|
16
|
+
} = options;
|
|
11
17
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
12
18
|
|
|
13
19
|
return [
|
|
@@ -24,7 +30,7 @@ export async function markdown(options: markdown.Options = {}) {
|
|
|
24
30
|
// eslint-disable-next-line ts/no-non-null-assertion
|
|
25
31
|
processor: mergeProcessors([markdownPlugin.processors!.markdown, processorPassThrough]),
|
|
26
32
|
rules: {
|
|
27
|
-
...markdownPlugin.configs.recommended.at(0)?.rules,
|
|
33
|
+
...(recommended ? markdownPlugin.configs.recommended.at(0)?.rules : {}),
|
|
28
34
|
...(stylisticEnabled ? {} : {}),
|
|
29
35
|
...rules,
|
|
30
36
|
},
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ESLintConfig, interopDefault } from '@w5s/dev';
|
|
2
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
3
|
+
import type { RuleOptions } from '../typegen/next.js';
|
|
4
|
+
import { sourceGlob } from '../glob.js';
|
|
5
|
+
|
|
6
|
+
const defaultFiles = [sourceGlob];
|
|
7
|
+
|
|
8
|
+
export async function next(options: next.Options = {}) {
|
|
9
|
+
const [nextPlugin] = await Promise.all([
|
|
10
|
+
interopDefault(import('@next/eslint-plugin-next')),
|
|
11
|
+
] as const);
|
|
12
|
+
const { files = defaultFiles, recommended = true, rules = {} } = options;
|
|
13
|
+
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: 'w5s/next/setup',
|
|
17
|
+
plugins: {
|
|
18
|
+
next: nextPlugin,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'w5s/next/rules',
|
|
23
|
+
files,
|
|
24
|
+
languageOptions: {
|
|
25
|
+
parserOptions: {
|
|
26
|
+
ecmaFeatures: {
|
|
27
|
+
jsx: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
sourceType: 'module',
|
|
31
|
+
},
|
|
32
|
+
settings: {
|
|
33
|
+
react: {
|
|
34
|
+
version: 'detect',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
...(recommended ? ESLintConfig.renameRules(nextPlugin.configs.recommended.rules ?? {}, { '@next/next': 'next' }) : {}),
|
|
39
|
+
...(recommended ? ESLintConfig.renameRules(nextPlugin.configs['core-web-vitals'].rules ?? {}, { '@next/next': 'next' }) : {}),
|
|
40
|
+
...rules,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export namespace next {
|
|
47
|
+
export type Rules = RuleOptions;
|
|
48
|
+
|
|
49
|
+
export interface Options extends Omit<PluginOptionsBase<Rules>, 'stylistic'> {}
|
|
50
|
+
}
|
package/src/config/node.ts
CHANGED
|
@@ -6,7 +6,7 @@ export async function node(options: node.Options = {}) {
|
|
|
6
6
|
const [nodePlugin] = await Promise.all([
|
|
7
7
|
interopDefault(import('eslint-plugin-n')),
|
|
8
8
|
] as const);
|
|
9
|
-
const { rules = {} } = options;
|
|
9
|
+
const { recommended, rules = {} } = options;
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
12
|
name: 'w5s/node/setup',
|
|
@@ -17,18 +17,23 @@ export async function node(options: node.Options = {}) {
|
|
|
17
17
|
{
|
|
18
18
|
name: 'w5s/node/rules',
|
|
19
19
|
rules: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
...(recommended
|
|
21
|
+
? {
|
|
22
|
+
// 'node/handle-callback-err': ['error', '^(err|error|_error)$'],
|
|
23
|
+
'node/no-deprecated-api': 'error',
|
|
24
|
+
'node/no-exports-assign': 'error',
|
|
25
|
+
'node/no-new-require': 'error',
|
|
26
|
+
'node/no-path-concat': 'error',
|
|
27
|
+
// 'node/no-sync': 'error', FIXME: this rule uses typing without a way to disable it, so it causes errors in JS files
|
|
28
|
+
'node/prefer-global/buffer': ['error', 'never'],
|
|
29
|
+
'node/prefer-global/console': ['error', 'always'],
|
|
30
|
+
// 'node/prefer-global/process': ['error', 'never'],
|
|
31
|
+
'node/prefer-global/url': ['error', 'always'],
|
|
32
|
+
'node/prefer-global/url-search-params': ['error', 'always'],
|
|
33
|
+
'node/process-exit-as-throw': 'error',
|
|
34
|
+
}
|
|
35
|
+
: {}),
|
|
36
|
+
|
|
32
37
|
...rules,
|
|
33
38
|
},
|
|
34
39
|
},
|
package/src/config/test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { interopDefault, Project } from '@w5s/dev';
|
|
1
|
+
import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
|
|
2
2
|
import { StylisticConfig, type PluginOptionsBase, type Config } from '../type.js';
|
|
3
3
|
import type { RuleOptions } from '../typegen/test.js';
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ export async function test(options: test.Options = {}) {
|
|
|
13
13
|
const [vitestPlugin] = await Promise.all([
|
|
14
14
|
interopDefault(import('@vitest/eslint-plugin')),
|
|
15
15
|
] as const);
|
|
16
|
-
const { files = defaultFiles, rules = {}, stylistic = true } = options;
|
|
16
|
+
const { files = defaultFiles, recommended = true, rules = {}, stylistic = true } = options;
|
|
17
17
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
18
18
|
|
|
19
19
|
return [
|
|
@@ -27,7 +27,14 @@ export async function test(options: test.Options = {}) {
|
|
|
27
27
|
files,
|
|
28
28
|
name: 'w5s/test/rules',
|
|
29
29
|
rules: {
|
|
30
|
-
...
|
|
30
|
+
...(recommended
|
|
31
|
+
? ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, {
|
|
32
|
+
vitest: 'test',
|
|
33
|
+
})
|
|
34
|
+
: {}),
|
|
35
|
+
'test/valid-title': ESLintConfig.fixme(undefined),
|
|
36
|
+
|
|
37
|
+
'e18e/prefer-static-regex': 'off',
|
|
31
38
|
...(stylisticEnabled
|
|
32
39
|
? {}
|
|
33
40
|
: {}),
|
package/src/config/unicorn.ts
CHANGED
|
@@ -7,7 +7,7 @@ const defaultFiles = [sourceGlob];
|
|
|
7
7
|
|
|
8
8
|
export async function unicorn(options: unicorn.Options = {}) {
|
|
9
9
|
const [unicornPlugin] = await Promise.all([interopDefault(import('eslint-plugin-unicorn'))] as const);
|
|
10
|
-
const { files = defaultFiles, rules = {}, stylistic = true } = options;
|
|
10
|
+
const { files = defaultFiles, recommended = true, rules = {}, stylistic = true } = options;
|
|
11
11
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
12
12
|
|
|
13
13
|
return [
|
|
@@ -21,7 +21,7 @@ export async function unicorn(options: unicorn.Options = {}) {
|
|
|
21
21
|
name: 'w5s/unicorn/rules',
|
|
22
22
|
files,
|
|
23
23
|
rules: {
|
|
24
|
-
...unicornPlugin.configs.recommended?.rules,
|
|
24
|
+
...(recommended ? unicornPlugin.configs.recommended?.rules : {}),
|
|
25
25
|
// Disabled for safety
|
|
26
26
|
'unicorn/consistent-destructuring': 'off',
|
|
27
27
|
'unicorn/consistent-function-scoping': 'off', // Too many false positive
|
|
@@ -39,7 +39,6 @@ export async function unicorn(options: unicorn.Options = {}) {
|
|
|
39
39
|
'unicorn/no-object-as-default-parameter': 'off',
|
|
40
40
|
'unicorn/no-process-exit': 'off',
|
|
41
41
|
'unicorn/no-unreadable-array-destructuring': 'off',
|
|
42
|
-
'unicorn/no-unused-properties': 'warn',
|
|
43
42
|
'unicorn/no-useless-undefined': 'off',
|
|
44
43
|
'unicorn/prefer-add-event-listener': 'off',
|
|
45
44
|
'unicorn/prefer-default-parameters': 'off',
|
package/src/config/yml.ts
CHANGED
|
@@ -7,7 +7,7 @@ const defaultFiles = [ymlSourceGlob];
|
|
|
7
7
|
|
|
8
8
|
export async function yml(options: yml.Options = {}) {
|
|
9
9
|
const [ymlPlugin] = await Promise.all([interopDefault(import('eslint-plugin-yml'))] as const);
|
|
10
|
-
const { files = defaultFiles, rules = {}, stylistic = true } = options;
|
|
10
|
+
const { files = defaultFiles, recommended = true, rules = {}, stylistic = true } = options;
|
|
11
11
|
const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
|
|
12
12
|
|
|
13
13
|
return [
|
|
@@ -22,11 +22,13 @@ export async function yml(options: yml.Options = {}) {
|
|
|
22
22
|
language: 'yml/yaml',
|
|
23
23
|
name: 'w5s/yml/rules',
|
|
24
24
|
rules: {
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
...(recommended
|
|
26
|
+
? ymlPlugin.configs['recommended'].reduce(
|
|
27
|
+
(acc, config) => ({ ...acc, ...config.rules }),
|
|
28
|
+
// eslint-disable-next-line ts/consistent-type-assertions
|
|
29
|
+
{} as RuleOptions,
|
|
30
|
+
)
|
|
31
|
+
: {}),
|
|
30
32
|
...(stylisticEnabled
|
|
31
33
|
? {
|
|
32
34
|
'style/spaced-comment': 'off', // Fix
|
package/src/config.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export * from './config/e18e.js';
|
|
1
2
|
export * from './config/es.js';
|
|
2
3
|
export * from './config/ignores.js';
|
|
3
4
|
export * from './config/jsdoc.js';
|
|
4
5
|
export * from './config/jsonc.js';
|
|
5
6
|
export * from './config/imports.js';
|
|
6
7
|
export * from './config/markdown.js';
|
|
8
|
+
export * from './config/next.js';
|
|
7
9
|
export * from './config/node.js';
|
|
8
10
|
export * from './config/stylistic.js';
|
|
9
11
|
export * from './config/test.js';
|
package/src/defineConfig.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { ESLintConfig } from '@w5s/dev';
|
|
2
|
-
import { jsdoc, jsonc, ignores, imports, markdown, node, ts, yml, unicorn, stylistic, es } from './config.js';
|
|
2
|
+
import { jsdoc, jsonc, ignores, imports, markdown, next, node, ts, yml, unicorn, stylistic, es, e18e, test } from './config.js';
|
|
3
3
|
import type { Config } from './type.js';
|
|
4
4
|
|
|
5
5
|
export interface DefineConfigOptions extends ignores.Options {
|
|
6
|
+
e18e?: boolean | e18e.Options;
|
|
6
7
|
es?: boolean | es.Options;
|
|
7
8
|
import?: boolean | imports.Options;
|
|
8
9
|
markdown?: boolean | markdown.Options;
|
|
9
10
|
jsdoc?: boolean | jsdoc.Options;
|
|
10
11
|
jsonc?: boolean | jsonc.Options;
|
|
12
|
+
next?: boolean | next.Options;
|
|
11
13
|
node?: boolean | node.Options;
|
|
12
14
|
stylistic?: boolean | stylistic.Options;
|
|
15
|
+
test?: boolean | test.Options;
|
|
13
16
|
ts?: boolean | ts.Options;
|
|
14
17
|
unicorn?: boolean | unicorn.Options;
|
|
15
18
|
yml?: boolean | yml.Options;
|
|
@@ -25,49 +28,23 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
|
25
28
|
? { enabled: optionsOrBoolean }
|
|
26
29
|
: { enabled: true, ...optionsOrBoolean }) as T & { enabled: boolean },
|
|
27
30
|
);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const jsdocOptions = toOption(options.jsdoc);
|
|
31
|
-
const jsoncOptions = toOption(options.jsonc);
|
|
32
|
-
const markdownOptions = toOption(options.markdown);
|
|
33
|
-
const nodeOptions = toOption(options.node);
|
|
34
|
-
const tsOptions = toOption(options.ts);
|
|
35
|
-
const unicornOptions = toOption(options.unicorn);
|
|
36
|
-
const ymlOptions = toOption(options.yml);
|
|
31
|
+
const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<readonly Config[]>>(factory: (config: T) => R, input: T) =>
|
|
32
|
+
input.enabled ? [factory(input)] : [];
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (importOptions.enabled) {
|
|
55
|
-
append(imports(importOptions));
|
|
56
|
-
}
|
|
57
|
-
if (markdownOptions.enabled) {
|
|
58
|
-
append(markdown(markdownOptions));
|
|
59
|
-
}
|
|
60
|
-
if (nodeOptions.enabled) {
|
|
61
|
-
append(node(nodeOptions));
|
|
62
|
-
}
|
|
63
|
-
if (tsOptions.enabled) {
|
|
64
|
-
append(ts(tsOptions));
|
|
65
|
-
}
|
|
66
|
-
if (ymlOptions.enabled) {
|
|
67
|
-
append(yml(ymlOptions));
|
|
68
|
-
}
|
|
69
|
-
if (unicornOptions.enabled) {
|
|
70
|
-
append(unicorn(unicornOptions));
|
|
71
|
-
}
|
|
72
|
-
return ESLintConfig.concat(...returnValue);
|
|
34
|
+
return ESLintConfig.concat(
|
|
35
|
+
...includeEnabled(e18e, toOption(options.e18e)),
|
|
36
|
+
...includeEnabled(es, toOption(options.es)),
|
|
37
|
+
...includeEnabled(ts, toOption(options.ts)),
|
|
38
|
+
...includeEnabled(ignores, toOption(options)),
|
|
39
|
+
...includeEnabled(jsonc, toOption(options.jsonc)),
|
|
40
|
+
...includeEnabled(jsdoc, toOption(options.jsdoc)),
|
|
41
|
+
...includeEnabled(stylistic, toOption(options.stylistic)),
|
|
42
|
+
...includeEnabled(imports, toOption(options.import)),
|
|
43
|
+
...includeEnabled(markdown, toOption(options.markdown)),
|
|
44
|
+
...includeEnabled(next, toOption(options.next)),
|
|
45
|
+
...includeEnabled(node, toOption(options.node)),
|
|
46
|
+
...includeEnabled(unicorn, toOption(options.unicorn)),
|
|
47
|
+
...includeEnabled(yml, toOption(options.yml)),
|
|
48
|
+
...includeEnabled(test, toOption(options.test)),
|
|
49
|
+
);
|
|
73
50
|
}
|