-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.setup.ts
133 lines (112 loc) · 3.5 KB
/
eslint.setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { defineCommand, runMain } from "citty";
import consola from "consola";
import { defineAddon } from "$/scripts/utils";
// ▶️ pnpm tsx eslint.setup.ts
// TODO: Move this code to a separate package
// Utils for setting up ESLint configuration file
const main = defineCommand({
args: {
deprecated: {
description: "@blefnk/eslint-reliverse-addons/cluster",
type: "boolean",
},
toggler: {
description: "@blefnk/eslint-reliverse-addons/toggler",
type: "boolean",
},
},
meta: {
name: "eslint-reliverse-addons",
description: "@blefnk/eslint-reliverse-addons",
version: "0.0.0-canary.0",
},
async run() {
consola.info("More ESLint utilities coming soon! 🚀");
const message = defineAddon(
"📦",
"@blefnk/eslint-reliverse-addons",
"ESLint utility to apply",
"<enter>",
);
const selected = await consola.prompt(message, {
options: [
"Test how well I know ESLint",
"Switch between default and recommended config",
"Find deprecated rules",
"Toggle all ESLint rules",
] as const,
type: "select",
});
if (typeof selected !== "string") {
process.exit(0);
}
switch (selected) {
case "Find deprecated rules":
consola.info(
"💡 py addons/scripts/reliverse/relimter/python/tasks/find-eslint-dep-rules.py",
);
consola.info(
"Ensure you've Python installed, learn more in the Scripts and Python sections of README.md file",
);
break;
case "Switch between default and recommended config":
consola.info(
"💡 Run `pnpm reli:setup` to switch between `default` (almost every rules disabled) and `recommended` ESLint configs",
);
break;
case "Test how well I know ESLint":
consola.info("💡 pnpm reli:academy");
break;
case "Toggle all ESLint rules":
consola.info(
"py addons/scripts/reliverse/relimter/python/tasks/toggle-all-eslint-rules.py",
);
consola.info(
"Ensure you've Python installed, learn more in the Scripts and Python sections of README.md file",
);
break;
default:
break;
}
},
});
const flags = ["--academy", "--preset", "--deprecated", "--toggler"] as const;
function withArgument() {
const flagged = process.argv[2] as (typeof flags)[number];
consola.info("More ESLint utilities coming soon! 🚀\n");
switch (flagged) {
case "--academy":
consola.info("💡 pnpm reli:academy");
break;
case "--deprecated":
consola.info(
"💡 py addons/scripts/reliverse/relimter/python/tasks/find-eslint-dep-rules.py",
);
consola.info(
"Ensure you've Python installed, learn more in the Scripts and Python sections of README.md file",
);
break;
case "--preset":
consola.info(
"💡 Run `pnpm reli:setup` to switch between `default` (almost every rules disabled) and `recommended` ESLint configs",
);
break;
case "--toggler":
consola.info(
"💡 py addons/scripts/reliverse/relimter/python/tasks/toggle-all-eslint-rules.py",
);
consola.info(
"Ensure you've Python installed, learn more in the Scripts and Python sections of README.md file",
);
break;
default:
break;
}
}
const withFlag = flags.some((flag) => process.argv.includes(flag));
if (withFlag) {
withArgument();
} else {
runMain(main);
}
export default main;