@cuiqg/eslint-config 2.8.1 → 2.8.3
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.mjs +49 -19
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { isPackageExists } from "local-pkg";
|
|
2
4
|
import globals from "globals";
|
|
3
5
|
import process from "node:process";
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
5
6
|
|
|
6
7
|
//#region src/globs.js
|
|
7
8
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -26,6 +27,8 @@ const GLOB_TOML = "**/*.toml";
|
|
|
26
27
|
const GLOB_XML = "**/*.xml";
|
|
27
28
|
const GLOB_SVG = "**/*.svg";
|
|
28
29
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
30
|
+
const GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
31
|
+
const GLOB_PHP = "**/*.php";
|
|
29
32
|
const GLOB_EXCLUDE = [
|
|
30
33
|
"**/node_modules",
|
|
31
34
|
"**/dist",
|
|
@@ -69,6 +72,7 @@ const GLOB_EXCLUDE = [
|
|
|
69
72
|
|
|
70
73
|
//#endregion
|
|
71
74
|
//#region src/utils.js
|
|
75
|
+
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
72
76
|
async function interopDefault(module) {
|
|
73
77
|
try {
|
|
74
78
|
let resolved = await module;
|
|
@@ -119,7 +123,15 @@ async function javascript() {
|
|
|
119
123
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
120
124
|
name: "cuiqg/javascript",
|
|
121
125
|
plugins: { js: pluginJs },
|
|
122
|
-
rules: {
|
|
126
|
+
rules: {
|
|
127
|
+
...pluginJs.configs.recommended.rules,
|
|
128
|
+
"no-unused-vars": ["error", {
|
|
129
|
+
argsIgnorePattern: "^_",
|
|
130
|
+
caughtErrorsIgnorePattern: "^_",
|
|
131
|
+
ignoreRestSiblings: true,
|
|
132
|
+
varsIgnorePattern: "^_"
|
|
133
|
+
}]
|
|
134
|
+
}
|
|
123
135
|
}];
|
|
124
136
|
}
|
|
125
137
|
|
|
@@ -190,18 +202,19 @@ async function prettier() {
|
|
|
190
202
|
|
|
191
203
|
//#endregion
|
|
192
204
|
//#region src/configs/stylistic.js
|
|
205
|
+
const stylisticConfigDefaults = {
|
|
206
|
+
experimental: false,
|
|
207
|
+
indent: 2,
|
|
208
|
+
jsx: true,
|
|
209
|
+
quotes: "single",
|
|
210
|
+
semi: false
|
|
211
|
+
};
|
|
193
212
|
async function stylistic() {
|
|
194
213
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
195
|
-
const config = pluginStylistic.configs.customize({
|
|
196
|
-
commaDangle: "never",
|
|
197
|
-
indent: 2,
|
|
198
|
-
pluginName: "style",
|
|
199
|
-
quotes: "single",
|
|
200
|
-
semi: false
|
|
201
|
-
});
|
|
214
|
+
const config = pluginStylistic.configs.customize({ ...stylisticConfigDefaults });
|
|
202
215
|
return [{
|
|
203
216
|
name: "cuiqg/stylistic",
|
|
204
|
-
plugins: {
|
|
217
|
+
plugins: { "@stylistic": pluginStylistic },
|
|
205
218
|
rules: { ...config.rules }
|
|
206
219
|
}];
|
|
207
220
|
}
|
|
@@ -229,6 +242,7 @@ async function vue() {
|
|
|
229
242
|
computed: "readonly",
|
|
230
243
|
defineEmits: "readonly",
|
|
231
244
|
defineExpose: "readonly",
|
|
245
|
+
definePage: "readonly",
|
|
232
246
|
defineModel: "readonly",
|
|
233
247
|
defineOptions: "readonly",
|
|
234
248
|
defineProps: "readonly",
|
|
@@ -370,7 +384,20 @@ async function tailwindcss() {
|
|
|
370
384
|
name: "cuiqg/tailwindcss",
|
|
371
385
|
plugins: { tailwindcss: pluginTailwindcss },
|
|
372
386
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
373
|
-
rules: { ...pluginTailwindcss.configs
|
|
387
|
+
rules: { ...pluginTailwindcss.configs.recommended.rules },
|
|
388
|
+
settings: {}
|
|
389
|
+
}];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/configs/imports.js
|
|
394
|
+
async function imports() {
|
|
395
|
+
const pluginImportX = await interopDefault(import("eslint-plugin-import-x"));
|
|
396
|
+
return [{
|
|
397
|
+
name: "cuiqg/imports",
|
|
398
|
+
plugins: { "import-x": pluginImportX },
|
|
399
|
+
rules: { ...pluginImportX.configs["flat/recommended"].rules },
|
|
400
|
+
settings: { "import-x/core-modules": ["electron", "vue-router/auto-routes"] }
|
|
374
401
|
}];
|
|
375
402
|
}
|
|
376
403
|
|
|
@@ -396,20 +423,23 @@ const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
|
396
423
|
|
|
397
424
|
//#endregion
|
|
398
425
|
//#region src/presets.js
|
|
399
|
-
const defaultPluginRenaming = {
|
|
400
|
-
"@stylistic": "style",
|
|
401
|
-
"@typescript-eslint": "ts"
|
|
402
|
-
};
|
|
426
|
+
const defaultPluginRenaming = {};
|
|
403
427
|
/**
|
|
404
428
|
*
|
|
405
429
|
* @param {object} options - 设置选项
|
|
406
|
-
* @param {
|
|
407
|
-
* @
|
|
430
|
+
* @param {boolean} [options.prettier=false] - 是否启用 prettier 格式化
|
|
431
|
+
* @param {boolean} [options.unocss] - 是否启用 unocss 格式化
|
|
432
|
+
* @param {boolean} [options.tailwindcss] - 是否启用 tailwindcss 格式化
|
|
433
|
+
* @param {boolean} [options.vue] - 是否启用 vue 格式化
|
|
434
|
+
* @param {boolean|object} [options.formatter=true] - 是否启用格式化
|
|
435
|
+
* @param {...Object} userConfigs - 用户配置
|
|
436
|
+
* @returns {Promise<Object[]>} 合并后的配置
|
|
408
437
|
*/
|
|
409
438
|
function cuiqg(options = {}, ...userConfigs) {
|
|
410
|
-
const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), vue: enableVue = hasVue() } = options;
|
|
439
|
+
const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), vue: enableVue = hasVue(), imports: enableImports = true } = options;
|
|
411
440
|
const configs = [];
|
|
412
441
|
configs.push(ignores(), javascript(), jsdoc(), stylistic(), packageJson());
|
|
442
|
+
if (enableImports) configs.push(imports());
|
|
413
443
|
if (enableVue) configs.push(vue(), macros());
|
|
414
444
|
if (enableUnocss) configs.push(unocss());
|
|
415
445
|
if (enableTailwindcss) configs.push(tailwindcss());
|
|
@@ -424,4 +454,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
424
454
|
var src_default = cuiqg;
|
|
425
455
|
|
|
426
456
|
//#endregion
|
|
427
|
-
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_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, src_default as default, defaultPluginRenaming, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, tailwindcss, unocss, vue };
|
|
457
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_PHP, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, src_default as default, defaultPluginRenaming, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, imports, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, stylisticConfigDefaults, tailwindcss, unocss, vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
43
43
|
"eslint-config-prettier": "^10.1.8",
|
|
44
44
|
"eslint-flat-config-utils": "^2.1.4",
|
|
45
|
+
"eslint-plugin-format": "^1.0.2",
|
|
46
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
45
47
|
"eslint-plugin-jsdoc": "^61.4.1",
|
|
46
48
|
"eslint-plugin-package-json": "^0.85.0",
|
|
47
49
|
"eslint-plugin-prettier": "^5.5.4",
|