@vp-tw/eslint-config 0.0.14 → 0.0.16
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/README.md +1 -0
- package/dist/configs/mdx.d.ts +3 -2
- package/dist/configs/mdx.js +22 -60
- package/dist/configs/prettier.d.ts +2 -1
- package/dist/configs/prettier.js +8 -24
- package/dist/configs/storybook.d.ts +6 -6
- package/dist/configs/storybook.js +20 -42
- package/dist/esm/configs/mdx.d.ts +3 -2
- package/dist/esm/configs/mdx.mjs +34 -76
- package/dist/esm/configs/prettier.d.ts +2 -1
- package/dist/esm/configs/prettier.mjs +13 -24
- package/dist/esm/configs/storybook.d.ts +6 -6
- package/dist/esm/configs/storybook.mjs +30 -45
- package/dist/esm/extends/_utils.d.ts +1 -1
- package/dist/esm/extends/_utils.mjs +1 -1
- package/dist/esm/extends/imports.d.ts +3 -3
- package/dist/esm/extends/imports.mjs +55 -66
- package/dist/esm/extends/javascript.d.ts +4 -3
- package/dist/esm/extends/javascript.mjs +30 -41
- package/dist/esm/extends/jsonc.d.ts +6 -6
- package/dist/esm/extends/jsonc.mjs +50 -118
- package/dist/esm/extends/react.d.ts +10 -3
- package/dist/esm/extends/react.mjs +39 -45
- package/dist/esm/extends/typescript.d.ts +4 -3
- package/dist/esm/extends/typescript.mjs +37 -48
- package/dist/esm/extends/yaml.d.ts +4 -4
- package/dist/esm/extends/yaml.mjs +23 -47
- package/dist/extends/_utils.d.ts +1 -1
- package/dist/extends/_utils.js +1 -1
- package/dist/extends/imports.d.ts +3 -3
- package/dist/extends/imports.js +38 -52
- package/dist/extends/javascript.d.ts +4 -3
- package/dist/extends/javascript.js +26 -37
- package/dist/extends/jsonc.d.ts +6 -6
- package/dist/extends/jsonc.js +29 -101
- package/dist/extends/react.d.ts +10 -3
- package/dist/extends/react.js +28 -43
- package/dist/extends/typescript.d.ts +4 -3
- package/dist/extends/typescript.js +35 -46
- package/dist/extends/yaml.d.ts +4 -4
- package/dist/extends/yaml.js +28 -52
- package/package.json +22 -4
|
@@ -6,80 +6,69 @@ import {
|
|
|
6
6
|
GLOB_TS,
|
|
7
7
|
GLOB_TSX
|
|
8
8
|
} from "@antfu/eslint-config";
|
|
9
|
-
import
|
|
9
|
+
import defu from "defu";
|
|
10
|
+
import { omit, pick } from "es-toolkit";
|
|
10
11
|
import { GLOB_CONFIG_JS } from "../globs.mjs";
|
|
11
12
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
12
13
|
import { ignoreKeys } from "./_utils.mjs";
|
|
13
14
|
const configNamesMapSource = {
|
|
14
15
|
imports: "vdustr/imports/rules",
|
|
15
|
-
noDefaultExport: "vdustr/no-default-export/rules"
|
|
16
|
+
noDefaultExport: "vdustr/imports/no-default-export/rules"
|
|
16
17
|
};
|
|
17
18
|
const importsInternal = (composer, options) => {
|
|
18
|
-
extendsConfig(composer, "antfu/imports/rules", (config) =>
|
|
19
|
-
config
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Forbid `import {} from "module"`.
|
|
39
|
-
*/
|
|
40
|
-
"import/no-empty-named-blocks": "error",
|
|
41
|
-
/**
|
|
42
|
-
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
43
|
-
* Consider using named imports instead.
|
|
44
|
-
*/
|
|
45
|
-
"import/no-namespace": "error",
|
|
46
|
-
/**
|
|
47
|
-
* Overridable.
|
|
48
|
-
*/
|
|
49
|
-
...options?.imports?.rules
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: configNamesMapSource.noDefaultExport,
|
|
54
|
-
/**
|
|
55
|
-
* Overridable.
|
|
56
|
-
*/
|
|
57
|
-
...options?.noDefaultExport,
|
|
58
|
-
rules: {
|
|
59
|
-
/**
|
|
60
|
-
* Enforcing named exports improves consistency, enhances auto-completion and refactoring, and avoids issues
|
|
61
|
-
* with default export renaming. Additionally, default exports might lead to different behavior when transformed
|
|
62
|
-
* to CJS.
|
|
63
|
-
*/
|
|
64
|
-
"import/no-default-export": "error",
|
|
65
|
-
...options?.noDefaultExport?.rules
|
|
19
|
+
extendsConfig(composer, "antfu/imports/rules", (config) => {
|
|
20
|
+
const modifiedConfig = defu(pick(options?.imports ?? {}, ["files", "ignores"]), config);
|
|
21
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
22
|
+
const rulesConfig = defu(
|
|
23
|
+
omit(options?.imports ?? {}, ["files", "ignores"]),
|
|
24
|
+
{
|
|
25
|
+
name: configNamesMapSource.imports,
|
|
26
|
+
rules: {
|
|
27
|
+
/**
|
|
28
|
+
* Forbid `import {} from "module"`.
|
|
29
|
+
*/
|
|
30
|
+
"import/no-empty-named-blocks": "error",
|
|
31
|
+
/**
|
|
32
|
+
* Wildcard imports can prevent tree shaking and cause name conflicts.
|
|
33
|
+
* Consider using named imports instead.
|
|
34
|
+
*/
|
|
35
|
+
"import/no-namespace": "error"
|
|
36
|
+
}
|
|
66
37
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
38
|
+
omittedConfig
|
|
39
|
+
);
|
|
40
|
+
const noDefaultExportConfig = defu(
|
|
41
|
+
options?.noDefaultExport,
|
|
42
|
+
{
|
|
43
|
+
name: configNamesMapSource.noDefaultExport,
|
|
44
|
+
rules: {
|
|
45
|
+
/**
|
|
46
|
+
* Enforcing named exports improves consistency, enhances
|
|
47
|
+
* auto-completion and refactoring, and avoids issues with default
|
|
48
|
+
* export renaming. Additionally, default exports might lead to
|
|
49
|
+
* different behavior when transformed to CJS.
|
|
50
|
+
*/
|
|
51
|
+
"import/no-default-export": "error"
|
|
52
|
+
},
|
|
53
|
+
files: [
|
|
54
|
+
GLOB_JS,
|
|
55
|
+
GLOB_JSX,
|
|
56
|
+
GLOB_TS,
|
|
57
|
+
GLOB_TSX,
|
|
58
|
+
...options?.noDefaultExport?.files || []
|
|
59
|
+
],
|
|
60
|
+
ignores: [
|
|
61
|
+
// Configuration files
|
|
62
|
+
GLOB_CONFIG_JS,
|
|
63
|
+
GLOB_MARKDOWN_CODE,
|
|
64
|
+
GLOB_ASTRO_TS,
|
|
65
|
+
...options?.noDefaultExport?.ignores || []
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
omit(omittedConfig, ["files", "ignores"])
|
|
69
|
+
);
|
|
70
|
+
return [modifiedConfig, rulesConfig, noDefaultExportConfig];
|
|
71
|
+
});
|
|
83
72
|
};
|
|
84
73
|
const imports = Object.assign(importsInternal, {
|
|
85
74
|
configNamesMapSource
|
|
@@ -2,7 +2,7 @@ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
|
2
2
|
import type { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
|
|
4
4
|
declare const configNamesMapSource: {
|
|
5
|
-
readonly
|
|
5
|
+
readonly javascript: "vdustr/javascript/rules";
|
|
6
6
|
};
|
|
7
7
|
declare module "../types" {
|
|
8
8
|
interface ConfigNamesMap extends ResolveConfigNamesMap<javascript.ConfigNamesMapSource> {
|
|
@@ -10,12 +10,13 @@ declare module "../types" {
|
|
|
10
10
|
}
|
|
11
11
|
declare namespace javascript {
|
|
12
12
|
type ConfigNamesMapSource = typeof configNamesMapSource;
|
|
13
|
-
interface Options
|
|
13
|
+
interface Options {
|
|
14
|
+
javascript?: ConfigOverrides;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
declare const javascript: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: javascript.Options) => void) & {
|
|
17
18
|
configNamesMapSource: {
|
|
18
|
-
readonly
|
|
19
|
+
readonly javascript: "vdustr/javascript/rules";
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
export { javascript };
|
|
@@ -1,49 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { omit, pick } from "es-toolkit";
|
|
2
3
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
3
4
|
import { ignoreKeys } from "./_utils.mjs";
|
|
4
5
|
const configNamesMapSource = {
|
|
5
|
-
|
|
6
|
+
javascript: "vdustr/javascript/rules"
|
|
6
7
|
};
|
|
7
8
|
const javascriptInternal = (composer, options) => {
|
|
8
|
-
extendsConfig(composer, "antfu/javascript/rules", (config) =>
|
|
9
|
-
config
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"no-unused-vars": "off",
|
|
36
|
-
"unused-imports/no-unused-vars": "off",
|
|
37
|
-
"unused-imports/no-unused-imports-ts": "off",
|
|
38
|
-
"unused-imports/no-unused-vars-ts": "off",
|
|
39
|
-
"unused-imports/no-unused-imports": "off",
|
|
40
|
-
/**
|
|
41
|
-
* Overridable.
|
|
42
|
-
*/
|
|
43
|
-
...options?.rules
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
]);
|
|
9
|
+
extendsConfig(composer, "antfu/javascript/rules", (config) => {
|
|
10
|
+
const modifiedConfig = defu(pick(options?.javascript ?? {}, ["files", "ignores"]), config);
|
|
11
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
12
|
+
const rulesConfig = defu(
|
|
13
|
+
omit(options?.javascript ?? {}, ["files", "ignores"]),
|
|
14
|
+
{
|
|
15
|
+
name: configNamesMapSource.javascript,
|
|
16
|
+
rules: {
|
|
17
|
+
/**
|
|
18
|
+
* Some callbacks are purposefully named to make the code self-documenting.
|
|
19
|
+
*/
|
|
20
|
+
"prefer-arrow-callback": "off",
|
|
21
|
+
/**
|
|
22
|
+
* This rule does not integrate well with JSDoc `@link` tags. It's advised
|
|
23
|
+
* to verify its behavior with TypeScript instead.
|
|
24
|
+
*/
|
|
25
|
+
"no-unused-vars": "off",
|
|
26
|
+
"unused-imports/no-unused-vars": "off",
|
|
27
|
+
"unused-imports/no-unused-imports-ts": "off",
|
|
28
|
+
"unused-imports/no-unused-vars-ts": "off",
|
|
29
|
+
"unused-imports/no-unused-imports": "off"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
omittedConfig
|
|
33
|
+
);
|
|
34
|
+
return [modifiedConfig, rulesConfig];
|
|
35
|
+
});
|
|
47
36
|
};
|
|
48
37
|
const javascript = Object.assign(javascriptInternal, {
|
|
49
38
|
configNamesMapSource
|
|
@@ -2,8 +2,8 @@ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
|
2
2
|
import type { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
|
|
4
4
|
declare const configNamesMapSource: {
|
|
5
|
-
readonly
|
|
6
|
-
readonly sortArrayValues: "vdustr/jsonc/
|
|
5
|
+
readonly jsonc: "vdustr/jsonc/rules";
|
|
6
|
+
readonly sortArrayValues: "vdustr/jsonc/sort-array-values/rules";
|
|
7
7
|
readonly packageJsonSetup: "vdustr/package-json/setup";
|
|
8
8
|
readonly packageJsonRules: "vdustr/package-json/rules";
|
|
9
9
|
};
|
|
@@ -15,14 +15,14 @@ declare namespace jsonc {
|
|
|
15
15
|
type ConfigNamesMapSource = typeof configNamesMapSource;
|
|
16
16
|
interface Options {
|
|
17
17
|
jsonc?: ConfigOverrides;
|
|
18
|
+
sortArrayValues?: ConfigOverrides;
|
|
18
19
|
packageJson?: ConfigOverrides;
|
|
19
|
-
sortArrayValues: ConfigOverrides;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
declare const jsonc: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: jsonc.Options) => void) & {
|
|
22
|
+
declare const jsonc: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: jsonc.Options) => Promise<void>) & {
|
|
23
23
|
configNamesMapSource: {
|
|
24
|
-
readonly
|
|
25
|
-
readonly sortArrayValues: "vdustr/jsonc/
|
|
24
|
+
readonly jsonc: "vdustr/jsonc/rules";
|
|
25
|
+
readonly sortArrayValues: "vdustr/jsonc/sort-array-values/rules";
|
|
26
26
|
readonly packageJsonSetup: "vdustr/package-json/setup";
|
|
27
27
|
readonly packageJsonRules: "vdustr/package-json/rules";
|
|
28
28
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { omit, pick } from "es-toolkit";
|
|
3
4
|
import {
|
|
4
5
|
GLOB_CODE_WORKSPACE,
|
|
5
6
|
GLOB_CSPELL_JSON,
|
|
@@ -8,64 +9,29 @@ import {
|
|
|
8
9
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
9
10
|
import { ignoreKeys } from "./_utils.mjs";
|
|
10
11
|
const configNamesMapSource = {
|
|
11
|
-
|
|
12
|
-
sortArrayValues: "vdustr/jsonc/
|
|
12
|
+
jsonc: "vdustr/jsonc/rules",
|
|
13
|
+
sortArrayValues: "vdustr/jsonc/sort-array-values/rules",
|
|
13
14
|
packageJsonSetup: "vdustr/package-json/setup",
|
|
14
15
|
packageJsonRules: "vdustr/package-json/rules"
|
|
15
16
|
};
|
|
16
|
-
const jsoncInternal = (composer, options) => {
|
|
17
|
+
const jsoncInternal = async (composer, options) => {
|
|
18
|
+
await ensurePackages(["eslint-plugin-package-json"]);
|
|
19
|
+
const packageJson = await interopDefault(
|
|
20
|
+
import("eslint-plugin-package-json/configs/recommended")
|
|
21
|
+
);
|
|
17
22
|
extendsConfig(
|
|
18
23
|
composer,
|
|
19
24
|
"antfu/jsonc/rules",
|
|
20
25
|
(config) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Default.
|
|
30
|
-
*/
|
|
31
|
-
GLOB_CODE_WORKSPACE,
|
|
32
|
-
/**
|
|
33
|
-
* Overridable.
|
|
34
|
-
*/
|
|
35
|
-
...options?.jsonc?.files ?? []
|
|
36
|
-
],
|
|
37
|
-
ignores: [
|
|
38
|
-
/**
|
|
39
|
-
* Inherited.
|
|
40
|
-
*/
|
|
41
|
-
...config.ignores ?? [],
|
|
42
|
-
/**
|
|
43
|
-
* Default.
|
|
44
|
-
*/
|
|
45
|
-
GLOB_PACKAGE_JSON,
|
|
46
|
-
/**
|
|
47
|
-
* Overridable.
|
|
48
|
-
*/
|
|
49
|
-
...options?.jsonc?.ignores ?? []
|
|
50
|
-
]
|
|
51
|
-
};
|
|
52
|
-
return [
|
|
53
|
-
config,
|
|
26
|
+
const modifiedConfig = defu(pick(options?.jsonc ?? {}, ["files", "ignores"]), config, {
|
|
27
|
+
files: [GLOB_CODE_WORKSPACE],
|
|
28
|
+
ignores: [GLOB_PACKAGE_JSON]
|
|
29
|
+
});
|
|
30
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
31
|
+
const rulesConfig = defu(
|
|
32
|
+
omit(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
54
33
|
{
|
|
55
|
-
|
|
56
|
-
* Inherited.
|
|
57
|
-
*/
|
|
58
|
-
...omit(config, ignoreKeys),
|
|
59
|
-
/**
|
|
60
|
-
* Default.
|
|
61
|
-
*/
|
|
62
|
-
name: configNamesMapSource.rules,
|
|
63
|
-
files: [...config.files ?? []],
|
|
64
|
-
ignores: [...config.ignores ?? []],
|
|
65
|
-
/**
|
|
66
|
-
* Overridable.
|
|
67
|
-
*/
|
|
68
|
-
...omit(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
34
|
+
name: configNamesMapSource.jsonc,
|
|
69
35
|
rules: {
|
|
70
36
|
/**
|
|
71
37
|
* Default.
|
|
@@ -80,76 +46,42 @@ const jsoncInternal = (composer, options) => {
|
|
|
80
46
|
natural: true
|
|
81
47
|
}
|
|
82
48
|
}
|
|
83
|
-
]
|
|
84
|
-
/**
|
|
85
|
-
* Overridable.
|
|
86
|
-
*/
|
|
87
|
-
...options?.jsonc?.rules
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
plugins: packageJson.plugins,
|
|
92
|
-
name: configNamesMapSource.packageJsonSetup
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
/**
|
|
96
|
-
* Inherited.
|
|
97
|
-
*/
|
|
98
|
-
...omit(packageJson, ["plugins"]),
|
|
99
|
-
/**
|
|
100
|
-
* Default.
|
|
101
|
-
*/
|
|
102
|
-
name: configNamesMapSource.packageJsonRules,
|
|
103
|
-
/**
|
|
104
|
-
* Overridable.
|
|
105
|
-
*/
|
|
106
|
-
...options?.packageJson,
|
|
107
|
-
plugins: {
|
|
108
|
-
/**
|
|
109
|
-
* Inherited.
|
|
110
|
-
*/
|
|
111
|
-
...packageJson.plugins,
|
|
112
|
-
/**
|
|
113
|
-
* Overridable.
|
|
114
|
-
*/
|
|
115
|
-
...options?.packageJson?.plugins
|
|
116
|
-
},
|
|
117
|
-
rules: {
|
|
118
|
-
/**
|
|
119
|
-
* Inherited.
|
|
120
|
-
*/
|
|
121
|
-
...packageJson.rules,
|
|
122
|
-
/**
|
|
123
|
-
* Overridable.
|
|
124
|
-
*/
|
|
125
|
-
...options?.packageJson?.rules
|
|
49
|
+
]
|
|
126
50
|
}
|
|
127
51
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
pathPattern: ".*",
|
|
143
|
-
order: {
|
|
144
|
-
type: "asc",
|
|
145
|
-
caseSensitive: false,
|
|
146
|
-
natural: true
|
|
147
|
-
}
|
|
52
|
+
omittedConfig
|
|
53
|
+
);
|
|
54
|
+
const sortArrayValuesConfig = defu(options?.sortArrayValues, {
|
|
55
|
+
name: configNamesMapSource.sortArrayValues,
|
|
56
|
+
files: [GLOB_CSPELL_JSON],
|
|
57
|
+
rules: {
|
|
58
|
+
"jsonc/sort-array-values": [
|
|
59
|
+
"error",
|
|
60
|
+
{
|
|
61
|
+
pathPattern: ".*",
|
|
62
|
+
order: {
|
|
63
|
+
type: "asc",
|
|
64
|
+
caseSensitive: false,
|
|
65
|
+
natural: true
|
|
148
66
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
152
69
|
}
|
|
70
|
+
});
|
|
71
|
+
const packageJsonSetupConfig = {
|
|
72
|
+
plugins: packageJson.plugins,
|
|
73
|
+
name: configNamesMapSource.packageJsonSetup
|
|
74
|
+
};
|
|
75
|
+
const packageJsonRulesConfig = defu(options?.packageJson, {
|
|
76
|
+
...omit(packageJson, ["name", "plugins"]),
|
|
77
|
+
name: configNamesMapSource.packageJsonRules
|
|
78
|
+
});
|
|
79
|
+
return [
|
|
80
|
+
modifiedConfig,
|
|
81
|
+
rulesConfig,
|
|
82
|
+
sortArrayValuesConfig,
|
|
83
|
+
packageJsonSetupConfig,
|
|
84
|
+
packageJsonRulesConfig
|
|
153
85
|
];
|
|
154
86
|
},
|
|
155
87
|
["antfu/sort/package-json", "antfu/sort/tsconfig-json"]
|
|
@@ -2,7 +2,9 @@ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
|
2
2
|
import type { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
|
|
4
4
|
declare const configNamesMapSource: {
|
|
5
|
-
readonly
|
|
5
|
+
readonly react: "vdustr/react/rules";
|
|
6
|
+
readonly reactCompilerSetup: "vdustr/react/react-compiler/setup";
|
|
7
|
+
readonly reactCompilerRules: "vdustr/react/react-compiler/rules";
|
|
6
8
|
};
|
|
7
9
|
declare module "../types" {
|
|
8
10
|
interface ConfigNamesMap extends ResolveConfigNamesMap<react.ConfigNamesMapSource> {
|
|
@@ -10,12 +12,17 @@ declare module "../types" {
|
|
|
10
12
|
}
|
|
11
13
|
declare namespace react {
|
|
12
14
|
type ConfigNamesMapSource = typeof configNamesMapSource;
|
|
13
|
-
interface Options
|
|
15
|
+
interface Options {
|
|
16
|
+
react?: ConfigOverrides;
|
|
17
|
+
reactCompilerSetup?: ConfigOverrides;
|
|
18
|
+
reactCompilerRules?: ConfigOverrides;
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
declare const react: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: react.Options) => void) & {
|
|
17
22
|
configNamesMapSource: {
|
|
18
|
-
readonly
|
|
23
|
+
readonly react: "vdustr/react/rules";
|
|
24
|
+
readonly reactCompilerSetup: "vdustr/react/react-compiler/setup";
|
|
25
|
+
readonly reactCompilerRules: "vdustr/react/react-compiler/rules";
|
|
19
26
|
};
|
|
20
27
|
};
|
|
21
28
|
export { react };
|
|
@@ -1,56 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { omit, pick } from "es-toolkit";
|
|
2
3
|
import { reactCompiler } from "../lib/eslint-plugin-react-compiler.mjs";
|
|
3
4
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
4
5
|
import { ignoreKeys } from "./_utils.mjs";
|
|
5
6
|
const configNamesMapSource = {
|
|
6
|
-
|
|
7
|
+
react: "vdustr/react/rules",
|
|
8
|
+
reactCompilerSetup: "vdustr/react/react-compiler/setup",
|
|
9
|
+
reactCompilerRules: "vdustr/react/react-compiler/rules"
|
|
7
10
|
};
|
|
8
11
|
const reactInternal = (composer, options) => {
|
|
9
|
-
extendsConfig(composer, "antfu/react/rules", async (config) =>
|
|
10
|
-
config
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
name: configNamesMapSource.rules,
|
|
20
|
-
plugins: {
|
|
21
|
-
/**
|
|
22
|
-
* Inherited.
|
|
23
|
-
*/
|
|
24
|
-
...config.plugins,
|
|
25
|
-
/**
|
|
26
|
-
* Default.
|
|
27
|
-
*/
|
|
28
|
-
"react-compiler": await reactCompiler(),
|
|
29
|
-
/**
|
|
30
|
-
* Overridable.
|
|
31
|
-
*/
|
|
32
|
-
...options?.plugins
|
|
12
|
+
extendsConfig(composer, "antfu/react/rules", async (config) => {
|
|
13
|
+
const modifiedConfig = defu(pick(options?.react ?? {}, ["files", "ignores"]), config);
|
|
14
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
15
|
+
const rulesConfig = defu(
|
|
16
|
+
omit(options?.react ?? {}, ["files", "ignores"]),
|
|
17
|
+
{
|
|
18
|
+
name: configNamesMapSource.react,
|
|
19
|
+
rules: {
|
|
20
|
+
"react/prefer-destructuring-assignment": "off"
|
|
21
|
+
}
|
|
33
22
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* Default.
|
|
41
|
-
*/
|
|
42
|
-
"react-compiler/react-compiler": "error",
|
|
43
|
-
/**
|
|
44
|
-
* Not all destructuring assignments are more readable than their alternatives.
|
|
45
|
-
*/
|
|
46
|
-
"react/prefer-destructuring-assignment": "off",
|
|
47
|
-
/**
|
|
48
|
-
* Overridable.
|
|
49
|
-
*/
|
|
50
|
-
...options?.rules
|
|
23
|
+
omittedConfig
|
|
24
|
+
);
|
|
25
|
+
const reactCompilerSetupConfig = defu(options?.reactCompilerSetup, {
|
|
26
|
+
name: configNamesMapSource.reactCompilerSetup,
|
|
27
|
+
plugins: {
|
|
28
|
+
"react-compiler": await reactCompiler()
|
|
51
29
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
30
|
+
});
|
|
31
|
+
const reactCompilerRulesConfig = defu(
|
|
32
|
+
options?.reactCompilerRules,
|
|
33
|
+
{
|
|
34
|
+
name: configNamesMapSource.reactCompilerRules,
|
|
35
|
+
rules: {
|
|
36
|
+
"react-compiler/react-compiler": "error"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
omittedConfig
|
|
40
|
+
);
|
|
41
|
+
return [
|
|
42
|
+
modifiedConfig,
|
|
43
|
+
rulesConfig,
|
|
44
|
+
reactCompilerSetupConfig,
|
|
45
|
+
reactCompilerRulesConfig
|
|
46
|
+
];
|
|
47
|
+
});
|
|
54
48
|
};
|
|
55
49
|
const react = Object.assign(reactInternal, {
|
|
56
50
|
configNamesMapSource
|
|
@@ -2,7 +2,7 @@ import type { ConfigNames, TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
|
2
2
|
import type { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import type { ConfigOverrides, ResolveConfigNamesMap } from "../types";
|
|
4
4
|
declare const configNamesMapSource: {
|
|
5
|
-
readonly
|
|
5
|
+
readonly typescript: "vdustr/typescript/rules";
|
|
6
6
|
};
|
|
7
7
|
declare module "../types" {
|
|
8
8
|
interface ConfigNamesMap extends ResolveConfigNamesMap<typescript.ConfigNamesMapSource> {
|
|
@@ -10,12 +10,13 @@ declare module "../types" {
|
|
|
10
10
|
}
|
|
11
11
|
declare namespace typescript {
|
|
12
12
|
type ConfigNamesMapSource = typeof configNamesMapSource;
|
|
13
|
-
interface Options
|
|
13
|
+
interface Options {
|
|
14
|
+
typescript?: ConfigOverrides;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
declare const typescript: ((composer: FlatConfigComposer<TypedFlatConfigItem, ConfigNames>, options?: typescript.Options) => void) & {
|
|
17
18
|
configNamesMapSource: {
|
|
18
|
-
readonly
|
|
19
|
+
readonly typescript: "vdustr/typescript/rules";
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
export { typescript };
|