@zjutjh/eslint-config 2.0.0-beta.0 → 2.0.0-beta.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/README.md +4 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +17 -3
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { isPackageExists } from "local-pkg";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { includeIgnoreFile } from "@eslint/compat";
|
|
2
5
|
import importXPlugin, { flatConfigs } from "eslint-plugin-import-x";
|
|
3
6
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
4
7
|
import eslintJS from "@eslint/js";
|
|
@@ -57,10 +60,18 @@ const GLOBS_EXCLUDES = [
|
|
|
57
60
|
//#endregion
|
|
58
61
|
//#region src/configs/ignores.ts
|
|
59
62
|
function ignores(options) {
|
|
60
|
-
|
|
63
|
+
const { gitignore = false } = options ?? {};
|
|
64
|
+
const configs = [{
|
|
61
65
|
name: "zjutjh/ignores",
|
|
62
66
|
ignores: [...GLOBS_EXCLUDES, ...options?.userIgnores ?? []]
|
|
63
67
|
}];
|
|
68
|
+
if (gitignore !== false) {
|
|
69
|
+
const path = gitignore === true ? ".gitignore" : gitignore;
|
|
70
|
+
const absolute = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
71
|
+
if (existsSync(absolute)) configs.push(includeIgnoreFile(absolute, "zjutjh/gitignore"));
|
|
72
|
+
else if (gitignore !== true) throw new Error(`gitignore file not found: ${absolute}`);
|
|
73
|
+
}
|
|
74
|
+
return configs;
|
|
64
75
|
}
|
|
65
76
|
//#endregion
|
|
66
77
|
//#region src/configs/imports.ts
|
|
@@ -435,9 +446,12 @@ async function vue(options) {
|
|
|
435
446
|
//#endregion
|
|
436
447
|
//#region src/factory.ts
|
|
437
448
|
async function zjutjh(options = {}, ...userConfigs) {
|
|
438
|
-
const { componentExts = [], vue: enableVue = isPackageExists("vue"), ts: enableTs = isPackageExists("typescript"), taro: enableTaro = isPackageExists("@tarojs/taro"), jsx: enableJSX = isPackageExists("react"), react: enableReact = isPackageExists("react"), ignores: userIgnores, oxfmt: enableOxfmt = false } = options;
|
|
449
|
+
const { componentExts = [], vue: enableVue = isPackageExists("vue"), ts: enableTs = isPackageExists("typescript"), taro: enableTaro = isPackageExists("@tarojs/taro"), jsx: enableJSX = isPackageExists("react"), react: enableReact = isPackageExists("react"), ignores: userIgnores, gitignore: enableGitignore = false, oxfmt: enableOxfmt = false } = options;
|
|
439
450
|
const configs = [];
|
|
440
|
-
configs.push(ignores({
|
|
451
|
+
configs.push(ignores({
|
|
452
|
+
userIgnores,
|
|
453
|
+
gitignore: enableGitignore
|
|
454
|
+
}), javascript(), imports(), stylistic({ overrides: getOverrides(options, "stylistic") }), misc());
|
|
441
455
|
if (enableVue) componentExts.push("vue");
|
|
442
456
|
const typescriptOptions = resolveSubOptions(options, "ts");
|
|
443
457
|
if (enableTs) configs.push(await typescript({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zjutjh/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "zjutjh",
|
|
7
7
|
"description": "ESLint config used by zjutjh",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@antfu/install-pkg": "^1.1.0",
|
|
73
73
|
"@clack/prompts": "^1.2.0",
|
|
74
|
+
"@eslint/compat": "^2.0.5",
|
|
74
75
|
"@eslint/js": "^10.0.1",
|
|
75
76
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
76
77
|
"eslint-plugin-import-x": "^4.16.2",
|