@cuiqg/eslint-config 2.2.1 → 2.2.2
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/index.js +38 -4
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,12 @@ async function interopDefault(m) {
|
|
|
11
11
|
const resolved = await m;
|
|
12
12
|
return resolved.default || m;
|
|
13
13
|
}
|
|
14
|
+
function renameRules(rules, map) {
|
|
15
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
16
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
17
|
+
return [key, value];
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
14
20
|
|
|
15
21
|
//#endregion
|
|
16
22
|
//#region src/configs/comments.js
|
|
@@ -35,6 +41,8 @@ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
|
35
41
|
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
36
42
|
const GLOB_JS = "**/*.?([cm])js";
|
|
37
43
|
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
44
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
45
|
+
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
38
46
|
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
39
47
|
const GLOB_CSS = "**/*.css";
|
|
40
48
|
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
@@ -43,11 +51,13 @@ const GLOB_SCSS = "**/*.scss";
|
|
|
43
51
|
const GLOB_JSON = "**/*.json";
|
|
44
52
|
const GLOB_JSON5 = "**/*.json5";
|
|
45
53
|
const GLOB_JSONC = "**/*.jsonc";
|
|
54
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
46
55
|
const GLOB_VUE = "**/*.vue";
|
|
47
56
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
57
|
+
const GLOB_TOML = "**/*.toml";
|
|
48
58
|
const GLOB_XML = "**/*.xml";
|
|
59
|
+
const GLOB_SVG = "**/*.svg";
|
|
49
60
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
50
|
-
const GLOB_TOML = "**/*.toml";
|
|
51
61
|
const GLOB_EXCLUDE = [
|
|
52
62
|
"**/node_modules",
|
|
53
63
|
"**/dist",
|
|
@@ -169,7 +179,7 @@ function isInEditor() {
|
|
|
169
179
|
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
170
180
|
}
|
|
171
181
|
function isInGitHooksOrLintStaged() {
|
|
172
|
-
return !!(process.env.
|
|
182
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
173
183
|
}
|
|
174
184
|
|
|
175
185
|
//#endregion
|
|
@@ -841,6 +851,29 @@ const toml = async () => {
|
|
|
841
851
|
}];
|
|
842
852
|
};
|
|
843
853
|
|
|
854
|
+
//#endregion
|
|
855
|
+
//#region src/configs/typescript.js
|
|
856
|
+
/**
|
|
857
|
+
* TypeScript
|
|
858
|
+
*
|
|
859
|
+
* @see https://typescript-eslint.io/
|
|
860
|
+
* @returns {import('eslint').Linter.FlatConfig[]}
|
|
861
|
+
*/
|
|
862
|
+
async function typescript() {
|
|
863
|
+
const files = [GLOB_TS, GLOB_TSX];
|
|
864
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
865
|
+
return [{
|
|
866
|
+
files,
|
|
867
|
+
languageOptions: {
|
|
868
|
+
parser: parserTs,
|
|
869
|
+
parserOptions: { sourceType: "module" }
|
|
870
|
+
},
|
|
871
|
+
name: "cuiqg/typescript",
|
|
872
|
+
plugins: { "ts": pluginTs },
|
|
873
|
+
rules: { ...renameRules(pluginTs.configs["flat/recommended"].rules, { "@typescript-eslint": "ts" }) }
|
|
874
|
+
}];
|
|
875
|
+
}
|
|
876
|
+
|
|
844
877
|
//#endregion
|
|
845
878
|
//#region src/configs/unicorn.js
|
|
846
879
|
/**
|
|
@@ -1114,7 +1147,7 @@ const defaultPluginRenaming = {
|
|
|
1114
1147
|
"yml": "yaml"
|
|
1115
1148
|
};
|
|
1116
1149
|
function cuiqg(options = {}, ...userConfigs) {
|
|
1117
|
-
const { prettier: enablePrettier = false, gitignore: enableGitignore = true, unocss: enableUnocss = hasUnocss, vue: enableVue = hasVue, stylistic: enableStylistic = true, jsdoc: enableJsdoc = false, pnpm: enablePnpm = false } = options;
|
|
1150
|
+
const { prettier: enablePrettier = false, gitignore: enableGitignore = true, unocss: enableUnocss = hasUnocss, vue: enableVue = hasVue, stylistic: enableStylistic = true, typescript: enableTypescript = hasTypescript, jsdoc: enableJsdoc = false, pnpm: enablePnpm = false } = options;
|
|
1118
1151
|
const configs = [
|
|
1119
1152
|
unplugin(),
|
|
1120
1153
|
ignores(),
|
|
@@ -1138,6 +1171,7 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
1138
1171
|
if (enablePrettier) configs.push(prettier());
|
|
1139
1172
|
if (enableJsdoc) configs.push(jsdoc());
|
|
1140
1173
|
if (enablePnpm) configs.push(pnpm());
|
|
1174
|
+
if (enableTypescript) configs.push(typescript());
|
|
1141
1175
|
let composer = new FlatConfigComposer(...configs, ...userConfigs);
|
|
1142
1176
|
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
1143
1177
|
return composer;
|
|
@@ -1148,4 +1182,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
1148
1182
|
var src_default = cuiqg;
|
|
1149
1183
|
|
|
1150
1184
|
//#endregion
|
|
1151
|
-
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TOML, GLOB_VUE, GLOB_XML, GLOB_YAML, comments, cuiqg, src_default as default, defaultPluginRenaming, disables, gitignore, hasTypescript, hasUnocss, hasVue, ignores, imports, interopDefault, isInEditor, isInGitHooksOrLintStaged, javascript, jsdoc, jsonc, macros, node, pnpm, prettier, sortJsconfig, sortPackageJson, stylistic, toml, unicorn, unocss, unplugin, vue, yaml };
|
|
1185
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, comments, cuiqg, src_default as default, defaultPluginRenaming, disables, gitignore, hasTypescript, hasUnocss, hasVue, ignores, imports, interopDefault, isInEditor, isInGitHooksOrLintStaged, javascript, jsdoc, jsonc, macros, node, pnpm, prettier, renameRules, sortJsconfig, sortPackageJson, stylistic, toml, typescript, unicorn, unocss, unplugin, vue, yaml };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "ESLint config preset for @cuiqg",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@stylistic/eslint-plugin": "^4.4.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
35
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
34
36
|
"@unocss/eslint-plugin": "^66.1.2",
|
|
35
37
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
36
38
|
"eslint-flat-config-utils": "^2.1.0",
|