@eienjs/eslint-config 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/constants.js +74 -0
- package/dist/cli/constants_generated.js +13 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +3 -268
- package/dist/cli/run.js +77 -0
- package/dist/cli/stages/update_eslint_files.js +39 -0
- package/dist/cli/stages/update_package_json.js +46 -0
- package/dist/cli/stages/update_vscode_settings.js +30 -0
- package/dist/cli/utils.js +23 -0
- package/dist/configs/adonisjs.d.ts +6 -0
- package/dist/configs/adonisjs.js +115 -0
- package/dist/configs/astro.d.ts +6 -0
- package/dist/configs/astro.js +52 -0
- package/dist/configs/command.d.ts +6 -0
- package/dist/configs/command.js +12 -0
- package/dist/configs/comments.d.ts +6 -0
- package/dist/configs/comments.js +19 -0
- package/dist/configs/disables.d.ts +6 -0
- package/dist/configs/disables.js +85 -0
- package/dist/configs/formatters.d.ts +6 -0
- package/dist/configs/formatters.js +134 -0
- package/dist/configs/ignores.d.ts +6 -0
- package/dist/configs/ignores.js +12 -0
- package/dist/configs/imports.d.ts +6 -0
- package/dist/configs/imports.js +28 -0
- package/dist/configs/index.d.ts +25 -95
- package/dist/configs/index.js +25 -1
- package/dist/configs/javascript.d.ts +6 -0
- package/dist/configs/javascript.js +289 -0
- package/dist/configs/jsdoc.d.ts +6 -0
- package/dist/configs/jsdoc.js +34 -0
- package/dist/configs/jsonc.d.ts +6 -0
- package/dist/configs/jsonc.js +71 -0
- package/dist/configs/markdown.d.ts +6 -0
- package/dist/configs/markdown.js +67 -0
- package/dist/configs/node.d.ts +6 -0
- package/dist/configs/node.js +22 -0
- package/dist/configs/nuxt.d.ts +6 -0
- package/dist/configs/nuxt.js +137 -0
- package/dist/configs/perfectionist.d.ts +12 -0
- package/dist/configs/perfectionist.js +56 -0
- package/dist/configs/pnpm.d.ts +6 -0
- package/dist/configs/pnpm.js +33 -0
- package/dist/configs/regexp.d.ts +6 -0
- package/dist/configs/regexp.js +21 -0
- package/dist/configs/sort.d.ts +18 -0
- package/dist/configs/sort.js +239 -0
- package/dist/configs/stylistic.d.ts +8 -0
- package/dist/configs/stylistic.js +76 -0
- package/dist/configs/test.d.ts +6 -0
- package/dist/configs/test.js +42 -0
- package/dist/configs/toml.d.ts +6 -0
- package/dist/configs/toml.js +45 -0
- package/dist/configs/typescript.d.ts +6 -0
- package/dist/configs/typescript.js +237 -0
- package/dist/configs/unicorn.d.ts +6 -0
- package/dist/configs/unicorn.js +42 -0
- package/dist/configs/vue.d.ts +6 -0
- package/dist/configs/vue.js +206 -0
- package/dist/configs/yaml.d.ts +6 -0
- package/dist/configs/yaml.js +83 -0
- package/dist/factory.d.ts +17 -0
- package/dist/factory.js +161 -0
- package/dist/globs.d.ts +32 -0
- package/dist/globs.js +89 -0
- package/dist/index.d.ts +6 -86
- package/dist/index.js +3 -133
- package/dist/package.js +5 -0
- package/dist/plugins.js +9 -0
- package/dist/{types-ClRJcxpY.d.ts → typegen.d.ts} +446 -747
- package/dist/types.d.ts +426 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +62 -0
- package/dist/vendored/prettier_types.d.ts +121 -0
- package/package.json +45 -33
- package/dist/configs-D_4UWxl6.js +0 -2192
package/dist/factory.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { interopDefault, isInEditorEnv } from "./utils.js";
|
|
2
|
+
import { adonisjs } from "./configs/adonisjs.js";
|
|
3
|
+
import { astro } from "./configs/astro.js";
|
|
4
|
+
import { command } from "./configs/command.js";
|
|
5
|
+
import { comments } from "./configs/comments.js";
|
|
6
|
+
import { disables } from "./configs/disables.js";
|
|
7
|
+
import { stylistic } from "./configs/stylistic.js";
|
|
8
|
+
import { formatters } from "./configs/formatters.js";
|
|
9
|
+
import { ignores } from "./configs/ignores.js";
|
|
10
|
+
import { imports } from "./configs/imports.js";
|
|
11
|
+
import { javascript } from "./configs/javascript.js";
|
|
12
|
+
import { jsdoc } from "./configs/jsdoc.js";
|
|
13
|
+
import { jsonc } from "./configs/jsonc.js";
|
|
14
|
+
import { markdown } from "./configs/markdown.js";
|
|
15
|
+
import { node } from "./configs/node.js";
|
|
16
|
+
import { nuxt } from "./configs/nuxt.js";
|
|
17
|
+
import { perfectionist } from "./configs/perfectionist.js";
|
|
18
|
+
import { pnpm } from "./configs/pnpm.js";
|
|
19
|
+
import { regexp } from "./configs/regexp.js";
|
|
20
|
+
import { sortPackageJson, sortTsconfig } from "./configs/sort.js";
|
|
21
|
+
import { test } from "./configs/test.js";
|
|
22
|
+
import { toml } from "./configs/toml.js";
|
|
23
|
+
import { typescript } from "./configs/typescript.js";
|
|
24
|
+
import { unicorn } from "./configs/unicorn.js";
|
|
25
|
+
import { vue } from "./configs/vue.js";
|
|
26
|
+
import { yaml } from "./configs/yaml.js";
|
|
27
|
+
import "./configs/index.js";
|
|
28
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
29
|
+
import { isPackageExists } from "local-pkg";
|
|
30
|
+
|
|
31
|
+
//#region src/factory.ts
|
|
32
|
+
const flatConfigProps = [
|
|
33
|
+
"name",
|
|
34
|
+
"languageOptions",
|
|
35
|
+
"linterOptions",
|
|
36
|
+
"processor",
|
|
37
|
+
"plugins",
|
|
38
|
+
"rules",
|
|
39
|
+
"settings"
|
|
40
|
+
];
|
|
41
|
+
const VuePackages = [
|
|
42
|
+
"vue",
|
|
43
|
+
"nuxt",
|
|
44
|
+
"vitepress",
|
|
45
|
+
"@slidev/cli"
|
|
46
|
+
];
|
|
47
|
+
const defaultPluginRenaming = {
|
|
48
|
+
"import-lite": "import",
|
|
49
|
+
"vitest": "test",
|
|
50
|
+
"yml": "yaml"
|
|
51
|
+
};
|
|
52
|
+
function eienjs(options = {}) {
|
|
53
|
+
const { astro: enableAstro = false, componentExts = [], gitignore: enableGitignore = true, imports: enableImports = true, pnpm: enableCatalogs = false, regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)), adonisjs: enableAdonisjs = false, nuxt: enableNuxt = false } = options;
|
|
54
|
+
let { isInEditor } = options;
|
|
55
|
+
if (isInEditor == null) {
|
|
56
|
+
isInEditor = isInEditorEnv();
|
|
57
|
+
if (isInEditor) console.info("[@eienjs/eslint-config] Detected running in editor, some rules are disabled.");
|
|
58
|
+
}
|
|
59
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
60
|
+
const configs = [];
|
|
61
|
+
if (enableGitignore) if (typeof enableGitignore === "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
62
|
+
name: "eienjs/gitignore",
|
|
63
|
+
strict: false
|
|
64
|
+
})]));
|
|
65
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
66
|
+
name: "eienjs/gitignore",
|
|
67
|
+
...enableGitignore
|
|
68
|
+
})]));
|
|
69
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
70
|
+
configs.push(ignores(options.ignores), javascript({
|
|
71
|
+
isInEditor,
|
|
72
|
+
overrides: getOverrides(options, "javascript")
|
|
73
|
+
}), comments(), node(), jsdoc({ stylistic: stylisticOptions }), imports({ stylistic: stylisticOptions }), command(), perfectionist());
|
|
74
|
+
if (enableImports) configs.push(imports(enableImports === true ? { stylistic: stylisticOptions } : {
|
|
75
|
+
stylistic: stylisticOptions,
|
|
76
|
+
...enableImports
|
|
77
|
+
}));
|
|
78
|
+
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
79
|
+
if (enableVue) componentExts.push("vue");
|
|
80
|
+
if (enableTypeScript) configs.push(typescript({
|
|
81
|
+
...typescriptOptions,
|
|
82
|
+
componentExts,
|
|
83
|
+
stylistic: stylisticOptions,
|
|
84
|
+
overrides: getOverrides(options, "typescript")
|
|
85
|
+
}));
|
|
86
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
87
|
+
...stylisticOptions,
|
|
88
|
+
overrides: getOverrides(options, "stylistic")
|
|
89
|
+
}));
|
|
90
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
91
|
+
if (options.test ?? true) configs.push(test({
|
|
92
|
+
isInEditor,
|
|
93
|
+
overrides: getOverrides(options, "test")
|
|
94
|
+
}));
|
|
95
|
+
if (enableVue) configs.push(vue({
|
|
96
|
+
...resolveSubOptions(options, "vue"),
|
|
97
|
+
overrides: getOverrides(options, "vue"),
|
|
98
|
+
stylistic: stylisticOptions,
|
|
99
|
+
typescript: Boolean(enableTypeScript)
|
|
100
|
+
}));
|
|
101
|
+
if (enableAstro) configs.push(astro({
|
|
102
|
+
overrides: getOverrides(options, "astro"),
|
|
103
|
+
stylistic: stylisticOptions
|
|
104
|
+
}));
|
|
105
|
+
if (enableAdonisjs) configs.push(adonisjs({
|
|
106
|
+
...resolveSubOptions(options, "adonisjs"),
|
|
107
|
+
overrides: getOverrides(options, "adonisjs")
|
|
108
|
+
}));
|
|
109
|
+
if (enableNuxt) configs.push(nuxt({
|
|
110
|
+
...resolveSubOptions(options, "nuxt"),
|
|
111
|
+
overrides: getOverrides(options, "nuxt"),
|
|
112
|
+
stylistic: stylisticOptions
|
|
113
|
+
}));
|
|
114
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
115
|
+
overrides: getOverrides(options, "jsonc"),
|
|
116
|
+
stylistic: stylisticOptions
|
|
117
|
+
}), sortPackageJson(), sortTsconfig());
|
|
118
|
+
if (enableCatalogs) configs.push(pnpm());
|
|
119
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
120
|
+
overrides: getOverrides(options, "yaml"),
|
|
121
|
+
stylistic: stylisticOptions
|
|
122
|
+
}));
|
|
123
|
+
if (options.toml ?? true) configs.push(toml({
|
|
124
|
+
overrides: getOverrides(options, "toml"),
|
|
125
|
+
stylistic: stylisticOptions
|
|
126
|
+
}));
|
|
127
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
128
|
+
componentExts,
|
|
129
|
+
overrides: getOverrides(options, "markdown")
|
|
130
|
+
}));
|
|
131
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
132
|
+
configs.push(disables());
|
|
133
|
+
if ("files" in options) throw new Error([
|
|
134
|
+
"[@eienjs/eslint-config] ",
|
|
135
|
+
"The first argument should not contain the \"files\" property as the options are supposed to be global. ",
|
|
136
|
+
"Place it in the second or later config instead."
|
|
137
|
+
].join(""));
|
|
138
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
139
|
+
if (key in options) acc[key] = options[key];
|
|
140
|
+
return acc;
|
|
141
|
+
}, {});
|
|
142
|
+
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
143
|
+
let composer = new FlatConfigComposer();
|
|
144
|
+
composer = composer.append(...configs).renamePlugins(defaultPluginRenaming);
|
|
145
|
+
if (isInEditor) composer = composer.disableRulesFix([
|
|
146
|
+
"unused-imports/no-unused-imports",
|
|
147
|
+
"test/no-only-tests",
|
|
148
|
+
"prefer-const"
|
|
149
|
+
], { builtinRules: async () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
150
|
+
return composer;
|
|
151
|
+
}
|
|
152
|
+
function resolveSubOptions(options, key) {
|
|
153
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
154
|
+
}
|
|
155
|
+
function getOverrides(options, key) {
|
|
156
|
+
const sub = resolveSubOptions(options, key);
|
|
157
|
+
return { ..."overrides" in sub ? sub.overrides : {} };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
export { defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions };
|
package/dist/globs.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/globs.d.ts
|
|
2
|
+
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
3
|
+
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
4
|
+
declare const GLOB_JS = "**/*.?([cm])js";
|
|
5
|
+
declare const GLOB_JSX = "**/*.?([cm])jsx";
|
|
6
|
+
declare const GLOB_TS = "**/*.?([cm])ts";
|
|
7
|
+
declare const GLOB_TSX = "**/*.?([cm])tsx";
|
|
8
|
+
declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
9
|
+
declare const GLOB_CSS = "**/*.css";
|
|
10
|
+
declare const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
11
|
+
declare const GLOB_LESS = "**/*.less";
|
|
12
|
+
declare const GLOB_SCSS = "**/*.scss";
|
|
13
|
+
declare const GLOB_JSON = "**/*.json";
|
|
14
|
+
declare const GLOB_JSON5 = "**/*.json5";
|
|
15
|
+
declare const GLOB_JSONC = "**/*.jsonc";
|
|
16
|
+
declare const GLOB_MARKDOWN = "**/*.md";
|
|
17
|
+
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
18
|
+
declare const GLOB_VUE = "**/*.vue";
|
|
19
|
+
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
20
|
+
declare const GLOB_TOML = "**/*.toml";
|
|
21
|
+
declare const GLOB_XML = "**/*.xml";
|
|
22
|
+
declare const GLOB_SVG = "**/*.svg";
|
|
23
|
+
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
24
|
+
declare const GLOB_ASTRO = "**/*.astro";
|
|
25
|
+
declare const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
26
|
+
declare const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
|
|
27
|
+
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
28
|
+
declare const GLOB_TESTS: string[];
|
|
29
|
+
declare const GLOB_ALL_SRC: string[];
|
|
30
|
+
declare const GLOB_EXCLUDE: string[];
|
|
31
|
+
//#endregion
|
|
32
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML };
|
package/dist/globs.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//#region src/globs.ts
|
|
2
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
3
|
+
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
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_STYLE = "**/*.{c,le,sc}ss";
|
|
9
|
+
const GLOB_CSS = "**/*.css";
|
|
10
|
+
const GLOB_POSTCSS = "**/*.{p,post}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_MARKDOWN = "**/*.md";
|
|
17
|
+
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
18
|
+
const GLOB_VUE = "**/*.vue";
|
|
19
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
20
|
+
const GLOB_TOML = "**/*.toml";
|
|
21
|
+
const GLOB_XML = "**/*.xml";
|
|
22
|
+
const GLOB_SVG = "**/*.svg";
|
|
23
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
24
|
+
const GLOB_ASTRO = "**/*.astro";
|
|
25
|
+
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
26
|
+
const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
|
|
27
|
+
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
28
|
+
const GLOB_TESTS = [
|
|
29
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
30
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
31
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
32
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
33
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
34
|
+
];
|
|
35
|
+
const GLOB_ALL_SRC = [
|
|
36
|
+
GLOB_SRC,
|
|
37
|
+
GLOB_STYLE,
|
|
38
|
+
GLOB_JSON,
|
|
39
|
+
GLOB_JSON5,
|
|
40
|
+
GLOB_MARKDOWN,
|
|
41
|
+
GLOB_VUE,
|
|
42
|
+
GLOB_YAML,
|
|
43
|
+
GLOB_XML,
|
|
44
|
+
GLOB_HTML
|
|
45
|
+
];
|
|
46
|
+
const GLOB_EXCLUDE = [
|
|
47
|
+
"**/node_modules",
|
|
48
|
+
"**/dist",
|
|
49
|
+
"**/build",
|
|
50
|
+
"**/package-lock.json",
|
|
51
|
+
"**/yarn.lock",
|
|
52
|
+
"**/pnpm-lock.yaml",
|
|
53
|
+
"**/bun.lockb",
|
|
54
|
+
"**/composer.lock",
|
|
55
|
+
"**/composer.json",
|
|
56
|
+
"**/output",
|
|
57
|
+
"**/coverage",
|
|
58
|
+
"**/temp",
|
|
59
|
+
"**/.temp",
|
|
60
|
+
"**/tmp",
|
|
61
|
+
"**/.tmp",
|
|
62
|
+
"**/vendor",
|
|
63
|
+
"**/public",
|
|
64
|
+
"**/.history",
|
|
65
|
+
"**/.vitepress/cache",
|
|
66
|
+
"**/.adonisjs",
|
|
67
|
+
"**/.nuxt",
|
|
68
|
+
"**/.next",
|
|
69
|
+
"**/.svelte-kit",
|
|
70
|
+
"**/.vercel",
|
|
71
|
+
"**/.husky",
|
|
72
|
+
"**/.changeset",
|
|
73
|
+
"**/.idea",
|
|
74
|
+
"**/.cache",
|
|
75
|
+
"**/.output",
|
|
76
|
+
"**/.vite-inspect",
|
|
77
|
+
"**/.yarn",
|
|
78
|
+
"**/.pnpm-store",
|
|
79
|
+
"**/vite.config.*.timestamp-*",
|
|
80
|
+
"**/CHANGELOG*.md",
|
|
81
|
+
"**/*.min.*",
|
|
82
|
+
"**/LICENSE*",
|
|
83
|
+
"**/__snapshots__",
|
|
84
|
+
"**/auto-import?(s).d.ts",
|
|
85
|
+
"**/components.d.ts"
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,86 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'import-lite': string;
|
|
8
|
-
vitest: string;
|
|
9
|
-
yml: string;
|
|
10
|
-
};
|
|
11
|
-
declare function eienjs(options?: OptionsConfig & Omit<TypedFlatConfigItem, 'files'>): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
|
|
12
|
-
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
13
|
-
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
14
|
-
declare function getOverrides(options: OptionsConfig, key: keyof OptionsConfig): Partial<Linter.RulesRecord & RuleOptions>;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/globs.d.ts
|
|
17
|
-
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
18
|
-
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
19
|
-
declare const GLOB_JS = "**/*.?([cm])js";
|
|
20
|
-
declare const GLOB_JSX = "**/*.?([cm])jsx";
|
|
21
|
-
declare const GLOB_TS = "**/*.?([cm])ts";
|
|
22
|
-
declare const GLOB_TSX = "**/*.?([cm])tsx";
|
|
23
|
-
declare const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
24
|
-
declare const GLOB_CSS = "**/*.css";
|
|
25
|
-
declare const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
26
|
-
declare const GLOB_LESS = "**/*.less";
|
|
27
|
-
declare const GLOB_SCSS = "**/*.scss";
|
|
28
|
-
declare const GLOB_JSON = "**/*.json";
|
|
29
|
-
declare const GLOB_JSON5 = "**/*.json5";
|
|
30
|
-
declare const GLOB_JSONC = "**/*.jsonc";
|
|
31
|
-
declare const GLOB_MARKDOWN = "**/*.md";
|
|
32
|
-
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
33
|
-
declare const GLOB_VUE = "**/*.vue";
|
|
34
|
-
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
35
|
-
declare const GLOB_TOML = "**/*.toml";
|
|
36
|
-
declare const GLOB_XML = "**/*.xml";
|
|
37
|
-
declare const GLOB_SVG = "**/*.svg";
|
|
38
|
-
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
39
|
-
declare const GLOB_ASTRO = "**/*.astro";
|
|
40
|
-
declare const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
41
|
-
declare const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
|
|
42
|
-
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
43
|
-
declare const GLOB_TESTS: string[];
|
|
44
|
-
declare const GLOB_ALL_SRC: string[];
|
|
45
|
-
declare const GLOB_EXCLUDE: string[];
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/utils.d.ts
|
|
48
|
-
declare const parserPlain: {
|
|
49
|
-
meta: {
|
|
50
|
-
name: string;
|
|
51
|
-
};
|
|
52
|
-
parseForESLint: (code: string) => {
|
|
53
|
-
ast: {
|
|
54
|
-
body: never[];
|
|
55
|
-
comments: never[];
|
|
56
|
-
loc: {
|
|
57
|
-
end: number;
|
|
58
|
-
start: number;
|
|
59
|
-
};
|
|
60
|
-
range: number[];
|
|
61
|
-
tokens: never[];
|
|
62
|
-
type: string;
|
|
63
|
-
};
|
|
64
|
-
scopeManager: null;
|
|
65
|
-
services: {
|
|
66
|
-
isPlain: boolean;
|
|
67
|
-
};
|
|
68
|
-
visitorKeys: {
|
|
69
|
-
Program: never[];
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Combine array and non-array configs into a single array.
|
|
75
|
-
*/
|
|
76
|
-
declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
|
|
77
|
-
declare function toArray<T>(value: T | T[]): T[];
|
|
78
|
-
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
79
|
-
default: infer U;
|
|
80
|
-
} ? U : T>;
|
|
81
|
-
declare function isPackageInScope(name: string): boolean;
|
|
82
|
-
declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
|
|
83
|
-
declare function isInEditorEnv(): boolean;
|
|
84
|
-
declare function isInGitHooksOrLintStaged(): boolean;
|
|
85
|
-
//#endregion
|
|
86
|
-
export { Awaitable, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
1
|
+
import { ConfigNames } from "./typegen.js";
|
|
2
|
+
import { Awaitable, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, Rules, StylisticConfig, TypedFlatConfigItem } from "./types.js";
|
|
3
|
+
import { ResolvedOptions, defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions } from "./factory.js";
|
|
4
|
+
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML } from "./globs.js";
|
|
5
|
+
import { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray } from "./utils.js";
|
|
6
|
+
export { Awaitable, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
package/dist/index.js
CHANGED
|
@@ -1,137 +1,7 @@
|
|
|
1
|
-
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML } from "./globs.js";
|
|
2
|
+
import { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray } from "./utils.js";
|
|
3
|
+
import { defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions } from "./factory.js";
|
|
4
4
|
|
|
5
|
-
//#region src/factory.ts
|
|
6
|
-
const flatConfigProps = [
|
|
7
|
-
"name",
|
|
8
|
-
"languageOptions",
|
|
9
|
-
"linterOptions",
|
|
10
|
-
"processor",
|
|
11
|
-
"plugins",
|
|
12
|
-
"rules",
|
|
13
|
-
"settings"
|
|
14
|
-
];
|
|
15
|
-
const VuePackages = [
|
|
16
|
-
"vue",
|
|
17
|
-
"nuxt",
|
|
18
|
-
"vitepress",
|
|
19
|
-
"@slidev/cli"
|
|
20
|
-
];
|
|
21
|
-
const defaultPluginRenaming = {
|
|
22
|
-
"import-lite": "import",
|
|
23
|
-
"vitest": "test",
|
|
24
|
-
"yml": "yaml"
|
|
25
|
-
};
|
|
26
|
-
function eienjs(options = {}) {
|
|
27
|
-
const { astro: enableAstro = false, componentExts = [], gitignore: enableGitignore = true, imports: enableImports = true, pnpm: enableCatalogs = false, regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)), adonisjs: enableAdonisjs = false, nuxt: enableNuxt = false } = options;
|
|
28
|
-
let { isInEditor } = options;
|
|
29
|
-
if (isInEditor == null) {
|
|
30
|
-
isInEditor = isInEditorEnv();
|
|
31
|
-
if (isInEditor) console.info("[@eienjs/eslint-config] Detected running in editor, some rules are disabled.");
|
|
32
|
-
}
|
|
33
|
-
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
34
|
-
const configs = [];
|
|
35
|
-
if (enableGitignore) if (typeof enableGitignore === "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
36
|
-
name: "eienjs/gitignore",
|
|
37
|
-
strict: false
|
|
38
|
-
})]));
|
|
39
|
-
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
40
|
-
name: "eienjs/gitignore",
|
|
41
|
-
...enableGitignore
|
|
42
|
-
})]));
|
|
43
|
-
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
44
|
-
configs.push(ignores(options.ignores), javascript({
|
|
45
|
-
isInEditor,
|
|
46
|
-
overrides: getOverrides(options, "javascript")
|
|
47
|
-
}), comments(), node(), jsdoc({ stylistic: stylisticOptions }), imports({ stylistic: stylisticOptions }), command(), perfectionist());
|
|
48
|
-
if (enableImports) configs.push(imports(enableImports === true ? { stylistic: stylisticOptions } : {
|
|
49
|
-
stylistic: stylisticOptions,
|
|
50
|
-
...enableImports
|
|
51
|
-
}));
|
|
52
|
-
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
53
|
-
if (enableVue) componentExts.push("vue");
|
|
54
|
-
if (enableTypeScript) configs.push(typescript({
|
|
55
|
-
...typescriptOptions,
|
|
56
|
-
componentExts,
|
|
57
|
-
stylistic: stylisticOptions,
|
|
58
|
-
overrides: getOverrides(options, "typescript")
|
|
59
|
-
}));
|
|
60
|
-
if (stylisticOptions) configs.push(stylistic({
|
|
61
|
-
...stylisticOptions,
|
|
62
|
-
overrides: getOverrides(options, "stylistic")
|
|
63
|
-
}));
|
|
64
|
-
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
65
|
-
if (options.test ?? true) configs.push(test({
|
|
66
|
-
isInEditor,
|
|
67
|
-
overrides: getOverrides(options, "test")
|
|
68
|
-
}));
|
|
69
|
-
if (enableVue) configs.push(vue({
|
|
70
|
-
...resolveSubOptions(options, "vue"),
|
|
71
|
-
overrides: getOverrides(options, "vue"),
|
|
72
|
-
stylistic: stylisticOptions,
|
|
73
|
-
typescript: Boolean(enableTypeScript)
|
|
74
|
-
}));
|
|
75
|
-
if (enableAstro) configs.push(astro({
|
|
76
|
-
overrides: getOverrides(options, "astro"),
|
|
77
|
-
stylistic: stylisticOptions
|
|
78
|
-
}));
|
|
79
|
-
if (enableAdonisjs) configs.push(adonisjs({
|
|
80
|
-
...resolveSubOptions(options, "adonisjs"),
|
|
81
|
-
overrides: getOverrides(options, "adonisjs")
|
|
82
|
-
}));
|
|
83
|
-
if (enableNuxt) configs.push(nuxt({
|
|
84
|
-
...resolveSubOptions(options, "nuxt"),
|
|
85
|
-
overrides: getOverrides(options, "nuxt"),
|
|
86
|
-
stylistic: stylisticOptions
|
|
87
|
-
}));
|
|
88
|
-
if (options.jsonc ?? true) configs.push(jsonc({
|
|
89
|
-
overrides: getOverrides(options, "jsonc"),
|
|
90
|
-
stylistic: stylisticOptions
|
|
91
|
-
}), sortPackageJson(), sortTsconfig());
|
|
92
|
-
if (enableCatalogs) configs.push(pnpm());
|
|
93
|
-
if (options.yaml ?? true) configs.push(yaml({
|
|
94
|
-
overrides: getOverrides(options, "yaml"),
|
|
95
|
-
stylistic: stylisticOptions
|
|
96
|
-
}));
|
|
97
|
-
if (options.toml ?? true) configs.push(toml({
|
|
98
|
-
overrides: getOverrides(options, "toml"),
|
|
99
|
-
stylistic: stylisticOptions
|
|
100
|
-
}));
|
|
101
|
-
if (options.markdown ?? true) configs.push(markdown({
|
|
102
|
-
componentExts,
|
|
103
|
-
overrides: getOverrides(options, "markdown")
|
|
104
|
-
}));
|
|
105
|
-
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
106
|
-
configs.push(disables());
|
|
107
|
-
if ("files" in options) throw new Error([
|
|
108
|
-
"[@eienjs/eslint-config] ",
|
|
109
|
-
"The first argument should not contain the \"files\" property as the options are supposed to be global. ",
|
|
110
|
-
"Place it in the second or later config instead."
|
|
111
|
-
].join(""));
|
|
112
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
113
|
-
if (key in options) acc[key] = options[key];
|
|
114
|
-
return acc;
|
|
115
|
-
}, {});
|
|
116
|
-
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
117
|
-
let composer = new FlatConfigComposer();
|
|
118
|
-
composer = composer.append(...configs).renamePlugins(defaultPluginRenaming);
|
|
119
|
-
if (isInEditor) composer = composer.disableRulesFix([
|
|
120
|
-
"unused-imports/no-unused-imports",
|
|
121
|
-
"test/no-only-tests",
|
|
122
|
-
"prefer-const"
|
|
123
|
-
], { builtinRules: async () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
124
|
-
return composer;
|
|
125
|
-
}
|
|
126
|
-
function resolveSubOptions(options, key) {
|
|
127
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
128
|
-
}
|
|
129
|
-
function getOverrides(options, key) {
|
|
130
|
-
const sub = resolveSubOptions(options, key);
|
|
131
|
-
return { ..."overrides" in sub ? sub.overrides : {} };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
5
|
//#region src/index.ts
|
|
136
6
|
var src_default = eienjs;
|
|
137
7
|
|
package/dist/package.js
ADDED
package/dist/plugins.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
2
|
+
import pluginAntfu from "eslint-plugin-antfu";
|
|
3
|
+
import pluginImportLite from "eslint-plugin-import-lite";
|
|
4
|
+
import pluginNode from "eslint-plugin-n";
|
|
5
|
+
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
6
|
+
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
7
|
+
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
8
|
+
|
|
9
|
+
export { pluginAntfu, pluginComments, pluginImportLite, pluginNode, pluginPerfectionist, pluginUnicorn, pluginUnusedImports };
|