@vp-tw/eslint-config 0.0.22 → 0.0.23
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/configs/packageJson.d.ts +9 -0
- package/dist/configs/packageJson.js +24 -0
- package/dist/eslint-typegen.d.ts +1 -1
- package/dist/esm/configs/packageJson.d.ts +9 -0
- package/dist/esm/configs/packageJson.mjs +19 -0
- package/dist/esm/eslint-typegen.d.ts +1 -1
- package/dist/esm/extends/jsonc.d.ts +0 -2
- package/dist/esm/extends/jsonc.mjs +19 -75
- package/dist/esm/extends/sort.d.ts +26 -0
- package/dist/esm/extends/sort.mjs +108 -0
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/utils/extendsConfig.d.ts +14 -1
- package/dist/esm/utils/extendsConfig.mjs +21 -24
- package/dist/esm/vdustr.d.ts +7 -0
- package/dist/esm/vdustr.mjs +31 -0
- package/dist/extends/jsonc.d.ts +0 -2
- package/dist/extends/jsonc.js +3 -36
- package/dist/extends/sort.d.ts +26 -0
- package/dist/extends/sort.js +94 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils/extendsConfig.d.ts +14 -1
- package/dist/utils/extendsConfig.js +14 -18
- package/dist/vdustr.d.ts +7 -0
- package/dist/vdustr.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConfigOverrides, TypedFlatConfigItem } from "../types";
|
|
2
|
+
declare namespace packageJson {
|
|
3
|
+
interface Options {
|
|
4
|
+
setup?: ConfigOverrides;
|
|
5
|
+
packageJson?: ConfigOverrides;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
declare const packageJson: (options?: packageJson.Options) => Promise<TypedFlatConfigItem[]>;
|
|
9
|
+
export { packageJson };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.packageJson = void 0;
|
|
7
|
+
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
+
var _defu = _interopRequireDefault(require("defu"));
|
|
9
|
+
var _esToolkit = require("es-toolkit");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const packageJson = async options => {
|
|
12
|
+
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-package-json"]);
|
|
13
|
+
const packageJson2 = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-package-json/configs/recommended")));
|
|
14
|
+
const packageJsonSetupConfig = {
|
|
15
|
+
plugins: packageJson2.plugins,
|
|
16
|
+
name: "vdustr/package-json/setup"
|
|
17
|
+
};
|
|
18
|
+
const packageJsonRulesConfig = (0, _defu.default)(options?.packageJson, {
|
|
19
|
+
...(0, _esToolkit.omit)(packageJson2, ["name", "plugins"]),
|
|
20
|
+
name: "vdustr/package-json/rules"
|
|
21
|
+
});
|
|
22
|
+
return [packageJsonSetupConfig, packageJsonRulesConfig];
|
|
23
|
+
};
|
|
24
|
+
exports.packageJson = packageJson;
|
package/dist/eslint-typegen.d.ts
CHANGED
|
@@ -99,5 +99,5 @@ type StorybookNoUninstalledAddons = []|[{
|
|
|
99
99
|
[k: string]: unknown | undefined
|
|
100
100
|
}]
|
|
101
101
|
// Names of all the configs
|
|
102
|
-
export type ConfigNames = 'vdustr/mdx/setup' | 'vdustr/mdx/processor' | 'vdustr/mdx/rules' | 'vdustr/mdx/code-blocks' | 'vdustr/prettier/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/stroybook/setup' | 'vdustr/storybook/stories/rules' | 'vdustr/storybook/main/rules'
|
|
102
|
+
export type ConfigNames = 'vdustr/mdx/setup' | 'vdustr/mdx/processor' | 'vdustr/mdx/rules' | 'vdustr/mdx/code-blocks' | 'vdustr/prettier/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/stroybook/setup' | 'vdustr/storybook/stories/rules' | 'vdustr/storybook/main/rules' | 'vdustr/javascript/rules' | 'vdustr/imports/rules' | 'vdustr/imports/no-default-export/rules' | 'vdustr/typescript/rules' | 'vdustr/jsonc/rules' | 'vdustr/sort/tsconfig-json' | 'vdustr/yaml/rules' | 'vdustr/yaml/sort-keys/rules' | 'vdustr/sort/json-keys' | 'vdustr/jsonc/sort-array-values/rules'
|
|
103
103
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConfigOverrides, TypedFlatConfigItem } from "../types";
|
|
2
|
+
declare namespace packageJson {
|
|
3
|
+
interface Options {
|
|
4
|
+
setup?: ConfigOverrides;
|
|
5
|
+
packageJson?: ConfigOverrides;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
declare const packageJson: (options?: packageJson.Options) => Promise<TypedFlatConfigItem[]>;
|
|
9
|
+
export { packageJson };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { omit } from "es-toolkit";
|
|
4
|
+
const packageJson = async (options) => {
|
|
5
|
+
await ensurePackages(["eslint-plugin-package-json"]);
|
|
6
|
+
const packageJson2 = await interopDefault(
|
|
7
|
+
import("eslint-plugin-package-json/configs/recommended")
|
|
8
|
+
);
|
|
9
|
+
const packageJsonSetupConfig = {
|
|
10
|
+
plugins: packageJson2.plugins,
|
|
11
|
+
name: "vdustr/package-json/setup"
|
|
12
|
+
};
|
|
13
|
+
const packageJsonRulesConfig = defu(options?.packageJson, {
|
|
14
|
+
...omit(packageJson2, ["name", "plugins"]),
|
|
15
|
+
name: "vdustr/package-json/rules"
|
|
16
|
+
});
|
|
17
|
+
return [packageJsonSetupConfig, packageJsonRulesConfig];
|
|
18
|
+
};
|
|
19
|
+
export { packageJson };
|
|
@@ -99,5 +99,5 @@ type StorybookNoUninstalledAddons = []|[{
|
|
|
99
99
|
[k: string]: unknown | undefined
|
|
100
100
|
}]
|
|
101
101
|
// Names of all the configs
|
|
102
|
-
export type ConfigNames = 'vdustr/mdx/setup' | 'vdustr/mdx/processor' | 'vdustr/mdx/rules' | 'vdustr/mdx/code-blocks' | 'vdustr/prettier/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/stroybook/setup' | 'vdustr/storybook/stories/rules' | 'vdustr/storybook/main/rules'
|
|
102
|
+
export type ConfigNames = 'vdustr/mdx/setup' | 'vdustr/mdx/processor' | 'vdustr/mdx/rules' | 'vdustr/mdx/code-blocks' | 'vdustr/prettier/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/stroybook/setup' | 'vdustr/storybook/stories/rules' | 'vdustr/storybook/main/rules' | 'vdustr/javascript/rules' | 'vdustr/imports/rules' | 'vdustr/imports/no-default-export/rules' | 'vdustr/typescript/rules' | 'vdustr/jsonc/rules' | 'vdustr/sort/tsconfig-json' | 'vdustr/yaml/rules' | 'vdustr/yaml/sort-keys/rules' | 'vdustr/sort/json-keys' | 'vdustr/jsonc/sort-array-values/rules'
|
|
103
103
|
|
|
@@ -2,8 +2,6 @@ import type { ConfigOverrides, VpComposer } from "../types";
|
|
|
2
2
|
declare namespace jsonc {
|
|
3
3
|
interface Options {
|
|
4
4
|
jsonc?: ConfigOverrides;
|
|
5
|
-
sortArrayValues?: ConfigOverrides;
|
|
6
|
-
packageJson?: ConfigOverrides;
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
7
|
declare const jsonc: (composer: VpComposer, options?: jsonc.Options) => Promise<void>;
|
|
@@ -1,84 +1,28 @@
|
|
|
1
|
-
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
1
|
import defu from "defu";
|
|
3
2
|
import { omit, pick } from "es-toolkit";
|
|
4
|
-
import {
|
|
5
|
-
GLOB_CODE_WORKSPACE,
|
|
6
|
-
GLOB_CSPELL_JSON,
|
|
7
|
-
GLOB_PACKAGE_JSON
|
|
8
|
-
} from "../globs.mjs";
|
|
3
|
+
import { GLOB_CODE_WORKSPACE, GLOB_PACKAGE_JSON } from "../globs.mjs";
|
|
9
4
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
10
5
|
import { ignoreKeys } from "./_utils.mjs";
|
|
11
6
|
const jsonc = async (composer, options) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ignores: [GLOB_PACKAGE_JSON]
|
|
23
|
-
});
|
|
24
|
-
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
25
|
-
const rulesConfig = defu(
|
|
26
|
-
omit(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
27
|
-
{
|
|
28
|
-
name: "vdustr/jsonc/rules",
|
|
29
|
-
rules: {
|
|
30
|
-
/**
|
|
31
|
-
* Default.
|
|
32
|
-
*/
|
|
33
|
-
"jsonc/sort-keys": [
|
|
34
|
-
"error",
|
|
35
|
-
{
|
|
36
|
-
pathPattern: ".*",
|
|
37
|
-
order: {
|
|
38
|
-
type: "asc",
|
|
39
|
-
caseSensitive: false,
|
|
40
|
-
natural: true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
omittedConfig
|
|
47
|
-
);
|
|
48
|
-
const sortArrayValuesConfig = defu(options?.sortArrayValues, {
|
|
49
|
-
name: "vdustr/jsonc/sort-array-values/rules",
|
|
50
|
-
files: [GLOB_CSPELL_JSON],
|
|
7
|
+
extendsConfig(composer, "antfu/jsonc/rules", (config) => {
|
|
8
|
+
const modifiedConfig = defu(pick(options?.jsonc ?? {}, ["files", "ignores"]), config, {
|
|
9
|
+
files: [GLOB_CODE_WORKSPACE],
|
|
10
|
+
ignores: [GLOB_PACKAGE_JSON]
|
|
11
|
+
});
|
|
12
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
13
|
+
const rulesConfig = defu(
|
|
14
|
+
omit(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
15
|
+
{
|
|
16
|
+
name: "vdustr/jsonc/rules",
|
|
51
17
|
rules: {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
pathPattern: ".*",
|
|
56
|
-
order: {
|
|
57
|
-
type: "asc",
|
|
58
|
-
caseSensitive: false,
|
|
59
|
-
natural: true
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]
|
|
18
|
+
/**
|
|
19
|
+
* No overrides for now.
|
|
20
|
+
*/
|
|
63
21
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const packageJsonRulesConfig = defu(options?.packageJson, {
|
|
70
|
-
...omit(packageJson, ["name", "plugins"]),
|
|
71
|
-
name: "vdustr/package-json/rules"
|
|
72
|
-
});
|
|
73
|
-
return [
|
|
74
|
-
modifiedConfig,
|
|
75
|
-
rulesConfig,
|
|
76
|
-
sortArrayValuesConfig,
|
|
77
|
-
packageJsonSetupConfig,
|
|
78
|
-
packageJsonRulesConfig
|
|
79
|
-
];
|
|
80
|
-
},
|
|
81
|
-
["antfu/sort/package-json", "antfu/sort/tsconfig-json"]
|
|
82
|
-
);
|
|
22
|
+
},
|
|
23
|
+
omittedConfig
|
|
24
|
+
);
|
|
25
|
+
return [modifiedConfig, rulesConfig];
|
|
26
|
+
});
|
|
83
27
|
};
|
|
84
28
|
export { jsonc };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigOverrides, VpComposer } from "../types";
|
|
2
|
+
declare namespace sortJsonKeys {
|
|
3
|
+
interface Options {
|
|
4
|
+
sortKeys?: ConfigOverrides;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const sortJsonKeys: (composer: VpComposer, options?: sortJsonKeys.Options) => Promise<void>;
|
|
8
|
+
declare namespace sortPackageJson {
|
|
9
|
+
interface Options {
|
|
10
|
+
packageJson?: ConfigOverrides;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare const sortPackageJson: (composer: VpComposer, options?: sortPackageJson.Options) => Promise<void>;
|
|
14
|
+
declare namespace sortTsconfigJson {
|
|
15
|
+
interface Options {
|
|
16
|
+
tsconfigJson?: ConfigOverrides;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare const sortTsconfigJson: (composer: VpComposer, options?: sortTsconfigJson.Options) => Promise<void>;
|
|
20
|
+
declare namespace sortJsonArrayValues {
|
|
21
|
+
interface Options {
|
|
22
|
+
sortJsonArrayValues?: ConfigOverrides;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare const sortJsonArrayValues: (composer: VpComposer, options?: sortJsonArrayValues.Options) => Promise<void>;
|
|
26
|
+
export { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { omit, pick } from "es-toolkit";
|
|
3
|
+
import { GLOB_CSPELL_JSON } from "../globs.mjs";
|
|
4
|
+
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
5
|
+
import { ignoreKeys } from "./_utils.mjs";
|
|
6
|
+
const sortJsonKeys = async (composer, options) => {
|
|
7
|
+
extendsConfig.pushOverations(composer, [
|
|
8
|
+
async (items) => {
|
|
9
|
+
const source = "vdustr/jsonc/rules";
|
|
10
|
+
const configIndex = items.findIndex((item) => item.name === source);
|
|
11
|
+
const config = items[configIndex];
|
|
12
|
+
if (!config) {
|
|
13
|
+
return items;
|
|
14
|
+
}
|
|
15
|
+
const omittedConfig = omit(config, ignoreKeys);
|
|
16
|
+
const rulesConfig = defu(
|
|
17
|
+
options?.sortKeys,
|
|
18
|
+
{
|
|
19
|
+
name: "vdustr/sort/json-keys",
|
|
20
|
+
rules: {
|
|
21
|
+
"jsonc/sort-keys": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
pathPattern: ".*",
|
|
25
|
+
order: {
|
|
26
|
+
type: "asc",
|
|
27
|
+
caseSensitive: false,
|
|
28
|
+
natural: true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
omittedConfig
|
|
35
|
+
);
|
|
36
|
+
return [...items, rulesConfig];
|
|
37
|
+
}
|
|
38
|
+
]);
|
|
39
|
+
};
|
|
40
|
+
const sortPackageJson = async (composer, options) => {
|
|
41
|
+
extendsConfig(composer, "antfu/sort/package-json", (config) => {
|
|
42
|
+
const rules = config.rules;
|
|
43
|
+
const ruleKeys = Object.keys(rules ?? {});
|
|
44
|
+
const modifiedConfig = defu(pick(options?.packageJson ?? {}, ["files", "ignores"]), config);
|
|
45
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
46
|
+
const rulesConfig = defu(
|
|
47
|
+
options?.packageJson,
|
|
48
|
+
{
|
|
49
|
+
name: "vdustr/sort/package-json",
|
|
50
|
+
/**
|
|
51
|
+
* Disable all rules. Handled by `eslint-config-package-json`.
|
|
52
|
+
*/
|
|
53
|
+
rules: Object.fromEntries(
|
|
54
|
+
ruleKeys.map((key) => {
|
|
55
|
+
return [key, "off"];
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
},
|
|
59
|
+
omittedConfig
|
|
60
|
+
);
|
|
61
|
+
return [modifiedConfig, rulesConfig];
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const sortTsconfigJson = async (composer, options) => {
|
|
65
|
+
extendsConfig(composer, "antfu/sort/tsconfig-json", (config) => {
|
|
66
|
+
const rules = config.rules;
|
|
67
|
+
const ruleKeys = Object.keys(rules ?? {});
|
|
68
|
+
const modifiedConfig = defu(pick(options?.tsconfigJson ?? {}, ["files", "ignores"]), config);
|
|
69
|
+
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
70
|
+
const rulesConfig = defu(
|
|
71
|
+
options?.tsconfigJson,
|
|
72
|
+
{
|
|
73
|
+
name: "vdustr/sort/tsconfig-json",
|
|
74
|
+
/**
|
|
75
|
+
* Disable all rules.
|
|
76
|
+
*/
|
|
77
|
+
rules: Object.fromEntries(
|
|
78
|
+
ruleKeys.map((key) => {
|
|
79
|
+
return [key, "off"];
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
omittedConfig
|
|
84
|
+
);
|
|
85
|
+
return [modifiedConfig, rulesConfig];
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const sortJsonArrayValues = async (composer, options) => {
|
|
89
|
+
const sortArrayValuesConfig = defu(options?.sortJsonArrayValues, {
|
|
90
|
+
name: "vdustr/jsonc/sort-array-values/rules",
|
|
91
|
+
files: [GLOB_CSPELL_JSON],
|
|
92
|
+
rules: {
|
|
93
|
+
"jsonc/sort-array-values": [
|
|
94
|
+
"error",
|
|
95
|
+
{
|
|
96
|
+
pathPattern: ".*",
|
|
97
|
+
order: {
|
|
98
|
+
type: "asc",
|
|
99
|
+
caseSensitive: false,
|
|
100
|
+
natural: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
composer.append(sortArrayValuesConfig);
|
|
107
|
+
};
|
|
108
|
+
export { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson };
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ interface ConfigOverrides extends DistributiveOmit<TypedFlatConfigItem, "process
|
|
|
24
24
|
* Typed composer.
|
|
25
25
|
*/
|
|
26
26
|
type VpComposer = FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
|
|
27
|
-
export type { AnyObject, Config, ConfigNames, ConfigOverrides, ReplaceAntfuEslintRulesWithVpRulesDeeply, TypedFlatConfigItem, VpComposer, };
|
|
27
|
+
export type { AnyObject, Config, ConfigNames, ConfigOverrides, ReplaceAntfuEslintRulesWithVpRulesDeeply, Rules, TypedFlatConfigItem, VpComposer, };
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
2
|
import type { Arrayable, Awaitable, DefaultConfigNamesMap, FlatConfigComposer, StringLiteralUnion } from "eslint-flat-config-utils";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* <https://github.com/antfu/eslint-flat-config-utils/blob/ac3a9b4/src/composer.ts#L492-L512>
|
|
5
|
+
*/
|
|
6
|
+
declare function getConfigIndex(configs: Array<Linter.Config>, nameOrIndex: string | number): number;
|
|
7
|
+
/**
|
|
8
|
+
* <https://github.com/antfu/eslint-flat-config-utils/blob/ac3a9b4/src/composer.ts#L91>
|
|
9
|
+
*/
|
|
10
|
+
type Operation<T extends object = Linter.Config> = (items: Array<T>) => Promise<Array<T>>;
|
|
11
|
+
declare function extendsConfigInternal<T extends object = Linter.Config, ConfigNames extends string = keyof DefaultConfigNamesMap>(composer: FlatConfigComposer<T, ConfigNames>, sourceOrIndex: StringLiteralUnion<ConfigNames, string | number>, config: Awaitable<Arrayable<T>> | ((config: T) => Awaitable<Arrayable<T>>)): void;
|
|
12
|
+
declare const extendsConfig: typeof extendsConfigInternal & {
|
|
13
|
+
getConfigIndex: typeof getConfigIndex;
|
|
14
|
+
tryGetConfigIndex: typeof getConfigIndex;
|
|
15
|
+
pushOverations: <T extends object = Linter.Config<Linter.RulesRecord>, ConfigNames extends string = never>(composer: FlatConfigComposer<T, ConfigNames>, operations: Array<Operation<T>>) => void;
|
|
16
|
+
};
|
|
4
17
|
export { extendsConfig };
|
|
@@ -28,29 +28,26 @@ const tryGetConfigIndex = (configs, nameOrIndex) => {
|
|
|
28
28
|
return -1;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const source = items[index];
|
|
48
|
-
if (!source) return items;
|
|
49
|
-
const newConfigs = await (async () => {
|
|
50
|
-
const awaited = typeof config === "function" ? await config(source) : await config;
|
|
51
|
-
return Array.isArray(awaited) ? awaited : [awaited];
|
|
52
|
-
})();
|
|
53
|
-
return [...items.slice(0, index), ...newConfigs, ...items.slice(index + 1)];
|
|
54
|
-
});
|
|
31
|
+
const pushOverations = (composer, operations) => {
|
|
32
|
+
composer._operations.push(...operations);
|
|
33
|
+
};
|
|
34
|
+
function extendsConfigInternal(composer, sourceOrIndex, config) {
|
|
35
|
+
pushOverations(composer, [
|
|
36
|
+
async (items) => {
|
|
37
|
+
const index = tryGetConfigIndex(items, sourceOrIndex);
|
|
38
|
+
const source = items[index];
|
|
39
|
+
if (!source) return items;
|
|
40
|
+
const newConfigs = await (async () => {
|
|
41
|
+
const awaited = typeof config === "function" ? await config(source) : await config;
|
|
42
|
+
return Array.isArray(awaited) ? awaited : [awaited];
|
|
43
|
+
})();
|
|
44
|
+
return items.toSpliced(index, 1, ...newConfigs);
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
55
47
|
}
|
|
48
|
+
const extendsConfig = Object.assign(extendsConfigInternal, {
|
|
49
|
+
getConfigIndex,
|
|
50
|
+
tryGetConfigIndex,
|
|
51
|
+
pushOverations
|
|
52
|
+
});
|
|
56
53
|
export { extendsConfig };
|
package/dist/esm/vdustr.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Config, ReplaceAntfuEslintRulesWithVpRulesDeeply, VpComposer } from "./types";
|
|
2
2
|
import antfu from "@antfu/eslint-config";
|
|
3
3
|
import { mdx } from "./configs/mdx";
|
|
4
|
+
import { packageJson } from "./configs/packageJson";
|
|
4
5
|
import { prettier } from "./configs/prettier";
|
|
5
6
|
import { storybook } from "./configs/storybook";
|
|
6
7
|
import { imports } from "./extends/imports";
|
|
7
8
|
import { javascript } from "./extends/javascript";
|
|
8
9
|
import { jsonc } from "./extends/jsonc";
|
|
9
10
|
import { react } from "./extends/react";
|
|
11
|
+
import { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson } from "./extends/sort";
|
|
10
12
|
import { typescript } from "./extends/typescript";
|
|
11
13
|
import { yaml } from "./extends/yaml";
|
|
12
14
|
type Options = ReplaceAntfuEslintRulesWithVpRulesDeeply<NonNullable<Parameters<typeof antfu>[0]>> & {
|
|
@@ -14,7 +16,12 @@ type Options = ReplaceAntfuEslintRulesWithVpRulesDeeply<NonNullable<Parameters<t
|
|
|
14
16
|
importsExtends?: imports.Options;
|
|
15
17
|
typescriptExtends?: typescript.Options;
|
|
16
18
|
jsoncExtends?: jsonc.Options;
|
|
19
|
+
sortPackageJsonExtends?: sortPackageJson.Options;
|
|
20
|
+
sortTsConfigJsonExtends?: sortTsconfigJson.Options;
|
|
21
|
+
sortJsonKeysExtends?: sortJsonKeys.Options;
|
|
22
|
+
sortJsonArrayValuesExtends?: sortJsonArrayValues.Options;
|
|
17
23
|
yamlExtends?: yaml.Options;
|
|
24
|
+
packageJson?: boolean | packageJson.Options;
|
|
18
25
|
reactExtends?: react.Options;
|
|
19
26
|
mdx?: boolean | mdx.Options;
|
|
20
27
|
storybook?: boolean | storybook.Options;
|
package/dist/esm/vdustr.mjs
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import antfu from "@antfu/eslint-config";
|
|
2
2
|
import { mdx } from "./configs/mdx.mjs";
|
|
3
|
+
import { packageJson } from "./configs/packageJson.mjs";
|
|
3
4
|
import { prettier } from "./configs/prettier.mjs";
|
|
4
5
|
import { storybook } from "./configs/storybook.mjs";
|
|
5
6
|
import { imports } from "./extends/imports.mjs";
|
|
6
7
|
import { javascript } from "./extends/javascript.mjs";
|
|
7
8
|
import { jsonc } from "./extends/jsonc.mjs";
|
|
8
9
|
import { react } from "./extends/react.mjs";
|
|
10
|
+
import {
|
|
11
|
+
sortJsonArrayValues,
|
|
12
|
+
sortJsonKeys,
|
|
13
|
+
sortPackageJson,
|
|
14
|
+
sortTsconfigJson
|
|
15
|
+
} from "./extends/sort.mjs";
|
|
9
16
|
import { typescript } from "./extends/typescript.mjs";
|
|
10
17
|
import { yaml } from "./extends/yaml.mjs";
|
|
11
18
|
const vdustr = (options, ...userConfigs) => {
|
|
@@ -20,6 +27,30 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
20
27
|
jsonc(config, options?.jsoncExtends);
|
|
21
28
|
yaml(config, options?.yamlExtends);
|
|
22
29
|
react(config, options?.reactExtends);
|
|
30
|
+
const packageJsonEnabled = Boolean(options?.packageJson ?? true);
|
|
31
|
+
if (packageJsonEnabled) {
|
|
32
|
+
const packageJsonOptions = typeof options?.packageJson !== "object" ? void 0 : options.packageJson;
|
|
33
|
+
config = config.append(
|
|
34
|
+
packageJson(...!packageJsonOptions ? [] : [packageJsonOptions])
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
38
|
+
const sortPackageJsonExtendsEnabled = (
|
|
39
|
+
/**
|
|
40
|
+
* jsonc is required for the rules to work.
|
|
41
|
+
*/
|
|
42
|
+
jsoncEnabled && packageJsonEnabled
|
|
43
|
+
);
|
|
44
|
+
if (sortPackageJsonExtendsEnabled) {
|
|
45
|
+
const sortPackageJsonOptions = typeof options?.sortPackageJsonExtends !== "object" ? void 0 : options.sortPackageJsonExtends;
|
|
46
|
+
sortPackageJson(
|
|
47
|
+
config,
|
|
48
|
+
...!sortPackageJsonOptions ? [] : [sortPackageJsonOptions]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
sortTsconfigJson(config, options?.sortTsConfigJsonExtends);
|
|
52
|
+
sortJsonKeys(config, options?.sortJsonKeysExtends);
|
|
53
|
+
sortJsonArrayValues(config, options?.sortJsonArrayValuesExtends);
|
|
23
54
|
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
24
55
|
if (storybookEnabled) {
|
|
25
56
|
const storybookOptions = typeof options?.storybook !== "object" ? void 0 : options.storybook;
|
package/dist/extends/jsonc.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import type { ConfigOverrides, VpComposer } from "../types";
|
|
|
2
2
|
declare namespace jsonc {
|
|
3
3
|
interface Options {
|
|
4
4
|
jsonc?: ConfigOverrides;
|
|
5
|
-
sortArrayValues?: ConfigOverrides;
|
|
6
|
-
packageJson?: ConfigOverrides;
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
7
|
declare const jsonc: (composer: VpComposer, options?: jsonc.Options) => Promise<void>;
|
package/dist/extends/jsonc.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.jsonc = void 0;
|
|
7
|
-
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
7
|
var _defu = _interopRequireDefault(require("defu"));
|
|
9
8
|
var _esToolkit = require("es-toolkit");
|
|
10
9
|
var _globs = require("../globs");
|
|
@@ -12,8 +11,6 @@ var _extendsConfig = require("../utils/extendsConfig");
|
|
|
12
11
|
var _utils = require("./_utils");
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
const jsonc = async (composer, options) => {
|
|
15
|
-
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-package-json"]);
|
|
16
|
-
const packageJson = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-package-json/configs/recommended")));
|
|
17
14
|
(0, _extendsConfig.extendsConfig)(composer, "antfu/jsonc/rules", config => {
|
|
18
15
|
const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.jsonc ?? {}, ["files", "ignores"]), config, {
|
|
19
16
|
files: [_globs.GLOB_CODE_WORKSPACE],
|
|
@@ -24,41 +21,11 @@ const jsonc = async (composer, options) => {
|
|
|
24
21
|
name: "vdustr/jsonc/rules",
|
|
25
22
|
rules: {
|
|
26
23
|
/**
|
|
27
|
-
*
|
|
24
|
+
* No overrides for now.
|
|
28
25
|
*/
|
|
29
|
-
"jsonc/sort-keys": ["error", {
|
|
30
|
-
pathPattern: ".*",
|
|
31
|
-
order: {
|
|
32
|
-
type: "asc",
|
|
33
|
-
caseSensitive: false,
|
|
34
|
-
natural: true
|
|
35
|
-
}
|
|
36
|
-
}]
|
|
37
26
|
}
|
|
38
27
|
}, omittedConfig);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
files: [_globs.GLOB_CSPELL_JSON],
|
|
42
|
-
rules: {
|
|
43
|
-
"jsonc/sort-array-values": ["error", {
|
|
44
|
-
pathPattern: ".*",
|
|
45
|
-
order: {
|
|
46
|
-
type: "asc",
|
|
47
|
-
caseSensitive: false,
|
|
48
|
-
natural: true
|
|
49
|
-
}
|
|
50
|
-
}]
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const packageJsonSetupConfig = {
|
|
54
|
-
plugins: packageJson.plugins,
|
|
55
|
-
name: "vdustr/package-json/setup"
|
|
56
|
-
};
|
|
57
|
-
const packageJsonRulesConfig = (0, _defu.default)(options?.packageJson, {
|
|
58
|
-
...(0, _esToolkit.omit)(packageJson, ["name", "plugins"]),
|
|
59
|
-
name: "vdustr/package-json/rules"
|
|
60
|
-
});
|
|
61
|
-
return [modifiedConfig, rulesConfig, sortArrayValuesConfig, packageJsonSetupConfig, packageJsonRulesConfig];
|
|
62
|
-
}, ["antfu/sort/package-json", "antfu/sort/tsconfig-json"]);
|
|
28
|
+
return [modifiedConfig, rulesConfig];
|
|
29
|
+
});
|
|
63
30
|
};
|
|
64
31
|
exports.jsonc = jsonc;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigOverrides, VpComposer } from "../types";
|
|
2
|
+
declare namespace sortJsonKeys {
|
|
3
|
+
interface Options {
|
|
4
|
+
sortKeys?: ConfigOverrides;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const sortJsonKeys: (composer: VpComposer, options?: sortJsonKeys.Options) => Promise<void>;
|
|
8
|
+
declare namespace sortPackageJson {
|
|
9
|
+
interface Options {
|
|
10
|
+
packageJson?: ConfigOverrides;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare const sortPackageJson: (composer: VpComposer, options?: sortPackageJson.Options) => Promise<void>;
|
|
14
|
+
declare namespace sortTsconfigJson {
|
|
15
|
+
interface Options {
|
|
16
|
+
tsconfigJson?: ConfigOverrides;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare const sortTsconfigJson: (composer: VpComposer, options?: sortTsconfigJson.Options) => Promise<void>;
|
|
20
|
+
declare namespace sortJsonArrayValues {
|
|
21
|
+
interface Options {
|
|
22
|
+
sortJsonArrayValues?: ConfigOverrides;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare const sortJsonArrayValues: (composer: VpComposer, options?: sortJsonArrayValues.Options) => Promise<void>;
|
|
26
|
+
export { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sortTsconfigJson = exports.sortPackageJson = exports.sortJsonKeys = exports.sortJsonArrayValues = void 0;
|
|
7
|
+
var _defu = _interopRequireDefault(require("defu"));
|
|
8
|
+
var _esToolkit = require("es-toolkit");
|
|
9
|
+
var _globs = require("../globs");
|
|
10
|
+
var _extendsConfig = require("../utils/extendsConfig");
|
|
11
|
+
var _utils = require("./_utils");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const sortJsonKeys = async (composer, options) => {
|
|
14
|
+
_extendsConfig.extendsConfig.pushOverations(composer, [async items => {
|
|
15
|
+
const source = "vdustr/jsonc/rules";
|
|
16
|
+
const configIndex = items.findIndex(item => item.name === source);
|
|
17
|
+
const config = items[configIndex];
|
|
18
|
+
if (!config) {
|
|
19
|
+
return items;
|
|
20
|
+
}
|
|
21
|
+
const omittedConfig = (0, _esToolkit.omit)(config, _utils.ignoreKeys);
|
|
22
|
+
const rulesConfig = (0, _defu.default)(options?.sortKeys, {
|
|
23
|
+
name: "vdustr/sort/json-keys",
|
|
24
|
+
rules: {
|
|
25
|
+
"jsonc/sort-keys": ["error", {
|
|
26
|
+
pathPattern: ".*",
|
|
27
|
+
order: {
|
|
28
|
+
type: "asc",
|
|
29
|
+
caseSensitive: false,
|
|
30
|
+
natural: true
|
|
31
|
+
}
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
}, omittedConfig);
|
|
35
|
+
return [...items, rulesConfig];
|
|
36
|
+
}]);
|
|
37
|
+
};
|
|
38
|
+
exports.sortJsonKeys = sortJsonKeys;
|
|
39
|
+
const sortPackageJson = async (composer, options) => {
|
|
40
|
+
(0, _extendsConfig.extendsConfig)(composer, "antfu/sort/package-json", config => {
|
|
41
|
+
const rules = config.rules;
|
|
42
|
+
const ruleKeys = Object.keys(rules ?? {});
|
|
43
|
+
const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.packageJson ?? {}, ["files", "ignores"]), config);
|
|
44
|
+
const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
|
|
45
|
+
const rulesConfig = (0, _defu.default)(options?.packageJson, {
|
|
46
|
+
name: "vdustr/sort/package-json",
|
|
47
|
+
/**
|
|
48
|
+
* Disable all rules. Handled by `eslint-config-package-json`.
|
|
49
|
+
*/
|
|
50
|
+
rules: Object.fromEntries(ruleKeys.map(key => {
|
|
51
|
+
return [key, "off"];
|
|
52
|
+
}))
|
|
53
|
+
}, omittedConfig);
|
|
54
|
+
return [modifiedConfig, rulesConfig];
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.sortPackageJson = sortPackageJson;
|
|
58
|
+
const sortTsconfigJson = async (composer, options) => {
|
|
59
|
+
(0, _extendsConfig.extendsConfig)(composer, "antfu/sort/tsconfig-json", config => {
|
|
60
|
+
const rules = config.rules;
|
|
61
|
+
const ruleKeys = Object.keys(rules ?? {});
|
|
62
|
+
const modifiedConfig = (0, _defu.default)((0, _esToolkit.pick)(options?.tsconfigJson ?? {}, ["files", "ignores"]), config);
|
|
63
|
+
const omittedConfig = (0, _esToolkit.omit)(modifiedConfig, _utils.ignoreKeys);
|
|
64
|
+
const rulesConfig = (0, _defu.default)(options?.tsconfigJson, {
|
|
65
|
+
name: "vdustr/sort/tsconfig-json",
|
|
66
|
+
/**
|
|
67
|
+
* Disable all rules.
|
|
68
|
+
*/
|
|
69
|
+
rules: Object.fromEntries(ruleKeys.map(key => {
|
|
70
|
+
return [key, "off"];
|
|
71
|
+
}))
|
|
72
|
+
}, omittedConfig);
|
|
73
|
+
return [modifiedConfig, rulesConfig];
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
exports.sortTsconfigJson = sortTsconfigJson;
|
|
77
|
+
const sortJsonArrayValues = async (composer, options) => {
|
|
78
|
+
const sortArrayValuesConfig = (0, _defu.default)(options?.sortJsonArrayValues, {
|
|
79
|
+
name: "vdustr/jsonc/sort-array-values/rules",
|
|
80
|
+
files: [_globs.GLOB_CSPELL_JSON],
|
|
81
|
+
rules: {
|
|
82
|
+
"jsonc/sort-array-values": ["error", {
|
|
83
|
+
pathPattern: ".*",
|
|
84
|
+
order: {
|
|
85
|
+
type: "asc",
|
|
86
|
+
caseSensitive: false,
|
|
87
|
+
natural: true
|
|
88
|
+
}
|
|
89
|
+
}]
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
composer.append(sortArrayValuesConfig);
|
|
93
|
+
};
|
|
94
|
+
exports.sortJsonArrayValues = sortJsonArrayValues;
|
package/dist/types.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ interface ConfigOverrides extends DistributiveOmit<TypedFlatConfigItem, "process
|
|
|
24
24
|
* Typed composer.
|
|
25
25
|
*/
|
|
26
26
|
type VpComposer = FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
|
|
27
|
-
export type { AnyObject, Config, ConfigNames, ConfigOverrides, ReplaceAntfuEslintRulesWithVpRulesDeeply, TypedFlatConfigItem, VpComposer, };
|
|
27
|
+
export type { AnyObject, Config, ConfigNames, ConfigOverrides, ReplaceAntfuEslintRulesWithVpRulesDeeply, Rules, TypedFlatConfigItem, VpComposer, };
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
2
|
import type { Arrayable, Awaitable, DefaultConfigNamesMap, FlatConfigComposer, StringLiteralUnion } from "eslint-flat-config-utils";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* <https://github.com/antfu/eslint-flat-config-utils/blob/ac3a9b4/src/composer.ts#L492-L512>
|
|
5
|
+
*/
|
|
6
|
+
declare function getConfigIndex(configs: Array<Linter.Config>, nameOrIndex: string | number): number;
|
|
7
|
+
/**
|
|
8
|
+
* <https://github.com/antfu/eslint-flat-config-utils/blob/ac3a9b4/src/composer.ts#L91>
|
|
9
|
+
*/
|
|
10
|
+
type Operation<T extends object = Linter.Config> = (items: Array<T>) => Promise<Array<T>>;
|
|
11
|
+
declare function extendsConfigInternal<T extends object = Linter.Config, ConfigNames extends string = keyof DefaultConfigNamesMap>(composer: FlatConfigComposer<T, ConfigNames>, sourceOrIndex: StringLiteralUnion<ConfigNames, string | number>, config: Awaitable<Arrayable<T>> | ((config: T) => Awaitable<Arrayable<T>>)): void;
|
|
12
|
+
declare const extendsConfig: typeof extendsConfigInternal & {
|
|
13
|
+
getConfigIndex: typeof getConfigIndex;
|
|
14
|
+
tryGetConfigIndex: typeof getConfigIndex;
|
|
15
|
+
pushOverations: <T extends object = Linter.Config<Linter.RulesRecord>, ConfigNames extends string = never>(composer: FlatConfigComposer<T, ConfigNames>, operations: Array<Operation<T>>) => void;
|
|
16
|
+
};
|
|
4
17
|
export { extendsConfig };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.extendsConfig =
|
|
6
|
+
exports.extendsConfig = void 0;
|
|
7
7
|
function getConfigIndex(configs, nameOrIndex) {
|
|
8
8
|
if (typeof nameOrIndex === "number") {
|
|
9
9
|
if (nameOrIndex < 0 || nameOrIndex >= configs.length) throw new Error(`ESLintFlatConfigUtils: Failed to locate config at index ${nameOrIndex}
|
|
@@ -27,20 +27,11 @@ const tryGetConfigIndex = (configs, nameOrIndex) => {
|
|
|
27
27
|
return -1;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const removingTargets = (() => {
|
|
36
|
-
if (!remove) return [];
|
|
37
|
-
const removeSources = Array.isArray(remove) ? remove : [remove];
|
|
38
|
-
return removeSources.flatMap(removeSource => {
|
|
39
|
-
const index2 = tryGetConfigIndex(items, removeSource);
|
|
40
|
-
return index2 === -1 ? [] : [index2];
|
|
41
|
-
});
|
|
42
|
-
})();
|
|
43
|
-
items = removingTargets.length === 0 ? items : items.filter((_, index2) => !removingTargets.includes(index2));
|
|
30
|
+
const pushOverations = (composer, operations) => {
|
|
31
|
+
composer._operations.push(...operations);
|
|
32
|
+
};
|
|
33
|
+
function extendsConfigInternal(composer, sourceOrIndex, config) {
|
|
34
|
+
pushOverations(composer, [async items => {
|
|
44
35
|
const index = tryGetConfigIndex(items, sourceOrIndex);
|
|
45
36
|
const source = items[index];
|
|
46
37
|
if (!source) return items;
|
|
@@ -48,6 +39,11 @@ function extendsConfig(composer, sourceOrIndex, config, remove) {
|
|
|
48
39
|
const awaited = typeof config === "function" ? await config(source) : await config;
|
|
49
40
|
return Array.isArray(awaited) ? awaited : [awaited];
|
|
50
41
|
})();
|
|
51
|
-
return
|
|
52
|
-
});
|
|
53
|
-
}
|
|
42
|
+
return items.toSpliced(index, 1, ...newConfigs);
|
|
43
|
+
}]);
|
|
44
|
+
}
|
|
45
|
+
const extendsConfig = exports.extendsConfig = Object.assign(extendsConfigInternal, {
|
|
46
|
+
getConfigIndex,
|
|
47
|
+
tryGetConfigIndex,
|
|
48
|
+
pushOverations
|
|
49
|
+
});
|
package/dist/vdustr.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Config, ReplaceAntfuEslintRulesWithVpRulesDeeply, VpComposer } from "./types";
|
|
2
2
|
import antfu from "@antfu/eslint-config";
|
|
3
3
|
import { mdx } from "./configs/mdx";
|
|
4
|
+
import { packageJson } from "./configs/packageJson";
|
|
4
5
|
import { prettier } from "./configs/prettier";
|
|
5
6
|
import { storybook } from "./configs/storybook";
|
|
6
7
|
import { imports } from "./extends/imports";
|
|
7
8
|
import { javascript } from "./extends/javascript";
|
|
8
9
|
import { jsonc } from "./extends/jsonc";
|
|
9
10
|
import { react } from "./extends/react";
|
|
11
|
+
import { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson } from "./extends/sort";
|
|
10
12
|
import { typescript } from "./extends/typescript";
|
|
11
13
|
import { yaml } from "./extends/yaml";
|
|
12
14
|
type Options = ReplaceAntfuEslintRulesWithVpRulesDeeply<NonNullable<Parameters<typeof antfu>[0]>> & {
|
|
@@ -14,7 +16,12 @@ type Options = ReplaceAntfuEslintRulesWithVpRulesDeeply<NonNullable<Parameters<t
|
|
|
14
16
|
importsExtends?: imports.Options;
|
|
15
17
|
typescriptExtends?: typescript.Options;
|
|
16
18
|
jsoncExtends?: jsonc.Options;
|
|
19
|
+
sortPackageJsonExtends?: sortPackageJson.Options;
|
|
20
|
+
sortTsConfigJsonExtends?: sortTsconfigJson.Options;
|
|
21
|
+
sortJsonKeysExtends?: sortJsonKeys.Options;
|
|
22
|
+
sortJsonArrayValuesExtends?: sortJsonArrayValues.Options;
|
|
17
23
|
yamlExtends?: yaml.Options;
|
|
24
|
+
packageJson?: boolean | packageJson.Options;
|
|
18
25
|
reactExtends?: react.Options;
|
|
19
26
|
mdx?: boolean | mdx.Options;
|
|
20
27
|
storybook?: boolean | storybook.Options;
|
package/dist/vdustr.js
CHANGED
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.vdustr = void 0;
|
|
7
7
|
var _eslintConfig = _interopRequireDefault(require("@antfu/eslint-config"));
|
|
8
8
|
var _mdx = require("./configs/mdx");
|
|
9
|
+
var _packageJson = require("./configs/packageJson");
|
|
9
10
|
var _prettier = require("./configs/prettier");
|
|
10
11
|
var _storybook = require("./configs/storybook");
|
|
11
12
|
var _imports = require("./extends/imports");
|
|
12
13
|
var _javascript = require("./extends/javascript");
|
|
13
14
|
var _jsonc = require("./extends/jsonc");
|
|
14
15
|
var _react = require("./extends/react");
|
|
16
|
+
var _sort = require("./extends/sort");
|
|
15
17
|
var _typescript = require("./extends/typescript");
|
|
16
18
|
var _yaml = require("./extends/yaml");
|
|
17
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -27,6 +29,24 @@ const vdustr = (options, ...userConfigs) => {
|
|
|
27
29
|
(0, _jsonc.jsonc)(config, options?.jsoncExtends);
|
|
28
30
|
(0, _yaml.yaml)(config, options?.yamlExtends);
|
|
29
31
|
(0, _react.react)(config, options?.reactExtends);
|
|
32
|
+
const packageJsonEnabled = Boolean(options?.packageJson ?? true);
|
|
33
|
+
if (packageJsonEnabled) {
|
|
34
|
+
const packageJsonOptions = typeof options?.packageJson !== "object" ? void 0 : options.packageJson;
|
|
35
|
+
config = config.append((0, _packageJson.packageJson)(...(!packageJsonOptions ? [] : [packageJsonOptions])));
|
|
36
|
+
}
|
|
37
|
+
const jsoncEnabled = Boolean(options?.jsonc ?? true);
|
|
38
|
+
const sortPackageJsonExtendsEnabled =
|
|
39
|
+
/**
|
|
40
|
+
* jsonc is required for the rules to work.
|
|
41
|
+
*/
|
|
42
|
+
jsoncEnabled && packageJsonEnabled;
|
|
43
|
+
if (sortPackageJsonExtendsEnabled) {
|
|
44
|
+
const sortPackageJsonOptions = typeof options?.sortPackageJsonExtends !== "object" ? void 0 : options.sortPackageJsonExtends;
|
|
45
|
+
(0, _sort.sortPackageJson)(config, ...(!sortPackageJsonOptions ? [] : [sortPackageJsonOptions]));
|
|
46
|
+
}
|
|
47
|
+
(0, _sort.sortTsconfigJson)(config, options?.sortTsConfigJsonExtends);
|
|
48
|
+
(0, _sort.sortJsonKeys)(config, options?.sortJsonKeysExtends);
|
|
49
|
+
(0, _sort.sortJsonArrayValues)(config, options?.sortJsonArrayValuesExtends);
|
|
30
50
|
const storybookEnabled = Boolean(options?.storybook ?? false);
|
|
31
51
|
if (storybookEnabled) {
|
|
32
52
|
const storybookOptions = typeof options?.storybook !== "object" ? void 0 : options.storybook;
|