@so1ve/eslint-config 4.1.8 → 4.2.1
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/astro.d.mts +8 -0
- package/dist/configs/astro.mjs +44 -0
- package/dist/configs/command.d.mts +6 -0
- package/dist/configs/command.mjs +10 -0
- package/dist/configs/comments.d.mts +6 -0
- package/dist/configs/comments.mjs +19 -0
- package/dist/configs/de-morgan.d.mts +6 -0
- package/dist/configs/de-morgan.mjs +10 -0
- package/dist/configs/formatting.d.mts +6 -0
- package/dist/configs/formatting.mjs +294 -0
- package/dist/configs/html.d.mts +6 -0
- package/dist/configs/html.mjs +37 -0
- package/dist/configs/ignores.d.mts +6 -0
- package/dist/configs/ignores.mjs +14 -0
- package/dist/configs/imports.d.mts +6 -0
- package/dist/configs/imports.mjs +75 -0
- package/dist/configs/index.d.mts +24 -0
- package/dist/configs/index.mjs +26 -0
- package/dist/configs/javascript.d.mts +8 -0
- package/dist/configs/javascript.mjs +326 -0
- package/dist/configs/jsonc.d.mts +6 -0
- package/dist/configs/jsonc.mjs +30 -0
- package/dist/configs/mdx.d.mts +9 -0
- package/dist/configs/mdx.mjs +43 -0
- package/dist/configs/node.d.mts +6 -0
- package/dist/configs/node.mjs +21 -0
- package/dist/configs/only-error.d.mts +6 -0
- package/dist/configs/only-error.mjs +10 -0
- package/dist/configs/perfectionist.d.mts +6 -0
- package/dist/configs/perfectionist.mjs +34 -0
- package/dist/configs/pnpm.d.mts +6 -0
- package/dist/configs/pnpm.mjs +106 -0
- package/dist/configs/promise.d.mts +6 -0
- package/dist/configs/promise.mjs +13 -0
- package/dist/configs/solid.d.mts +9 -0
- package/dist/configs/solid.mjs +24 -0
- package/dist/configs/sort-imports.d.mts +6 -0
- package/dist/configs/sort-imports.mjs +11 -0
- package/dist/configs/test.d.mts +8 -0
- package/dist/configs/test.mjs +46 -0
- package/dist/configs/toml.d.mts +8 -0
- package/dist/configs/toml.mjs +24 -0
- package/dist/configs/typescript.d.mts +10 -0
- package/dist/configs/typescript.mjs +232 -0
- package/dist/configs/unicorn.d.mts +6 -0
- package/dist/configs/unicorn.mjs +61 -0
- package/dist/configs/vue.d.mts +9 -0
- package/dist/configs/vue.mjs +194 -0
- package/dist/configs/yaml.d.mts +8 -0
- package/dist/configs/yaml.mjs +25 -0
- package/dist/factory.d.mts +21 -0
- package/dist/factory.mjs +114 -0
- package/dist/globs.d.mts +31 -0
- package/dist/globs.mjs +80 -0
- package/dist/index.d.mts +30 -16646
- package/dist/index.mjs +28 -2298
- package/dist/plugins.mjs +15 -0
- package/dist/typegen.d.mts +16308 -0
- package/dist/types.d.mts +175 -0
- package/dist/utils.d.mts +30 -0
- package/dist/utils.mjs +32 -0
- package/package.json +4 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigNames } from "./typegen.mjs";
|
|
2
|
+
import { MaybeArray, Options, TypedFlatConfigItem } from "./types.mjs";
|
|
3
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
4
|
+
|
|
5
|
+
//#region src/factory.d.ts
|
|
6
|
+
declare const defaultPluginRenaming: {
|
|
7
|
+
"@html-eslint": string;
|
|
8
|
+
"@stylistic": string;
|
|
9
|
+
"@typescript-eslint": string;
|
|
10
|
+
"import-x": string;
|
|
11
|
+
n: string;
|
|
12
|
+
yml: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Construct an array of ESLint flat config items.
|
|
16
|
+
*/
|
|
17
|
+
declare function so1ve(options?: Options & TypedFlatConfigItem, ...userConfigs: MaybeArray<TypedFlatConfigItem>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
|
|
18
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
19
|
+
declare function getOverrides<K extends keyof Options>(options: Options, key: K): TypedFlatConfigItem["rules"];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ResolvedOptions, defaultPluginRenaming, getOverrides, so1ve };
|
package/dist/factory.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { interopDefault } from "./utils.mjs";
|
|
2
|
+
import { astro } from "./configs/astro.mjs";
|
|
3
|
+
import { command } from "./configs/command.mjs";
|
|
4
|
+
import { comments } from "./configs/comments.mjs";
|
|
5
|
+
import { deMorgan } from "./configs/de-morgan.mjs";
|
|
6
|
+
import { formatting } from "./configs/formatting.mjs";
|
|
7
|
+
import { html } from "./configs/html.mjs";
|
|
8
|
+
import { ignores } from "./configs/ignores.mjs";
|
|
9
|
+
import { imports } from "./configs/imports.mjs";
|
|
10
|
+
import { javascript } from "./configs/javascript.mjs";
|
|
11
|
+
import { jsonc } from "./configs/jsonc.mjs";
|
|
12
|
+
import { mdx } from "./configs/mdx.mjs";
|
|
13
|
+
import { node } from "./configs/node.mjs";
|
|
14
|
+
import { onlyError } from "./configs/only-error.mjs";
|
|
15
|
+
import { perfectionist } from "./configs/perfectionist.mjs";
|
|
16
|
+
import { pnpm } from "./configs/pnpm.mjs";
|
|
17
|
+
import { promise } from "./configs/promise.mjs";
|
|
18
|
+
import { solid } from "./configs/solid.mjs";
|
|
19
|
+
import { sortImports } from "./configs/sort-imports.mjs";
|
|
20
|
+
import { test } from "./configs/test.mjs";
|
|
21
|
+
import { toml } from "./configs/toml.mjs";
|
|
22
|
+
import { typescript } from "./configs/typescript.mjs";
|
|
23
|
+
import { unicorn } from "./configs/unicorn.mjs";
|
|
24
|
+
import { vue } from "./configs/vue.mjs";
|
|
25
|
+
import { yaml } from "./configs/yaml.mjs";
|
|
26
|
+
import "./configs/index.mjs";
|
|
27
|
+
import { findUpSync } from "find-up-simple";
|
|
28
|
+
import fs from "node:fs";
|
|
29
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
30
|
+
import { isPackageExists } from "local-pkg";
|
|
31
|
+
|
|
32
|
+
//#region src/factory.ts
|
|
33
|
+
const flatConfigProps = [
|
|
34
|
+
"files",
|
|
35
|
+
"ignores",
|
|
36
|
+
"languageOptions",
|
|
37
|
+
"linterOptions",
|
|
38
|
+
"processor",
|
|
39
|
+
"plugins",
|
|
40
|
+
"rules",
|
|
41
|
+
"settings"
|
|
42
|
+
];
|
|
43
|
+
const VuePackages = [
|
|
44
|
+
"vue",
|
|
45
|
+
"nuxt",
|
|
46
|
+
"vitepress",
|
|
47
|
+
"@slidev/cli"
|
|
48
|
+
];
|
|
49
|
+
const defaultPluginRenaming = {
|
|
50
|
+
"@html-eslint": "html",
|
|
51
|
+
"@stylistic": "style",
|
|
52
|
+
"@typescript-eslint": "ts",
|
|
53
|
+
"import-x": "import",
|
|
54
|
+
"n": "node",
|
|
55
|
+
"yml": "yaml"
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Construct an array of ESLint flat config items.
|
|
59
|
+
*/
|
|
60
|
+
function so1ve(options = {}, ...userConfigs) {
|
|
61
|
+
const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], pnpm: enablePnpm = !!findUpSync("pnpm-workspace.yaml"), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
62
|
+
const configs = [];
|
|
63
|
+
if (enableGitignore) if (typeof enableGitignore === "boolean") {
|
|
64
|
+
if (fs.existsSync(".gitignore")) configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
65
|
+
} else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
66
|
+
configs.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command(), deMorgan());
|
|
67
|
+
if (enablePnpm) configs.push(pnpm({
|
|
68
|
+
json: options.jsonc !== false,
|
|
69
|
+
yaml: options.yaml !== false,
|
|
70
|
+
...typeof enablePnpm === "boolean" ? {} : enablePnpm
|
|
71
|
+
}));
|
|
72
|
+
if (enableVue) componentExts.push("vue");
|
|
73
|
+
if (enableAstro) componentExts.push("astro");
|
|
74
|
+
if (enableTypeScript) configs.push(typescript({
|
|
75
|
+
componentExts,
|
|
76
|
+
overrides: getOverrides(options, "typescript")
|
|
77
|
+
}));
|
|
78
|
+
if (options.test ?? true) configs.push(test({ overrides: getOverrides(options, "test") }));
|
|
79
|
+
if (enableAstro) configs.push(astro({ overrides: getOverrides(options, "astro") }));
|
|
80
|
+
if (enableVue) configs.push(vue({
|
|
81
|
+
overrides: getOverrides(options, "vue"),
|
|
82
|
+
typescript: !!enableTypeScript
|
|
83
|
+
}));
|
|
84
|
+
if (enableSolid) configs.push(solid({
|
|
85
|
+
overrides: getOverrides(options, "solid"),
|
|
86
|
+
typescript: !!enableTypeScript
|
|
87
|
+
}));
|
|
88
|
+
if (options.formatting ?? true) configs.push(formatting(options));
|
|
89
|
+
if (options.perfectionist ?? true) configs.push(perfectionist());
|
|
90
|
+
if (options.html ?? true) configs.push(html());
|
|
91
|
+
if (options.jsonc ?? true) configs.push(jsonc());
|
|
92
|
+
if (options.toml ?? true) configs.push(toml({ overrides: getOverrides(options, "toml") }));
|
|
93
|
+
if (options.yaml ?? true) configs.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
94
|
+
if (options.mdx ?? true) configs.push(mdx({
|
|
95
|
+
componentExts,
|
|
96
|
+
overrides: getOverrides(options, "mdx")
|
|
97
|
+
}));
|
|
98
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
99
|
+
if (key in options) acc[key] = options[key];
|
|
100
|
+
return acc;
|
|
101
|
+
}, {});
|
|
102
|
+
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
103
|
+
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
104
|
+
}
|
|
105
|
+
function getOverrides(options, key) {
|
|
106
|
+
const sub = typeof options[key] === "boolean" ? {} : options[key] ?? {};
|
|
107
|
+
return {
|
|
108
|
+
...options.overrides?.[key],
|
|
109
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { defaultPluginRenaming, getOverrides, so1ve };
|
package/dist/globs.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/globs.d.ts
|
|
2
|
+
declare const GLOB_SRC_EXT: string;
|
|
3
|
+
declare const GLOB_SRC: string;
|
|
4
|
+
declare const GLOB_JS: string;
|
|
5
|
+
declare const GLOB_JSX: string;
|
|
6
|
+
declare const GLOB_TS: string;
|
|
7
|
+
declare const GLOB_TSX: string;
|
|
8
|
+
declare const GLOB_DTS: string;
|
|
9
|
+
declare const GLOB_STYLE: string;
|
|
10
|
+
declare const GLOB_CSS: string;
|
|
11
|
+
declare const GLOB_LESS: string;
|
|
12
|
+
declare const GLOB_SCSS: string;
|
|
13
|
+
declare const GLOB_JSON: string;
|
|
14
|
+
declare const GLOB_JSON5: string;
|
|
15
|
+
declare const GLOB_JSONC: string;
|
|
16
|
+
declare const GLOB_ESLINTRC: string;
|
|
17
|
+
declare const GLOB_MARKDOWN: string;
|
|
18
|
+
declare const GLOB_ASTRO: string;
|
|
19
|
+
declare const GLOB_ASTRO_TS: string;
|
|
20
|
+
declare const GLOB_VUE: string;
|
|
21
|
+
declare const GLOB_YAML: string;
|
|
22
|
+
declare const GLOB_TOML: string;
|
|
23
|
+
declare const GLOB_HTML: string;
|
|
24
|
+
declare const GLOB_PACKAGEJSON: string;
|
|
25
|
+
declare const GLOB_TSCONFIG: string[];
|
|
26
|
+
declare const GLOB_MARKDOWN_CODE: string;
|
|
27
|
+
declare const GLOB_TESTS: string[];
|
|
28
|
+
declare const GLOB_ALL_SRC: string[];
|
|
29
|
+
declare const GLOB_EXCLUDE: string[];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML };
|
package/dist/globs.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region src/globs.ts
|
|
2
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
3
|
+
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
4
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
5
|
+
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
6
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
7
|
+
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
8
|
+
const GLOB_DTS = "**/*.d.?([cm])tsx";
|
|
9
|
+
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
10
|
+
const GLOB_CSS = "**/*.css";
|
|
11
|
+
const GLOB_LESS = "**/*.less";
|
|
12
|
+
const GLOB_SCSS = "**/*.scss";
|
|
13
|
+
const GLOB_JSON = "**/*.json";
|
|
14
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
15
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
16
|
+
const GLOB_ESLINTRC = "**/.eslintrc";
|
|
17
|
+
const GLOB_MARKDOWN = "**/*.md?(x)";
|
|
18
|
+
const GLOB_ASTRO = "**/*.astro";
|
|
19
|
+
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
20
|
+
const GLOB_VUE = "**/*.vue";
|
|
21
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
22
|
+
const GLOB_TOML = "**/*.toml";
|
|
23
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
24
|
+
const GLOB_PACKAGEJSON = "**/package.json";
|
|
25
|
+
const GLOB_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
26
|
+
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/**`;
|
|
27
|
+
const GLOB_TESTS = [
|
|
28
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
29
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
30
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
31
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
32
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
33
|
+
];
|
|
34
|
+
const GLOB_ALL_SRC = [
|
|
35
|
+
GLOB_SRC,
|
|
36
|
+
GLOB_STYLE,
|
|
37
|
+
GLOB_JSON,
|
|
38
|
+
GLOB_JSON5,
|
|
39
|
+
GLOB_ESLINTRC,
|
|
40
|
+
GLOB_MARKDOWN,
|
|
41
|
+
GLOB_VUE,
|
|
42
|
+
GLOB_YAML,
|
|
43
|
+
GLOB_HTML
|
|
44
|
+
];
|
|
45
|
+
const GLOB_EXCLUDE = [
|
|
46
|
+
"**/node_modules",
|
|
47
|
+
"**/dist",
|
|
48
|
+
"**/out",
|
|
49
|
+
"**/output",
|
|
50
|
+
"**/package-lock.json",
|
|
51
|
+
"**/yarn.lock",
|
|
52
|
+
"**/pnpm-lock.yaml",
|
|
53
|
+
"**/bun.lockb",
|
|
54
|
+
"**/coverage",
|
|
55
|
+
"**/temp",
|
|
56
|
+
"**/.vitepress/cache",
|
|
57
|
+
"**/.nuxt",
|
|
58
|
+
"**/.nitro",
|
|
59
|
+
"**/.vercel",
|
|
60
|
+
"**/.netlify",
|
|
61
|
+
"**/.output",
|
|
62
|
+
"**/.vercel",
|
|
63
|
+
"**/.changeset",
|
|
64
|
+
"**/.idea",
|
|
65
|
+
"**/.vite-inspect",
|
|
66
|
+
"**/.yarn",
|
|
67
|
+
"**/CHANGELOG*.md",
|
|
68
|
+
"**/*.min.*",
|
|
69
|
+
"**/LICENSE*",
|
|
70
|
+
"**/__snapshots__",
|
|
71
|
+
"**/auto-import?(s).d.ts",
|
|
72
|
+
"**/components.d.ts",
|
|
73
|
+
"**/*.vue.js",
|
|
74
|
+
"**/*.vue.jsx",
|
|
75
|
+
"**/*.vue.ts",
|
|
76
|
+
"**/*.vue.tsx"
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML };
|