@dhzh/eslint-config 2.0.2 → 2.0.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/cli/index.mjs +1 -1
- package/dist/index.mjs +16 -7
- package/package.json +2 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import fsp from "node:fs/promises";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
//#region package.json
|
|
9
|
-
var version = "2.0.
|
|
9
|
+
var version = "2.0.3";
|
|
10
10
|
var devDependencies = {
|
|
11
11
|
"@eslint/config-inspector": "^2.0.0",
|
|
12
12
|
"@prettier/plugin-xml": "^3.4.2",
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,10 @@ import pluginReactHooks from "eslint-plugin-react-hooks";
|
|
|
3
3
|
import pluginReactRefresh from "eslint-plugin-react-refresh";
|
|
4
4
|
import pluginReactCompiler from "eslint-plugin-react-compiler";
|
|
5
5
|
import pluginReactGoogleTranslate from "eslint-plugin-react-google-translate";
|
|
6
|
-
import { isPackageExists } from "local-pkg";
|
|
7
6
|
import { defineConfig as defineConfig$1 } from "eslint/config";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { getPackagesSync } from "@manypkg/get-packages";
|
|
9
|
+
import { isPackageExists } from "local-pkg";
|
|
8
10
|
import js from "@eslint/js";
|
|
9
11
|
import tseslint from "typescript-eslint";
|
|
10
12
|
import pluginVue from "eslint-plugin-vue";
|
|
@@ -13,7 +15,6 @@ import { mergeProcessors } from "eslint-merge-processors";
|
|
|
13
15
|
import processorVueBlocks from "eslint-processor-vue-blocks";
|
|
14
16
|
import pluginStylistic from "@stylistic/eslint-plugin";
|
|
15
17
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
16
|
-
import process from "node:process";
|
|
17
18
|
import pluginNode from "eslint-plugin-n";
|
|
18
19
|
import pluginJsonc from "eslint-plugin-jsonc";
|
|
19
20
|
import pluginPackageJson from "eslint-plugin-package-json";
|
|
@@ -147,6 +148,14 @@ const mergeRule = (...rules) => {
|
|
|
147
148
|
if (Object.keys(finalOptions).length === 0) return finalLevel;
|
|
148
149
|
return [finalLevel, finalOptions];
|
|
149
150
|
};
|
|
151
|
+
function isPackageAvailable(name, cwd = process.cwd()) {
|
|
152
|
+
if (isPackageExists(name, { paths: [cwd] })) return true;
|
|
153
|
+
try {
|
|
154
|
+
return getPackagesSync(cwd).packages.some((pkg) => name in (pkg.packageJson.dependencies || {}) || name in (pkg.packageJson.devDependencies || {}) || name in (pkg.packageJson.peerDependencies || {}) || name in (pkg.packageJson.optionalDependencies || {}));
|
|
155
|
+
} catch {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
150
159
|
//#endregion
|
|
151
160
|
//#region src/configs/react.ts
|
|
152
161
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -173,11 +182,11 @@ function react(options = {}) {
|
|
|
173
182
|
googleTranslate: {}
|
|
174
183
|
} } = options;
|
|
175
184
|
const config = language === "typescript" ? pluginReact.configs["recommended-type-checked"] : pluginReact.configs.recommended;
|
|
176
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) =>
|
|
177
|
-
const isUsingRemix = RemixPackages.some((i) =>
|
|
178
|
-
const isUsingReactRouter = ReactRouterPackages.some((i) =>
|
|
179
|
-
const isUsingNext = NextJsPackages.some((i) =>
|
|
180
|
-
const isUsingExpo = ExpoPackages.some((i) =>
|
|
185
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageAvailable(i));
|
|
186
|
+
const isUsingRemix = RemixPackages.some((i) => isPackageAvailable(i));
|
|
187
|
+
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageAvailable(i));
|
|
188
|
+
const isUsingNext = NextJsPackages.some((i) => isPackageAvailable(i));
|
|
189
|
+
const isUsingExpo = ExpoPackages.some((i) => isPackageAvailable(i));
|
|
181
190
|
return [
|
|
182
191
|
{
|
|
183
192
|
...config,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhzh/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"description": "tinywaves's ESLint config",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Lyle Zheng",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
53
53
|
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
54
54
|
"@eslint/js": "^10.0.1",
|
|
55
|
+
"@manypkg/get-packages": "^3.1.0",
|
|
55
56
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
56
57
|
"@unocss/eslint-config": "66.6.8",
|
|
57
58
|
"ansis": "^4.2.0",
|