@coderwyd/eslint-config 3.5.0 → 4.0.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/README.md +0 -11
- package/dist/cli.js +10 -9
- package/dist/index.d.ts +393 -1711
- package/dist/index.js +38 -35
- package/package.json +23 -23
- package/dist/cli.cjs +0 -255
- package/dist/cli.d.cts +0 -2
- package/dist/index.cjs +0 -1917
- package/dist/index.d.cts +0 -15233
package/dist/index.js
CHANGED
|
@@ -114,6 +114,7 @@ function imports() {
|
|
|
114
114
|
"antfu/import-dedupe": "error",
|
|
115
115
|
"antfu/no-import-dist": "error",
|
|
116
116
|
"antfu/no-import-node-modules-by-path": "error",
|
|
117
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
117
118
|
"import/first": "error",
|
|
118
119
|
"import/no-duplicates": "error",
|
|
119
120
|
"import/no-mutable-exports": "error",
|
|
@@ -366,26 +367,6 @@ import { fileURLToPath } from "node:url";
|
|
|
366
367
|
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
367
368
|
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
368
369
|
var isCwdInScope = isPackageExists("@coderwyd/eslint-config");
|
|
369
|
-
var parserPlain = {
|
|
370
|
-
meta: {
|
|
371
|
-
name: "parser-plain"
|
|
372
|
-
},
|
|
373
|
-
parseForESLint: (code) => ({
|
|
374
|
-
ast: {
|
|
375
|
-
body: [],
|
|
376
|
-
comments: [],
|
|
377
|
-
loc: { end: code.length, start: 0 },
|
|
378
|
-
range: [0, code.length],
|
|
379
|
-
tokens: [],
|
|
380
|
-
type: "Program"
|
|
381
|
-
},
|
|
382
|
-
scopeManager: null,
|
|
383
|
-
services: { isPlain: true },
|
|
384
|
-
visitorKeys: {
|
|
385
|
-
Program: []
|
|
386
|
-
}
|
|
387
|
-
})
|
|
388
|
-
};
|
|
389
370
|
async function combine(...configs2) {
|
|
390
371
|
const resolved = await Promise.all(configs2);
|
|
391
372
|
return resolved.flat();
|
|
@@ -644,18 +625,25 @@ function prettier() {
|
|
|
644
625
|
import process2 from "node:process";
|
|
645
626
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
646
627
|
var isInEditor = !!((process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM || process2.env.NVIM) && !process2.env.CI);
|
|
647
|
-
var hasTypeScript = isPackageExists2("typescript");
|
|
648
628
|
var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
|
|
649
|
-
var hasVue = hasPackages(VueJsPackages);
|
|
650
629
|
var RemixPackages = [
|
|
651
630
|
"@remix-run/node",
|
|
652
631
|
"@remix-run/react",
|
|
653
632
|
"@remix-run/serve",
|
|
654
633
|
"@remix-run/dev"
|
|
655
634
|
];
|
|
635
|
+
var ReactRouterPackages = [
|
|
636
|
+
"@react-router/node",
|
|
637
|
+
"@react-router/react",
|
|
638
|
+
"@react-router/serve",
|
|
639
|
+
"@react-router/dev"
|
|
640
|
+
];
|
|
656
641
|
var NextJsPackages = ["next"];
|
|
657
642
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
643
|
+
var isUsingTypeScript = isPackageExists2("typescript");
|
|
644
|
+
var isUsingVue = hasPackages(VueJsPackages);
|
|
658
645
|
var isUsingRemix = hasPackages(RemixPackages);
|
|
646
|
+
var isUsingReactRouter = hasPackages(ReactRouterPackages);
|
|
659
647
|
var isUsingNext = hasPackages(NextJsPackages);
|
|
660
648
|
var isAllowConstantExport = hasPackages(
|
|
661
649
|
ReactRefreshAllowConstantExportPackages
|
|
@@ -682,24 +670,30 @@ async function react(options = {}) {
|
|
|
682
670
|
const typeAwareRules = {
|
|
683
671
|
"react/no-leaked-conditional-rendering": "warn"
|
|
684
672
|
};
|
|
685
|
-
const [
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
673
|
+
const [
|
|
674
|
+
pluginReact,
|
|
675
|
+
pluginReactHooks,
|
|
676
|
+
pluginReactRefresh,
|
|
677
|
+
pluginReactCompiler
|
|
678
|
+
] = await Promise.all([
|
|
679
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
680
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
681
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
682
|
+
interopDefault(import("eslint-plugin-react-compiler"))
|
|
683
|
+
]);
|
|
692
684
|
const plugins = pluginReact.configs.all.plugins;
|
|
693
685
|
return [
|
|
694
686
|
{
|
|
695
687
|
name: "coderwyd/react/setup",
|
|
696
688
|
plugins: {
|
|
697
689
|
react: plugins["@eslint-react"],
|
|
690
|
+
"react-compiler": pluginReactCompiler,
|
|
698
691
|
"react-dom": plugins["@eslint-react/dom"],
|
|
699
692
|
"react-hooks": pluginReactHooks,
|
|
700
693
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
701
694
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
702
|
-
"react-refresh": pluginReactRefresh
|
|
695
|
+
"react-refresh": pluginReactRefresh,
|
|
696
|
+
"react-web-api": plugins["@eslint-react/web-api"]
|
|
703
697
|
}
|
|
704
698
|
},
|
|
705
699
|
{
|
|
@@ -714,6 +708,7 @@ async function react(options = {}) {
|
|
|
714
708
|
},
|
|
715
709
|
name: "coderwyd/react/rules",
|
|
716
710
|
rules: {
|
|
711
|
+
"react-compiler/react-compiler": "warn",
|
|
717
712
|
// recommended rules from @eslint-react/dom
|
|
718
713
|
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
719
714
|
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
@@ -750,10 +745,15 @@ async function react(options = {}) {
|
|
|
750
745
|
"viewport",
|
|
751
746
|
"generateViewport"
|
|
752
747
|
] : [],
|
|
753
|
-
...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
|
|
748
|
+
...isUsingRemix || isUsingReactRouter ? ["meta", "links", "headers", "loader", "action"] : []
|
|
754
749
|
]
|
|
755
750
|
}
|
|
756
751
|
],
|
|
752
|
+
// recommended rules from @eslint-react/web-api
|
|
753
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
754
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
755
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
756
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
757
757
|
// recommended rules from @eslint-react
|
|
758
758
|
"react/ensure-forward-ref-using-ref": "warn",
|
|
759
759
|
"react/jsx-no-duplicate-props": "warn",
|
|
@@ -1372,7 +1372,11 @@ async function typescript(options = {}) {
|
|
|
1372
1372
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1373
1373
|
"ts/consistent-type-imports": [
|
|
1374
1374
|
"error",
|
|
1375
|
-
{
|
|
1375
|
+
{
|
|
1376
|
+
disallowTypeAnnotations: false,
|
|
1377
|
+
fixStyle: "separate-type-imports",
|
|
1378
|
+
prefer: "type-imports"
|
|
1379
|
+
}
|
|
1376
1380
|
],
|
|
1377
1381
|
"ts/method-signature-style": ["error", "property"],
|
|
1378
1382
|
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
@@ -1709,9 +1713,9 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1709
1713
|
regexp: enableRegexp = true,
|
|
1710
1714
|
svelte: enableSvelte = false,
|
|
1711
1715
|
tailwindcss: enableTailwindCSS = false,
|
|
1712
|
-
typescript: enableTypeScript =
|
|
1716
|
+
typescript: enableTypeScript = isUsingTypeScript,
|
|
1713
1717
|
unocss: enableUnoCSS = false,
|
|
1714
|
-
vue: enableVue =
|
|
1718
|
+
vue: enableVue = isUsingVue
|
|
1715
1719
|
} = options;
|
|
1716
1720
|
let isInEditor2 = options.isInEditor;
|
|
1717
1721
|
if (isInEditor2 == null) {
|
|
@@ -1854,7 +1858,6 @@ export {
|
|
|
1854
1858
|
isInEditorEnv,
|
|
1855
1859
|
isInGitHooksOrLintStaged,
|
|
1856
1860
|
isPackageInScope,
|
|
1857
|
-
parserPlain,
|
|
1858
1861
|
renamePluginInConfigs,
|
|
1859
1862
|
renameRules,
|
|
1860
1863
|
resolveSubOptions,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -17,14 +17,9 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
|
-
".":
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"import": "./dist/index.js",
|
|
23
|
-
"require": "./dist/index.cjs"
|
|
24
|
-
}
|
|
20
|
+
".": "./dist/index.js"
|
|
25
21
|
},
|
|
26
22
|
"main": "./dist/index.js",
|
|
27
|
-
"module": "./dist/index.js",
|
|
28
23
|
"types": "./dist/index.d.ts",
|
|
29
24
|
"bin": "./bin/index.js",
|
|
30
25
|
"files": [
|
|
@@ -38,6 +33,7 @@
|
|
|
38
33
|
"@eslint-react/eslint-plugin": "^1.5.8",
|
|
39
34
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
40
35
|
"eslint": "^9.5.0",
|
|
36
|
+
"eslint-plugin-react-compiler": "^19.0.0-beta-decd7b8-20250118",
|
|
41
37
|
"eslint-plugin-react-hooks": "^4.6.0 || ^5.0.0",
|
|
42
38
|
"eslint-plugin-react-refresh": "^0.4.4",
|
|
43
39
|
"eslint-plugin-svelte": ">=2.35.1",
|
|
@@ -51,6 +47,9 @@
|
|
|
51
47
|
"@unocss/eslint-plugin": {
|
|
52
48
|
"optional": true
|
|
53
49
|
},
|
|
50
|
+
"eslint-plugin-react-compiler": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
54
53
|
"eslint-plugin-react-hooks": {
|
|
55
54
|
"optional": true
|
|
56
55
|
},
|
|
@@ -70,20 +69,20 @@
|
|
|
70
69
|
"dependencies": {
|
|
71
70
|
"@antfu/install-pkg": "^1.0.0",
|
|
72
71
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
74
|
-
"@typescript-eslint/parser": "^8.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
75
74
|
"@vitest/eslint-plugin": "^1.1.25",
|
|
76
|
-
"eslint-config-flat-gitignore": "^
|
|
75
|
+
"eslint-config-flat-gitignore": "^2.0.0",
|
|
77
76
|
"eslint-config-prettier": "^10.0.1",
|
|
78
|
-
"eslint-plugin-antfu": "^
|
|
79
|
-
"eslint-plugin-command": "^
|
|
77
|
+
"eslint-plugin-antfu": "^3.0.0",
|
|
78
|
+
"eslint-plugin-command": "^3.0.0",
|
|
80
79
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
81
80
|
"eslint-plugin-import-x": "^4.6.1",
|
|
82
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
83
|
-
"eslint-plugin-jsonc": "^2.
|
|
81
|
+
"eslint-plugin-jsdoc": "^50.6.3",
|
|
82
|
+
"eslint-plugin-jsonc": "^2.19.1",
|
|
84
83
|
"eslint-plugin-n": "^17.15.1",
|
|
85
84
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
86
|
-
"eslint-plugin-perfectionist": "^4.
|
|
85
|
+
"eslint-plugin-perfectionist": "^4.8.0",
|
|
87
86
|
"eslint-plugin-regexp": "^2.7.0",
|
|
88
87
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
89
88
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
@@ -100,16 +99,17 @@
|
|
|
100
99
|
"yargs": "^17.7.2"
|
|
101
100
|
},
|
|
102
101
|
"devDependencies": {
|
|
103
|
-
"@antfu/ni": "^23.
|
|
104
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
102
|
+
"@antfu/ni": "^23.3.1",
|
|
103
|
+
"@eslint-react/eslint-plugin": "^1.26.2",
|
|
105
104
|
"@eslint/config-inspector": "^1.0.0",
|
|
106
105
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
107
|
-
"@types/node": "^22.
|
|
106
|
+
"@types/node": "^22.13.1",
|
|
108
107
|
"@types/prompts": "^2.4.9",
|
|
109
108
|
"@types/yargs": "^17.0.33",
|
|
110
|
-
"@unocss/eslint-plugin": "^65.4.
|
|
111
|
-
"bumpp": "^
|
|
112
|
-
"eslint": "^9.
|
|
109
|
+
"@unocss/eslint-plugin": "^65.4.3",
|
|
110
|
+
"bumpp": "^10.0.2",
|
|
111
|
+
"eslint": "^9.19.0",
|
|
112
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
|
|
113
113
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
114
114
|
"eslint-plugin-react-refresh": "^0.4.18",
|
|
115
115
|
"eslint-plugin-svelte": "^2.46.1",
|
|
@@ -117,9 +117,9 @@
|
|
|
117
117
|
"jiti": "^2.4.2",
|
|
118
118
|
"nano-staged": "^0.8.0",
|
|
119
119
|
"simple-git-hooks": "^2.11.1",
|
|
120
|
-
"svelte": "^5.19.
|
|
120
|
+
"svelte": "^5.19.9",
|
|
121
121
|
"svelte-eslint-parser": "^0.43.0",
|
|
122
|
-
"tsup": "^8.3.
|
|
122
|
+
"tsup": "^8.3.6",
|
|
123
123
|
"typescript": "^5.7.3"
|
|
124
124
|
},
|
|
125
125
|
"simple-git-hooks": {
|
package/dist/cli.cjs
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
|
|
26
|
-
// src/cli.ts
|
|
27
|
-
var cli_exports = {};
|
|
28
|
-
module.exports = __toCommonJS(cli_exports);
|
|
29
|
-
|
|
30
|
-
// src/cli/index.ts
|
|
31
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
32
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
33
|
-
var import_yargs = __toESM(require("yargs"), 1);
|
|
34
|
-
var import_helpers = require("yargs/helpers");
|
|
35
|
-
|
|
36
|
-
// src/cli/constants.ts
|
|
37
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
38
|
-
|
|
39
|
-
// package.json
|
|
40
|
-
var version = "3.5.0";
|
|
41
|
-
var devDependencies = {
|
|
42
|
-
"@antfu/ni": "^23.2.0",
|
|
43
|
-
"@eslint-react/eslint-plugin": "^1.23.2",
|
|
44
|
-
"@eslint/config-inspector": "^1.0.0",
|
|
45
|
-
"@types/eslint-config-prettier": "^6.11.3",
|
|
46
|
-
"@types/node": "^22.10.7",
|
|
47
|
-
"@types/prompts": "^2.4.9",
|
|
48
|
-
"@types/yargs": "^17.0.33",
|
|
49
|
-
"@unocss/eslint-plugin": "^65.4.2",
|
|
50
|
-
bumpp: "^9.10.1",
|
|
51
|
-
eslint: "^9.18.0",
|
|
52
|
-
"eslint-plugin-react-hooks": "^5.1.0",
|
|
53
|
-
"eslint-plugin-react-refresh": "^0.4.18",
|
|
54
|
-
"eslint-plugin-svelte": "^2.46.1",
|
|
55
|
-
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
56
|
-
jiti: "^2.4.2",
|
|
57
|
-
"nano-staged": "^0.8.0",
|
|
58
|
-
"simple-git-hooks": "^2.11.1",
|
|
59
|
-
svelte: "^5.19.0",
|
|
60
|
-
"svelte-eslint-parser": "^0.43.0",
|
|
61
|
-
tsup: "^8.3.5",
|
|
62
|
-
typescript: "^5.7.3"
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// src/cli/constants.ts
|
|
66
|
-
var ARROW = import_picocolors.default.cyan("\u2192");
|
|
67
|
-
var CHECK = import_picocolors.default.green("\u2714");
|
|
68
|
-
var CROSS = import_picocolors.default.red("\u2718");
|
|
69
|
-
var WARN = import_picocolors.default.yellow("\u2139");
|
|
70
|
-
var eslintVersion = devDependencies.eslint;
|
|
71
|
-
var vscodeSettingsString = `
|
|
72
|
-
"editor.formatOnSave": true,
|
|
73
|
-
|
|
74
|
-
// Auto fix
|
|
75
|
-
"editor.codeActionsOnSave": {
|
|
76
|
-
"source.fixAll.eslint": "explicit",
|
|
77
|
-
"source.organizeImports": "never"
|
|
78
|
-
},
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
// src/cli/run.ts
|
|
82
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
83
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
84
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
85
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
86
|
-
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
87
|
-
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
88
|
-
var import_prompts = __toESM(require("prompts"), 1);
|
|
89
|
-
|
|
90
|
-
// src/cli/utils.ts
|
|
91
|
-
var import_node_child_process = require("child_process");
|
|
92
|
-
function isGitClean() {
|
|
93
|
-
try {
|
|
94
|
-
(0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
|
|
95
|
-
return true;
|
|
96
|
-
} catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/cli/run.ts
|
|
102
|
-
async function run(options = {}) {
|
|
103
|
-
const SKIP_PROMPT = !!import_node_process.default.env.SKIP_PROMPT || options.yes;
|
|
104
|
-
const SKIP_GIT_CHECK = !!import_node_process.default.env.SKIP_GIT_CHECK;
|
|
105
|
-
const cwd = import_node_process.default.cwd();
|
|
106
|
-
const pathFlatConfig = import_node_path.default.join(cwd, "eslint.config.js");
|
|
107
|
-
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
108
|
-
const pathESLintIngore = import_node_path.default.join(cwd, ".eslintignore");
|
|
109
|
-
if (import_node_fs.default.existsSync(pathFlatConfig)) {
|
|
110
|
-
console.log(
|
|
111
|
-
import_picocolors2.default.yellow(
|
|
112
|
-
`${WARN} eslint.config.js already exists, migration wizard exited.`
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
return import_node_process.default.exit(1);
|
|
116
|
-
}
|
|
117
|
-
if (!SKIP_GIT_CHECK && !isGitClean()) {
|
|
118
|
-
const { confirmed } = await (0, import_prompts.default)({
|
|
119
|
-
initial: false,
|
|
120
|
-
message: "There are uncommitted changes in the current repository, are you sure to continue?",
|
|
121
|
-
name: "confirmed",
|
|
122
|
-
type: "confirm"
|
|
123
|
-
});
|
|
124
|
-
if (!confirmed) return import_node_process.default.exit(1);
|
|
125
|
-
}
|
|
126
|
-
console.log(import_picocolors2.default.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`));
|
|
127
|
-
const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
|
|
128
|
-
const pkg = JSON.parse(pkgContent);
|
|
129
|
-
pkg.devDependencies ??= {};
|
|
130
|
-
pkg.devDependencies["@coderwyd/eslint-config"] = `^${version}`;
|
|
131
|
-
if (!pkg.devDependencies.eslint) pkg.devDependencies.eslint = eslintVersion;
|
|
132
|
-
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
133
|
-
console.log(import_picocolors2.default.green(`${CHECK} changes wrote to package.json`));
|
|
134
|
-
const eslintIgnores = [];
|
|
135
|
-
if (import_node_fs.default.existsSync(pathESLintIngore)) {
|
|
136
|
-
console.log(import_picocolors2.default.cyan(`${ARROW} migrating existing .eslintignore`));
|
|
137
|
-
const content = await import_promises.default.readFile(pathESLintIngore, "utf-8");
|
|
138
|
-
const parsed = (0, import_parse_gitignore.default)(content);
|
|
139
|
-
const globs = parsed.globs();
|
|
140
|
-
for (const glob of globs) {
|
|
141
|
-
if (glob.type === "ignore") {
|
|
142
|
-
eslintIgnores.push(...glob.patterns);
|
|
143
|
-
} else if (glob.type === "unignore") {
|
|
144
|
-
eslintIgnores.push(
|
|
145
|
-
...glob.patterns.map((pattern) => `!${pattern}`)
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
let eslintConfigContent = "";
|
|
151
|
-
const coderwydConfig = `${eslintIgnores.length > 0 ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
152
|
-
if (pkg.type === "module") {
|
|
153
|
-
eslintConfigContent = `
|
|
154
|
-
import { defineConfig } from '@coderwyd/eslint-config'
|
|
155
|
-
|
|
156
|
-
export default defineConfig({
|
|
157
|
-
${coderwydConfig}
|
|
158
|
-
})
|
|
159
|
-
`.trimStart();
|
|
160
|
-
} else {
|
|
161
|
-
eslintConfigContent = `
|
|
162
|
-
const { defineConfig } = require('@coderwyd/eslint-config')
|
|
163
|
-
|
|
164
|
-
module.exports = defineConfig({
|
|
165
|
-
${coderwydConfig}
|
|
166
|
-
})
|
|
167
|
-
`.trimStart();
|
|
168
|
-
}
|
|
169
|
-
await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
170
|
-
console.log(import_picocolors2.default.green(`${CHECK} created eslint.config.js`));
|
|
171
|
-
const files = import_node_fs.default.readdirSync(cwd);
|
|
172
|
-
const legacyConfig = [];
|
|
173
|
-
files.forEach((file) => {
|
|
174
|
-
if (/eslint|prettier/.test(file) && !/eslint.config./.test(file))
|
|
175
|
-
legacyConfig.push(file);
|
|
176
|
-
});
|
|
177
|
-
if (legacyConfig.length > 0) {
|
|
178
|
-
console.log(`${WARN} you can now remove those files manually:`);
|
|
179
|
-
console.log(` ${import_picocolors2.default.dim(legacyConfig.join(", "))}`);
|
|
180
|
-
}
|
|
181
|
-
let promptResult = {
|
|
182
|
-
updateVscodeSettings: true
|
|
183
|
-
};
|
|
184
|
-
if (!SKIP_PROMPT) {
|
|
185
|
-
try {
|
|
186
|
-
promptResult = await (0, import_prompts.default)(
|
|
187
|
-
{
|
|
188
|
-
initial: true,
|
|
189
|
-
message: "Update .vscode/settings.json for better VS Code experience?",
|
|
190
|
-
name: "updateVscodeSettings",
|
|
191
|
-
type: "confirm"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
onCancel: () => {
|
|
195
|
-
throw new Error(`Cancelled`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
} catch (error) {
|
|
200
|
-
console.log(error.message);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (promptResult?.updateVscodeSettings ?? true) {
|
|
205
|
-
const dotVscodePath = import_node_path.default.join(cwd, ".vscode");
|
|
206
|
-
const settingsPath = import_node_path.default.join(dotVscodePath, "settings.json");
|
|
207
|
-
if (!import_node_fs.default.existsSync(dotVscodePath))
|
|
208
|
-
await import_promises.default.mkdir(dotVscodePath, { recursive: true });
|
|
209
|
-
if (!import_node_fs.default.existsSync(settingsPath)) {
|
|
210
|
-
await import_promises.default.writeFile(settingsPath, `{${vscodeSettingsString}}
|
|
211
|
-
`, "utf-8");
|
|
212
|
-
console.log(import_picocolors2.default.green(`${CHECK} created .vscode/settings.json`));
|
|
213
|
-
} else {
|
|
214
|
-
let settingsContent = await import_promises.default.readFile(settingsPath, "utf8");
|
|
215
|
-
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
216
|
-
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
217
|
-
settingsContent += `${vscodeSettingsString}}
|
|
218
|
-
`;
|
|
219
|
-
await import_promises.default.writeFile(settingsPath, settingsContent, "utf-8");
|
|
220
|
-
console.log(import_picocolors2.default.green(`${CHECK} updated .vscode/settings.json`));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
console.log(import_picocolors2.default.green(`${CHECK} migration completed`));
|
|
224
|
-
console.log(
|
|
225
|
-
`Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
|
|
226
|
-
`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// src/cli/index.ts
|
|
231
|
-
function header() {
|
|
232
|
-
console.log(`
|
|
233
|
-
${import_picocolors3.default.green(`@coderwyd/eslint-config `)}${import_picocolors3.default.dim(`v${version}`)}`);
|
|
234
|
-
}
|
|
235
|
-
var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process2.default.argv)).scriptName("@coderwyd/eslint-config").usage("").command(
|
|
236
|
-
"*",
|
|
237
|
-
"Run the initialization or migration",
|
|
238
|
-
(args) => args.option("yes", {
|
|
239
|
-
alias: "y",
|
|
240
|
-
description: "Skip prompts and use default values",
|
|
241
|
-
type: "boolean"
|
|
242
|
-
}).help(),
|
|
243
|
-
async (args) => {
|
|
244
|
-
header();
|
|
245
|
-
console.log();
|
|
246
|
-
try {
|
|
247
|
-
await run(args);
|
|
248
|
-
} catch (error) {
|
|
249
|
-
console.error(import_picocolors3.default.inverse(import_picocolors3.default.red(" Failed to migrate ")));
|
|
250
|
-
console.error(import_picocolors3.default.red(`${CROSS} ${String(error)}`));
|
|
251
|
-
import_node_process2.default.exit(1);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
255
|
-
instance.help().argv;
|
package/dist/cli.d.cts
DELETED