@vp-tw/eslint-config 0.0.23 → 0.0.25
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/mdx.js +3 -4
- package/dist/configs/packageJson.js +4 -3
- package/dist/configs/prettier.js +2 -3
- package/dist/configs/reactCompiler.d.ts +2 -2
- package/dist/configs/reactCompiler.js +3 -4
- package/dist/configs/storybook.js +3 -4
- package/dist/eslint-typegen.d.ts +1 -1
- package/dist/esm/configs/mdx.mjs +3 -3
- package/dist/esm/configs/packageJson.mjs +4 -2
- package/dist/esm/configs/prettier.mjs +6 -9
- package/dist/esm/configs/reactCompiler.d.ts +2 -2
- package/dist/esm/configs/reactCompiler.mjs +3 -3
- package/dist/esm/configs/storybook.mjs +3 -3
- package/dist/esm/eslint-typegen.d.ts +1 -1
- package/dist/esm/extends/imports.mjs +10 -13
- package/dist/esm/extends/javascript.mjs +6 -3
- package/dist/esm/extends/jsonc.mjs +10 -7
- package/dist/esm/extends/react.mjs +7 -4
- package/dist/esm/extends/sort.d.ts +11 -19
- package/dist/esm/extends/sort.mjs +65 -76
- package/dist/esm/extends/typescript.mjs +6 -3
- package/dist/esm/extends/yaml.mjs +7 -4
- package/dist/esm/globs.d.ts +2 -1
- package/dist/esm/globs.mjs +3 -1
- package/dist/esm/types.d.ts +8 -2
- package/dist/esm/utils/mergeConfig.d.ts +3 -0
- package/dist/esm/utils/mergeConfig.mjs +56 -0
- package/dist/esm/vdustr.d.ts +10 -11
- package/dist/esm/vdustr.mjs +37 -34
- package/dist/extends/imports.js +6 -7
- package/dist/extends/javascript.js +3 -4
- package/dist/extends/jsonc.js +5 -6
- package/dist/extends/react.js +4 -5
- package/dist/extends/sort.d.ts +11 -19
- package/dist/extends/sort.js +42 -54
- package/dist/extends/typescript.js +3 -4
- package/dist/extends/yaml.js +4 -4
- package/dist/globs.d.ts +2 -1
- package/dist/globs.js +3 -2
- package/dist/types.d.ts +8 -2
- package/dist/utils/mergeConfig.d.ts +3 -0
- package/dist/utils/mergeConfig.js +47 -0
- package/dist/vdustr.d.ts +10 -11
- package/dist/vdustr.js +27 -30
- package/package.json +1 -2
package/dist/configs/mdx.js
CHANGED
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.mdx = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var _defu = _interopRequireDefault(require("defu"));
|
|
9
8
|
var _esToolkit = require("es-toolkit");
|
|
9
|
+
var _mergeConfig = require("../utils/mergeConfig");
|
|
10
10
|
var _renameRules = require("../utils/renameRules");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
const mdx = async ({
|
|
13
12
|
codeBlocks = true,
|
|
14
13
|
processorOptions,
|
|
@@ -28,7 +27,7 @@ const mdx = async ({
|
|
|
28
27
|
}),
|
|
29
28
|
name: "vdustr/mdx/processor"
|
|
30
29
|
};
|
|
31
|
-
const rulesConfig = (0,
|
|
30
|
+
const rulesConfig = (0, _mergeConfig.mergeConfig)(options.mdx, {
|
|
32
31
|
ignores: [
|
|
33
32
|
/**
|
|
34
33
|
* Handled by `@eslint/markdown`.
|
|
@@ -42,7 +41,7 @@ const mdx = async ({
|
|
|
42
41
|
});
|
|
43
42
|
const configs = [setupConfig, processorConfig, rulesConfig];
|
|
44
43
|
if (codeBlocks) {
|
|
45
|
-
const codeBlocksConfig = (0,
|
|
44
|
+
const codeBlocksConfig = (0, _mergeConfig.mergeConfig)(codeBlocksOptions, {
|
|
46
45
|
rules: {
|
|
47
46
|
"import/no-default-export": "off"
|
|
48
47
|
},
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.packageJson = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var _defu = _interopRequireDefault(require("defu"));
|
|
9
8
|
var _esToolkit = require("es-toolkit");
|
|
10
|
-
|
|
9
|
+
var _mergeConfig = require("../utils/mergeConfig");
|
|
10
|
+
var _renameRules = require("../utils/renameRules");
|
|
11
11
|
const packageJson = async options => {
|
|
12
12
|
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-package-json"]);
|
|
13
13
|
const packageJson2 = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-package-json/configs/recommended")));
|
|
@@ -15,8 +15,9 @@ const packageJson = async options => {
|
|
|
15
15
|
plugins: packageJson2.plugins,
|
|
16
16
|
name: "vdustr/package-json/setup"
|
|
17
17
|
};
|
|
18
|
-
const packageJsonRulesConfig = (0,
|
|
18
|
+
const packageJsonRulesConfig = (0, _mergeConfig.mergeConfig)(options?.packageJson, {
|
|
19
19
|
...(0, _esToolkit.omit)(packageJson2, ["name", "plugins"]),
|
|
20
|
+
rules: (0, _renameRules.renameRules)(packageJson2.rules),
|
|
20
21
|
name: "vdustr/package-json/rules"
|
|
21
22
|
});
|
|
22
23
|
return [packageJsonSetupConfig, packageJsonRulesConfig];
|
package/dist/configs/prettier.js
CHANGED
|
@@ -5,13 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.prettier = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var
|
|
8
|
+
var _mergeConfig = require("../utils/mergeConfig");
|
|
9
9
|
var _renameRules = require("../utils/renameRules");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
const prettier = async options => {
|
|
12
11
|
await (0, _eslintConfig.ensurePackages)(["eslint-config-prettier"]);
|
|
13
12
|
const eslintConfigPrettier = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-config-prettier")));
|
|
14
|
-
const rulesConfig = (0,
|
|
13
|
+
const rulesConfig = (0, _mergeConfig.mergeConfig)(options?.prettier, {
|
|
15
14
|
...eslintConfigPrettier,
|
|
16
15
|
rules: (0, _renameRules.renameRules)(eslintConfigPrettier.rules),
|
|
17
16
|
name: "vdustr/prettier/rules"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ConfigOverrides
|
|
1
|
+
import type { ConfigOverrides } from "../types";
|
|
2
2
|
declare namespace reactCompiler {
|
|
3
3
|
interface Options {
|
|
4
4
|
setup?: ConfigOverrides;
|
|
5
5
|
reactCompiler?: ConfigOverrides;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
declare const reactCompiler: (options?: reactCompiler.Options) => Promise<TypedFlatConfigItem[]>;
|
|
8
|
+
declare const reactCompiler: (options?: reactCompiler.Options) => Promise<import("../types").TypedFlatConfigItem[]>;
|
|
9
9
|
export { reactCompiler };
|
|
@@ -4,17 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.reactCompiler = void 0;
|
|
7
|
-
var _defu = _interopRequireDefault(require("defu"));
|
|
8
7
|
var _eslintPluginReactCompiler = require("../lib/eslint-plugin-react-compiler");
|
|
9
|
-
|
|
8
|
+
var _mergeConfig = require("../utils/mergeConfig");
|
|
10
9
|
const reactCompiler = async options => {
|
|
11
|
-
const reactCompilerSetupConfig = (0,
|
|
10
|
+
const reactCompilerSetupConfig = (0, _mergeConfig.mergeConfig)(options?.setup, {
|
|
12
11
|
name: "vdustr/react/react-compiler/setup",
|
|
13
12
|
plugins: {
|
|
14
13
|
"react-compiler": await (0, _eslintPluginReactCompiler.reactCompiler)()
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
|
-
const reactCompilerRulesConfig = (0,
|
|
16
|
+
const reactCompilerRulesConfig = (0, _mergeConfig.mergeConfig)(options?.reactCompiler, {
|
|
18
17
|
name: "vdustr/react/react-compiler/rules",
|
|
19
18
|
rules: {
|
|
20
19
|
"react-compiler/react-compiler": "error"
|
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.storybook = void 0;
|
|
7
7
|
var _eslintConfig = require("@antfu/eslint-config");
|
|
8
|
-
var _defu = _interopRequireDefault(require("defu"));
|
|
9
8
|
var _esToolkit = require("es-toolkit");
|
|
9
|
+
var _mergeConfig = require("../utils/mergeConfig");
|
|
10
10
|
var _renameRules = require("../utils/renameRules");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
const storybook = async options => {
|
|
13
12
|
await (0, _eslintConfig.ensurePackages)(["eslint-plugin-storybook"]);
|
|
14
13
|
const storybookPlugin = await (0, _eslintConfig.interopDefault)(Promise.resolve().then(() => require("eslint-plugin-storybook")));
|
|
@@ -25,7 +24,7 @@ const storybook = async options => {
|
|
|
25
24
|
...(0, _esToolkit.pick)(originalSetupConfig, ["plugins"]),
|
|
26
25
|
name: "vdustr/stroybook/setup"
|
|
27
26
|
};
|
|
28
|
-
const storyRulesConfig = (0,
|
|
27
|
+
const storyRulesConfig = (0, _mergeConfig.mergeConfig)(options?.stories, {
|
|
29
28
|
name: "vdustr/storybook/stories/rules",
|
|
30
29
|
rules: {
|
|
31
30
|
"import/no-default-export": "off"
|
|
@@ -38,7 +37,7 @@ const storybook = async options => {
|
|
|
38
37
|
...originalCsfStrictConfig.rules
|
|
39
38
|
})
|
|
40
39
|
});
|
|
41
|
-
const mainRulesConfig = (0,
|
|
40
|
+
const mainRulesConfig = (0, _mergeConfig.mergeConfig)(options?.main, {
|
|
42
41
|
name: "vdustr/storybook/main/rules"
|
|
43
42
|
}, {
|
|
44
43
|
...originalMainRulesConfig,
|
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' | 'vdustr/javascript/rules' | 'vdustr/imports/rules' | 'vdustr/imports/no-default-export/rules' | 'vdustr/typescript/rules' | 'vdustr/
|
|
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/react/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/jsonc/rules' | 'vdustr/sort/json-keys' | 'vdustr/sort/json-array-values' | 'vdustr/sort/tsconfig-json' | 'vdustr/yaml/rules' | 'vdustr/yaml/sort-keys/rules'
|
|
103
103
|
|
package/dist/esm/configs/mdx.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
GLOB_MARKDOWN_CODE,
|
|
5
5
|
interopDefault
|
|
6
6
|
} from "@antfu/eslint-config";
|
|
7
|
-
import defu from "defu";
|
|
8
7
|
import { omit, pick } from "es-toolkit";
|
|
8
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
9
9
|
import { renameRules } from "../utils/renameRules.mjs";
|
|
10
10
|
const mdx = async ({
|
|
11
11
|
codeBlocks = true,
|
|
@@ -26,7 +26,7 @@ const mdx = async ({
|
|
|
26
26
|
}),
|
|
27
27
|
name: "vdustr/mdx/processor"
|
|
28
28
|
};
|
|
29
|
-
const rulesConfig =
|
|
29
|
+
const rulesConfig = mergeConfig(
|
|
30
30
|
options.mdx,
|
|
31
31
|
{
|
|
32
32
|
ignores: [
|
|
@@ -45,7 +45,7 @@ const mdx = async ({
|
|
|
45
45
|
);
|
|
46
46
|
const configs = [setupConfig, processorConfig, rulesConfig];
|
|
47
47
|
if (codeBlocks) {
|
|
48
|
-
const codeBlocksConfig =
|
|
48
|
+
const codeBlocksConfig = mergeConfig(
|
|
49
49
|
codeBlocksOptions,
|
|
50
50
|
{
|
|
51
51
|
rules: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
-
import defu from "defu";
|
|
3
2
|
import { omit } from "es-toolkit";
|
|
3
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
4
|
+
import { renameRules } from "../utils/renameRules.mjs";
|
|
4
5
|
const packageJson = async (options) => {
|
|
5
6
|
await ensurePackages(["eslint-plugin-package-json"]);
|
|
6
7
|
const packageJson2 = await interopDefault(
|
|
@@ -10,8 +11,9 @@ const packageJson = async (options) => {
|
|
|
10
11
|
plugins: packageJson2.plugins,
|
|
11
12
|
name: "vdustr/package-json/setup"
|
|
12
13
|
};
|
|
13
|
-
const packageJsonRulesConfig =
|
|
14
|
+
const packageJsonRulesConfig = mergeConfig(options?.packageJson, {
|
|
14
15
|
...omit(packageJson2, ["name", "plugins"]),
|
|
16
|
+
rules: renameRules(packageJson2.rules),
|
|
15
17
|
name: "vdustr/package-json/rules"
|
|
16
18
|
});
|
|
17
19
|
return [packageJsonSetupConfig, packageJsonRulesConfig];
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
-
import
|
|
2
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
3
3
|
import { renameRules } from "../utils/renameRules.mjs";
|
|
4
4
|
const prettier = async (options) => {
|
|
5
5
|
await ensurePackages(["eslint-config-prettier"]);
|
|
6
6
|
const eslintConfigPrettier = await interopDefault(
|
|
7
7
|
import("eslint-config-prettier")
|
|
8
8
|
);
|
|
9
|
-
const rulesConfig =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name: "vdustr/prettier/rules"
|
|
15
|
-
}
|
|
16
|
-
);
|
|
9
|
+
const rulesConfig = mergeConfig(options?.prettier, {
|
|
10
|
+
...eslintConfigPrettier,
|
|
11
|
+
rules: renameRules(eslintConfigPrettier.rules),
|
|
12
|
+
name: "vdustr/prettier/rules"
|
|
13
|
+
});
|
|
17
14
|
return rulesConfig;
|
|
18
15
|
};
|
|
19
16
|
export { prettier };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ConfigOverrides
|
|
1
|
+
import type { ConfigOverrides } from "../types";
|
|
2
2
|
declare namespace reactCompiler {
|
|
3
3
|
interface Options {
|
|
4
4
|
setup?: ConfigOverrides;
|
|
5
5
|
reactCompiler?: ConfigOverrides;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
declare const reactCompiler: (options?: reactCompiler.Options) => Promise<TypedFlatConfigItem[]>;
|
|
8
|
+
declare const reactCompiler: (options?: reactCompiler.Options) => Promise<import("../types").TypedFlatConfigItem[]>;
|
|
9
9
|
export { reactCompiler };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
1
|
import { reactCompiler as importLib } from "../lib/eslint-plugin-react-compiler.mjs";
|
|
2
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
3
3
|
const reactCompiler = async (options) => {
|
|
4
|
-
const reactCompilerSetupConfig =
|
|
4
|
+
const reactCompilerSetupConfig = mergeConfig(options?.setup, {
|
|
5
5
|
name: "vdustr/react/react-compiler/setup",
|
|
6
6
|
plugins: {
|
|
7
7
|
"react-compiler": await importLib()
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
const reactCompilerRulesConfig =
|
|
10
|
+
const reactCompilerRulesConfig = mergeConfig(options?.reactCompiler, {
|
|
11
11
|
name: "vdustr/react/react-compiler/rules",
|
|
12
12
|
rules: {
|
|
13
13
|
"react-compiler/react-compiler": "error"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
|
-
import defu from "defu";
|
|
3
2
|
import { pick } from "es-toolkit";
|
|
3
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
4
4
|
import { renameRules } from "../utils/renameRules.mjs";
|
|
5
5
|
const storybook = async (options) => {
|
|
6
6
|
await ensurePackages(["eslint-plugin-storybook"]);
|
|
@@ -20,7 +20,7 @@ const storybook = async (options) => {
|
|
|
20
20
|
...pick(originalSetupConfig, ["plugins"]),
|
|
21
21
|
name: "vdustr/stroybook/setup"
|
|
22
22
|
};
|
|
23
|
-
const storyRulesConfig =
|
|
23
|
+
const storyRulesConfig = mergeConfig(
|
|
24
24
|
options?.stories,
|
|
25
25
|
{
|
|
26
26
|
name: "vdustr/storybook/stories/rules",
|
|
@@ -37,7 +37,7 @@ const storybook = async (options) => {
|
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
|
-
const mainRulesConfig =
|
|
40
|
+
const mainRulesConfig = mergeConfig(
|
|
41
41
|
options?.main,
|
|
42
42
|
{
|
|
43
43
|
name: "vdustr/storybook/main/rules"
|
|
@@ -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' | 'vdustr/javascript/rules' | 'vdustr/imports/rules' | 'vdustr/imports/no-default-export/rules' | 'vdustr/typescript/rules' | 'vdustr/
|
|
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/react/rules' | 'vdustr/react/react-compiler/setup' | 'vdustr/react/react-compiler/rules' | 'vdustr/jsonc/rules' | 'vdustr/sort/json-keys' | 'vdustr/sort/json-array-values' | 'vdustr/sort/tsconfig-json' | 'vdustr/yaml/rules' | 'vdustr/yaml/sort-keys/rules'
|
|
103
103
|
|
|
@@ -6,16 +6,19 @@ import {
|
|
|
6
6
|
GLOB_TS,
|
|
7
7
|
GLOB_TSX
|
|
8
8
|
} from "@antfu/eslint-config";
|
|
9
|
-
import defu from "defu";
|
|
10
9
|
import { omit, pick } from "es-toolkit";
|
|
11
|
-
import { GLOB_CONFIG_JS } from "../globs.mjs";
|
|
10
|
+
import { GLOB_CONFIG_JS, GLOB_VITEST_WORKSPACE } from "../globs.mjs";
|
|
12
11
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
12
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
13
13
|
import { ignoreKeys } from "./_utils.mjs";
|
|
14
14
|
const imports = (composer, options) => {
|
|
15
15
|
extendsConfig(composer, "antfu/imports/rules", (config) => {
|
|
16
|
-
const modifiedConfig =
|
|
16
|
+
const modifiedConfig = mergeConfig(
|
|
17
|
+
pick(options?.imports ?? {}, ["files", "ignores"]),
|
|
18
|
+
config
|
|
19
|
+
);
|
|
17
20
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
18
|
-
const rulesConfig =
|
|
21
|
+
const rulesConfig = mergeConfig(
|
|
19
22
|
omit(options?.imports ?? {}, ["files", "ignores"]),
|
|
20
23
|
{
|
|
21
24
|
name: "vdustr/imports/rules",
|
|
@@ -33,7 +36,7 @@ const imports = (composer, options) => {
|
|
|
33
36
|
},
|
|
34
37
|
omittedConfig
|
|
35
38
|
);
|
|
36
|
-
const noDefaultExportConfig =
|
|
39
|
+
const noDefaultExportConfig = mergeConfig(
|
|
37
40
|
options?.noDefaultExport,
|
|
38
41
|
{
|
|
39
42
|
name: "vdustr/imports/no-default-export/rules",
|
|
@@ -46,19 +49,13 @@ const imports = (composer, options) => {
|
|
|
46
49
|
*/
|
|
47
50
|
"import/no-default-export": "error"
|
|
48
51
|
},
|
|
49
|
-
files: [
|
|
50
|
-
GLOB_JS,
|
|
51
|
-
GLOB_JSX,
|
|
52
|
-
GLOB_TS,
|
|
53
|
-
GLOB_TSX,
|
|
54
|
-
...options?.noDefaultExport?.files || []
|
|
55
|
-
],
|
|
52
|
+
files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
|
|
56
53
|
ignores: [
|
|
57
54
|
// Configuration files
|
|
58
55
|
GLOB_CONFIG_JS,
|
|
59
56
|
GLOB_MARKDOWN_CODE,
|
|
60
57
|
GLOB_ASTRO_TS,
|
|
61
|
-
|
|
58
|
+
GLOB_VITEST_WORKSPACE
|
|
62
59
|
]
|
|
63
60
|
},
|
|
64
61
|
omit(omittedConfig, ["files", "ignores"])
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
1
|
import { omit, pick } from "es-toolkit";
|
|
3
2
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
3
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
4
4
|
import { ignoreKeys } from "./_utils.mjs";
|
|
5
5
|
const javascript = (composer, options) => {
|
|
6
6
|
extendsConfig(composer, "antfu/javascript/rules", (config) => {
|
|
7
|
-
const modifiedConfig =
|
|
7
|
+
const modifiedConfig = mergeConfig(
|
|
8
|
+
pick(options?.javascript ?? {}, ["files", "ignores"]),
|
|
9
|
+
config
|
|
10
|
+
);
|
|
8
11
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
9
|
-
const rulesConfig =
|
|
12
|
+
const rulesConfig = mergeConfig(
|
|
10
13
|
omit(options?.javascript ?? {}, ["files", "ignores"]),
|
|
11
14
|
{
|
|
12
15
|
name: "vdustr/javascript/rules",
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
1
|
import { omit, pick } from "es-toolkit";
|
|
3
|
-
import { GLOB_CODE_WORKSPACE
|
|
2
|
+
import { GLOB_CODE_WORKSPACE } from "../globs.mjs";
|
|
4
3
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
4
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
5
5
|
import { ignoreKeys } from "./_utils.mjs";
|
|
6
6
|
const jsonc = async (composer, options) => {
|
|
7
7
|
extendsConfig(composer, "antfu/jsonc/rules", (config) => {
|
|
8
|
-
const modifiedConfig =
|
|
9
|
-
files
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const modifiedConfig = mergeConfig(
|
|
9
|
+
pick(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
10
|
+
{
|
|
11
|
+
...config,
|
|
12
|
+
files: [...config.files ?? [], GLOB_CODE_WORKSPACE]
|
|
13
|
+
}
|
|
14
|
+
);
|
|
12
15
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
13
|
-
const rulesConfig =
|
|
16
|
+
const rulesConfig = mergeConfig(
|
|
14
17
|
omit(options?.jsonc ?? {}, ["files", "ignores"]),
|
|
15
18
|
{
|
|
16
19
|
name: "vdustr/jsonc/rules",
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
1
|
import { omit, pick } from "es-toolkit";
|
|
3
2
|
import { reactCompiler } from "../configs/reactCompiler.mjs";
|
|
4
3
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
4
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
5
5
|
import { ignoreKeys } from "./_utils.mjs";
|
|
6
6
|
const react = (composer, options) => {
|
|
7
7
|
extendsConfig(composer, "antfu/react/rules", async (config) => {
|
|
8
|
-
const modifiedConfig =
|
|
8
|
+
const modifiedConfig = mergeConfig(
|
|
9
|
+
pick(options?.react ?? {}, ["files", "ignores"]),
|
|
10
|
+
config
|
|
11
|
+
);
|
|
9
12
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
10
|
-
const rulesConfig =
|
|
13
|
+
const rulesConfig = mergeConfig(
|
|
11
14
|
omit(options?.react ?? {}, ["files", "ignores"]),
|
|
12
15
|
{
|
|
13
16
|
name: "vdustr/react/rules",
|
|
@@ -19,7 +22,7 @@ const react = (composer, options) => {
|
|
|
19
22
|
);
|
|
20
23
|
const reactCompilerConfigs = await reactCompiler({
|
|
21
24
|
setup: options?.reactCompilerSetup ?? {},
|
|
22
|
-
reactCompiler:
|
|
25
|
+
reactCompiler: mergeConfig(
|
|
23
26
|
options?.reactCompiler,
|
|
24
27
|
pick(omittedConfig, ["files", "ignores"])
|
|
25
28
|
)
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import type { ConfigOverrides, VpComposer } from "../types";
|
|
2
|
-
declare namespace
|
|
3
|
-
interface Options {
|
|
4
|
-
sortKeys?: ConfigOverrides;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
declare const sortJsonKeys: (composer: VpComposer, options?: sortJsonKeys.Options) => Promise<void>;
|
|
8
|
-
declare namespace sortPackageJson {
|
|
2
|
+
declare namespace sort {
|
|
9
3
|
interface Options {
|
|
4
|
+
jsoncSortKeys?: ConfigOverrides;
|
|
5
|
+
jsoncSortArrayValues?: ConfigOverrides;
|
|
10
6
|
packageJson?: ConfigOverrides;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
declare const sortPackageJson: (composer: VpComposer, options?: sortPackageJson.Options) => Promise<void>;
|
|
14
|
-
declare namespace sortTsconfigJson {
|
|
15
|
-
interface Options {
|
|
16
7
|
tsconfigJson?: ConfigOverrides;
|
|
17
8
|
}
|
|
18
9
|
}
|
|
19
|
-
declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
declare const sortJsonArrayValues: (composer: VpComposer, options?:
|
|
10
|
+
declare const sortJsonKeys: (composer: VpComposer, options?: sort.Options["jsoncSortKeys"]) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Disable rules conflicting with `eslint-config-package-json`.
|
|
13
|
+
*/
|
|
14
|
+
declare const sortPackageJson: (composer: VpComposer, options?: sort.Options["packageJson"]) => Promise<void>;
|
|
15
|
+
declare const sortTsconfigJson: (composer: VpComposer, options?: sort.Options["tsconfigJson"]) => Promise<void>;
|
|
16
|
+
declare const sortJsonArrayValues: (composer: VpComposer, options?: sort.Options["jsoncSortArrayValues"]) => Promise<void>;
|
|
17
|
+
export type { sort };
|
|
26
18
|
export { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson };
|
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import defu from "defu";
|
|
2
1
|
import { omit, pick } from "es-toolkit";
|
|
3
2
|
import { GLOB_CSPELL_JSON } from "../globs.mjs";
|
|
4
3
|
import { extendsConfig } from "../utils/extendsConfig.mjs";
|
|
4
|
+
import { mergeConfig } from "../utils/mergeConfig.mjs";
|
|
5
5
|
import { ignoreKeys } from "./_utils.mjs";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
order: {
|
|
26
|
-
type: "asc",
|
|
27
|
-
caseSensitive: false,
|
|
28
|
-
natural: true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
omittedConfig
|
|
35
|
-
);
|
|
36
|
-
return [...items, rulesConfig];
|
|
6
|
+
const defaultSortJsonKeys = [
|
|
7
|
+
"error",
|
|
8
|
+
{
|
|
9
|
+
pathPattern: ".*",
|
|
10
|
+
order: {
|
|
11
|
+
type: "asc",
|
|
12
|
+
caseSensitive: false,
|
|
13
|
+
natural: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
const defaultSortJsonArrayValues = [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
pathPattern: ".*",
|
|
21
|
+
order: {
|
|
22
|
+
type: "asc",
|
|
23
|
+
caseSensitive: false,
|
|
24
|
+
natural: true
|
|
37
25
|
}
|
|
38
|
-
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
const sortJsonKeys = async (composer, options) => {
|
|
29
|
+
extendsConfig(composer, "vdustr/jsonc/rules", async (config) => {
|
|
30
|
+
const omittedConfig = omit(config, ignoreKeys);
|
|
31
|
+
const rulesConfig = mergeConfig(
|
|
32
|
+
options,
|
|
33
|
+
{
|
|
34
|
+
name: "vdustr/sort/json-keys",
|
|
35
|
+
rules: {
|
|
36
|
+
"jsonc/sort-keys": defaultSortJsonKeys
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
omittedConfig
|
|
40
|
+
);
|
|
41
|
+
return [config, rulesConfig];
|
|
42
|
+
});
|
|
39
43
|
};
|
|
40
44
|
const sortPackageJson = async (composer, options) => {
|
|
41
45
|
extendsConfig(composer, "antfu/sort/package-json", (config) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
const modifiedConfig = mergeConfig(
|
|
47
|
+
pick(options ?? {}, ["files", "ignores"]),
|
|
48
|
+
config
|
|
49
|
+
);
|
|
45
50
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
46
|
-
const rulesConfig =
|
|
47
|
-
options
|
|
51
|
+
const rulesConfig = mergeConfig(
|
|
52
|
+
options,
|
|
48
53
|
{
|
|
49
54
|
name: "vdustr/sort/package-json",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ruleKeys.map((key) => {
|
|
55
|
-
return [key, "off"];
|
|
56
|
-
})
|
|
57
|
-
)
|
|
55
|
+
rules: {
|
|
56
|
+
"jsonc/sort-array-values": "off",
|
|
57
|
+
"jsonc/sort-keys": "off"
|
|
58
|
+
}
|
|
58
59
|
},
|
|
59
60
|
omittedConfig
|
|
60
61
|
);
|
|
@@ -63,22 +64,18 @@ const sortPackageJson = async (composer, options) => {
|
|
|
63
64
|
};
|
|
64
65
|
const sortTsconfigJson = async (composer, options) => {
|
|
65
66
|
extendsConfig(composer, "antfu/sort/tsconfig-json", (config) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const modifiedConfig = mergeConfig(
|
|
68
|
+
pick(options ?? {}, ["files", "ignores"]),
|
|
69
|
+
config
|
|
70
|
+
);
|
|
69
71
|
const omittedConfig = omit(modifiedConfig, ignoreKeys);
|
|
70
|
-
const rulesConfig =
|
|
71
|
-
options
|
|
72
|
+
const rulesConfig = mergeConfig(
|
|
73
|
+
options,
|
|
72
74
|
{
|
|
73
75
|
name: "vdustr/sort/tsconfig-json",
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
rules: Object.fromEntries(
|
|
78
|
-
ruleKeys.map((key) => {
|
|
79
|
-
return [key, "off"];
|
|
80
|
-
})
|
|
81
|
-
)
|
|
76
|
+
rules: {
|
|
77
|
+
"jsonc/sort-keys": defaultSortJsonKeys
|
|
78
|
+
}
|
|
82
79
|
},
|
|
83
80
|
omittedConfig
|
|
84
81
|
);
|
|
@@ -86,23 +83,15 @@ const sortTsconfigJson = async (composer, options) => {
|
|
|
86
83
|
});
|
|
87
84
|
};
|
|
88
85
|
const sortJsonArrayValues = async (composer, options) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
type: "asc",
|
|
99
|
-
caseSensitive: false,
|
|
100
|
-
natural: true
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}
|
|
86
|
+
extendsConfig(composer, "vdustr/sort/json-keys", async (config) => {
|
|
87
|
+
const sortArrayValuesConfig = mergeConfig(options, {
|
|
88
|
+
name: "vdustr/sort/json-array-values",
|
|
89
|
+
files: [GLOB_CSPELL_JSON],
|
|
90
|
+
rules: {
|
|
91
|
+
"jsonc/sort-array-values": defaultSortJsonArrayValues
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return [config, sortArrayValuesConfig];
|
|
105
95
|
});
|
|
106
|
-
composer.append(sortArrayValuesConfig);
|
|
107
96
|
};
|
|
108
97
|
export { sortJsonArrayValues, sortJsonKeys, sortPackageJson, sortTsconfigJson };
|