@kirklin/eslint-config 2.6.0 → 2.7.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/LICENSE +21 -21
- package/README.md +6 -4
- package/README.zh-cn.md +3 -1
- package/dist/cli.cjs +141 -139
- package/dist/cli.js +141 -139
- package/dist/index.cjs +231 -181
- package/dist/index.d.cts +1271 -559
- package/dist/index.d.ts +1271 -559
- package/dist/index.js +240 -191
- package/package.json +55 -56
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019-PRESENT Kirk Lin<https://github.com/kirklin>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-PRESENT Kirk Lin<https://github.com/kirklin>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -39,10 +39,12 @@
|
|
|
39
39
|
- Single quotes, no semi
|
|
40
40
|
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
41
41
|
- Respects `.gitignore` by default
|
|
42
|
-
-
|
|
42
|
+
- Requires ESLint v9.5.0+
|
|
43
43
|
|
|
44
|
-
> [!
|
|
44
|
+
> [!NOTE]
|
|
45
45
|
> Since v1.0.0, this config is rewritten to the new [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), check the [release note](https://github.com/kirklin/eslint-config/releases/tag/v1.0.0) for more details.
|
|
46
|
+
>
|
|
47
|
+
> Since v2.7.0, ESLint v9.5.0+ is now required.
|
|
46
48
|
|
|
47
49
|
## Usage
|
|
48
50
|
|
|
@@ -79,9 +81,9 @@ Combined with legacy config:
|
|
|
79
81
|
If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
|
|
80
82
|
|
|
81
83
|
```js
|
|
84
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
82
85
|
// eslint.config.mjs
|
|
83
86
|
import kirklin from "@kirklin/eslint-config";
|
|
84
|
-
import { FlatCompat } from "@eslint/eslintrc";
|
|
85
87
|
|
|
86
88
|
const compat = new FlatCompat();
|
|
87
89
|
|
|
@@ -287,7 +289,7 @@ And that's it! Or you can configure each integration individually, for example:
|
|
|
287
289
|
import kirklin from "@kirklin/eslint-config";
|
|
288
290
|
|
|
289
291
|
export default kirklin({
|
|
290
|
-
|
|
292
|
+
// Type of the project. 'lib' for libraries, the default is 'app'
|
|
291
293
|
type: "lib",
|
|
292
294
|
|
|
293
295
|
// Enable stylistic formatting rules
|
package/README.zh-cn.md
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
|
|
43
43
|
> [!IMPORTANT]
|
|
44
44
|
> 从v1.0.0开始,该配置已重写为新的 [ESLint Flat配置](https://eslint.org/docs/latest/use/configure/configuration-files-new), 请查看[发布说明](https://github.com/kirklin/eslint-config/releases/tag/v1.0.0)以获取更多详细信息。
|
|
45
|
+
>
|
|
46
|
+
> 自 v2.7.0 起,需要 ESLint v9.5.0+。
|
|
45
47
|
|
|
46
48
|
## 使用方法
|
|
47
49
|
|
|
@@ -78,9 +80,9 @@ export default kirklin();
|
|
|
78
80
|
如果您仍然使用旧版`eslintrc`的一些配置,您可以使用[`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc)将它们转换为flat config
|
|
79
81
|
|
|
80
82
|
```js
|
|
83
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
81
84
|
// eslint.config.mjs
|
|
82
85
|
import kirklin from "@kirklin/eslint-config";
|
|
83
|
-
import { FlatCompat } from "@eslint/eslintrc";
|
|
84
86
|
|
|
85
87
|
const compat = new FlatCompat();
|
|
86
88
|
|
package/dist/cli.cjs
CHANGED
|
@@ -29,17 +29,10 @@ module.exports = __toCommonJS(cli_exports);
|
|
|
29
29
|
|
|
30
30
|
// src/cli/index.ts
|
|
31
31
|
var import_node_process5 = __toESM(require("process"), 1);
|
|
32
|
+
var p5 = __toESM(require("@clack/prompts"), 1);
|
|
32
33
|
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
33
|
-
var import_helpers = require("yargs/helpers");
|
|
34
34
|
var import_yargs = __toESM(require("yargs"), 1);
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
// src/cli/run.ts
|
|
38
|
-
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
39
|
-
var import_node_path4 = __toESM(require("path"), 1);
|
|
40
|
-
var import_node_process4 = __toESM(require("process"), 1);
|
|
41
|
-
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
42
|
-
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
35
|
+
var import_helpers = require("yargs/helpers");
|
|
43
36
|
|
|
44
37
|
// src/cli/constants.ts
|
|
45
38
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
@@ -48,8 +41,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
|
|
|
48
41
|
var package_default = {
|
|
49
42
|
name: "@kirklin/eslint-config",
|
|
50
43
|
type: "module",
|
|
51
|
-
version: "2.
|
|
52
|
-
packageManager: "pnpm@9.
|
|
44
|
+
version: "2.7.0",
|
|
45
|
+
packageManager: "pnpm@9.12.3",
|
|
53
46
|
description: "Kirk Lin's ESLint config",
|
|
54
47
|
author: "Kirk Lin (https://github.com/kirklin/)",
|
|
55
48
|
license: "MIT",
|
|
@@ -91,12 +84,12 @@ var package_default = {
|
|
|
91
84
|
"@prettier/plugin-xml": "^3.4.1",
|
|
92
85
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
93
86
|
"astro-eslint-parser": "^1.0.2",
|
|
94
|
-
eslint: "
|
|
87
|
+
eslint: "^9.10.0",
|
|
95
88
|
"eslint-plugin-astro": "^1.2.0",
|
|
96
89
|
"eslint-plugin-format": ">=0.1.0",
|
|
97
|
-
"eslint-plugin-react-hooks": "^
|
|
90
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
98
91
|
"eslint-plugin-react-refresh": "^0.4.4",
|
|
99
|
-
"eslint-plugin-solid": "^0.
|
|
92
|
+
"eslint-plugin-solid": "^0.14.3",
|
|
100
93
|
"eslint-plugin-svelte": ">=2.35.1",
|
|
101
94
|
"prettier-plugin-astro": "^0.13.0",
|
|
102
95
|
"prettier-plugin-slidev": "^1.0.5",
|
|
@@ -146,86 +139,85 @@ var package_default = {
|
|
|
146
139
|
dependencies: {
|
|
147
140
|
"@antfu/install-pkg": "^0.4.1",
|
|
148
141
|
"@clack/prompts": "^0.7.0",
|
|
149
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.
|
|
150
|
-
"@
|
|
151
|
-
"@
|
|
152
|
-
"@typescript-eslint/
|
|
153
|
-
"@
|
|
154
|
-
"eslint-
|
|
155
|
-
"eslint-flat-
|
|
142
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
143
|
+
"@eslint/markdown": "^6.2.1",
|
|
144
|
+
"@stylistic/eslint-plugin": "^2.10.1",
|
|
145
|
+
"@typescript-eslint/eslint-plugin": "^8.12.2",
|
|
146
|
+
"@typescript-eslint/parser": "^8.12.2",
|
|
147
|
+
"@vitest/eslint-plugin": "^1.1.7",
|
|
148
|
+
"eslint-config-flat-gitignore": "^0.3.0",
|
|
149
|
+
"eslint-flat-config-utils": "^0.4.0",
|
|
156
150
|
"eslint-merge-processors": "^0.1.0",
|
|
157
|
-
"eslint-plugin-command": "^0.2.
|
|
158
|
-
"eslint-plugin-import-x": "^4.
|
|
159
|
-
"eslint-plugin-jsdoc": "^50.
|
|
151
|
+
"eslint-plugin-command": "^0.2.6",
|
|
152
|
+
"eslint-plugin-import-x": "^4.4.0",
|
|
153
|
+
"eslint-plugin-jsdoc": "^50.4.3",
|
|
160
154
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
161
|
-
"eslint-plugin-kirklin": "^1.
|
|
162
|
-
"eslint-plugin-
|
|
163
|
-
"eslint-plugin-n": "^17.10.2",
|
|
155
|
+
"eslint-plugin-kirklin": "^1.5.0",
|
|
156
|
+
"eslint-plugin-n": "^17.12.0",
|
|
164
157
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
165
|
-
"eslint-plugin-perfectionist": "^3.
|
|
158
|
+
"eslint-plugin-perfectionist": "^3.9.1",
|
|
166
159
|
"eslint-plugin-regexp": "^2.6.0",
|
|
167
160
|
"eslint-plugin-toml": "^0.11.1",
|
|
168
|
-
"eslint-plugin-unicorn": "^
|
|
169
|
-
"eslint-plugin-unused-imports": "^4.1.
|
|
170
|
-
"eslint-plugin-vue": "^9.
|
|
171
|
-
"eslint-plugin-yml": "^1.
|
|
161
|
+
"eslint-plugin-unicorn": "^56.0.0",
|
|
162
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
163
|
+
"eslint-plugin-vue": "^9.30.0",
|
|
164
|
+
"eslint-plugin-yml": "^1.15.0",
|
|
172
165
|
"eslint-processor-vue-blocks": "^0.1.2",
|
|
173
|
-
globals: "^15.
|
|
166
|
+
globals: "^15.11.0",
|
|
174
167
|
"jsonc-eslint-parser": "^2.4.0",
|
|
175
168
|
"local-pkg": "^0.5.0",
|
|
176
169
|
"parse-gitignore": "^2.0.0",
|
|
177
|
-
picocolors: "^1.
|
|
170
|
+
picocolors: "^1.1.1",
|
|
178
171
|
"toml-eslint-parser": "^0.10.0",
|
|
179
172
|
"vue-eslint-parser": "^9.4.3",
|
|
180
173
|
"yaml-eslint-parser": "^1.2.3",
|
|
181
174
|
yargs: "^17.7.2"
|
|
182
175
|
},
|
|
183
176
|
devDependencies: {
|
|
184
|
-
"@antfu/ni": "^0.
|
|
185
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
186
|
-
"@eslint/config-inspector": "^0.5.
|
|
177
|
+
"@antfu/ni": "^0.23.0",
|
|
178
|
+
"@eslint-react/eslint-plugin": "^1.15.2",
|
|
179
|
+
"@eslint/config-inspector": "^0.5.6",
|
|
187
180
|
"@kirklin/eslint-config": "workspace:*",
|
|
188
181
|
"@prettier/plugin-xml": "^3.4.1",
|
|
189
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
190
|
-
"@types/eslint": "^9.6.1",
|
|
182
|
+
"@stylistic/eslint-plugin-migrate": "^2.10.1",
|
|
191
183
|
"@types/fs-extra": "^11.0.4",
|
|
192
|
-
"@types/node": "^22.
|
|
184
|
+
"@types/node": "^22.8.6",
|
|
193
185
|
"@types/prompts": "^2.4.9",
|
|
194
186
|
"@types/yargs": "^17.0.33",
|
|
195
|
-
"@unocss/eslint-plugin": "^0.
|
|
196
|
-
"astro-eslint-parser": "^1.0.
|
|
197
|
-
bumpp: "^9.
|
|
198
|
-
eslint: "^9.
|
|
199
|
-
"eslint-plugin-astro": "^1.
|
|
187
|
+
"@unocss/eslint-plugin": "^0.63.6",
|
|
188
|
+
"astro-eslint-parser": "^1.0.3",
|
|
189
|
+
bumpp: "^9.8.0",
|
|
190
|
+
eslint: "^9.14.0",
|
|
191
|
+
"eslint-plugin-astro": "^1.3.0",
|
|
200
192
|
"eslint-plugin-format": "^0.1.2",
|
|
201
|
-
"eslint-plugin-react-hooks": "^
|
|
202
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
203
|
-
"eslint-plugin-solid": "^0.14.
|
|
204
|
-
"eslint-plugin-svelte": "^2.
|
|
205
|
-
"eslint-typegen": "^0.3.
|
|
206
|
-
esno: "^4.
|
|
207
|
-
execa: "^9.
|
|
193
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
194
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
195
|
+
"eslint-plugin-solid": "^0.14.3",
|
|
196
|
+
"eslint-plugin-svelte": "^2.46.0",
|
|
197
|
+
"eslint-typegen": "^0.3.2",
|
|
198
|
+
esno: "^4.8.0",
|
|
199
|
+
execa: "^9.5.1",
|
|
208
200
|
"fast-glob": "^3.3.2",
|
|
209
201
|
"fs-extra": "^11.2.0",
|
|
210
|
-
jiti: "^
|
|
211
|
-
"lint-staged": "^15.2.
|
|
202
|
+
jiti: "^2.4.0",
|
|
203
|
+
"lint-staged": "^15.2.10",
|
|
212
204
|
"prettier-plugin-astro": "^0.14.1",
|
|
213
205
|
"prettier-plugin-slidev": "^1.0.5",
|
|
214
206
|
rimraf: "^6.0.1",
|
|
215
207
|
"simple-git-hooks": "^2.11.1",
|
|
216
|
-
svelte: "^
|
|
217
|
-
"svelte-eslint-parser": "^0.
|
|
218
|
-
tsup: "^8.
|
|
219
|
-
tsx: "^4.
|
|
220
|
-
typescript: "^5.
|
|
221
|
-
vitest: "^2.
|
|
222
|
-
vue: "^3.
|
|
208
|
+
svelte: "^5.1.9",
|
|
209
|
+
"svelte-eslint-parser": "^0.43.0",
|
|
210
|
+
tsup: "^8.3.5",
|
|
211
|
+
tsx: "^4.19.2",
|
|
212
|
+
typescript: "^5.6.3",
|
|
213
|
+
vitest: "^2.1.4",
|
|
214
|
+
vue: "^3.5.12"
|
|
223
215
|
},
|
|
224
216
|
resolutions: {
|
|
225
|
-
"@eslint-community/eslint-utils": "^4.4.
|
|
226
|
-
"@typescript-eslint/utils": "^8.
|
|
227
|
-
eslint: "^9.
|
|
228
|
-
tsx: "^4.
|
|
217
|
+
"@eslint-community/eslint-utils": "^4.4.1",
|
|
218
|
+
"@typescript-eslint/utils": "^8.12.2",
|
|
219
|
+
eslint: "^9.14.0",
|
|
220
|
+
tsx: "^4.19.2"
|
|
229
221
|
},
|
|
230
222
|
"simple-git-hooks": {
|
|
231
223
|
"pre-commit": "npx lint-staged"
|
|
@@ -271,6 +263,7 @@ var vscodeSettingsString = `
|
|
|
271
263
|
"html",
|
|
272
264
|
"markdown",
|
|
273
265
|
"json",
|
|
266
|
+
"json5",
|
|
274
267
|
"jsonc",
|
|
275
268
|
"yaml",
|
|
276
269
|
"toml",
|
|
@@ -347,6 +340,22 @@ var dependenciesMap = {
|
|
|
347
340
|
vue: []
|
|
348
341
|
};
|
|
349
342
|
|
|
343
|
+
// src/cli/run.ts
|
|
344
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
345
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
346
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
347
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
348
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
349
|
+
|
|
350
|
+
// src/cli/stages/update-eslint-files.ts
|
|
351
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
352
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
353
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
354
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
355
|
+
var p = __toESM(require("@clack/prompts"), 1);
|
|
356
|
+
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
357
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
358
|
+
|
|
350
359
|
// src/cli/utils.ts
|
|
351
360
|
var import_node_child_process = require("child_process");
|
|
352
361
|
function isGitClean() {
|
|
@@ -369,18 +378,71 @@ ${config}
|
|
|
369
378
|
`.trimStart();
|
|
370
379
|
}
|
|
371
380
|
|
|
372
|
-
// src/cli/stages/update-
|
|
373
|
-
|
|
374
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
375
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
376
|
-
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
377
|
-
var p = __toESM(require("@clack/prompts"), 1);
|
|
378
|
-
async function updatePackageJson(result) {
|
|
381
|
+
// src/cli/stages/update-eslint-files.ts
|
|
382
|
+
async function updateEslintFiles(result) {
|
|
379
383
|
const cwd = import_node_process.default.cwd();
|
|
384
|
+
const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
|
|
380
385
|
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
381
|
-
p.log.step(import_picocolors2.default.cyan(`Bumping @kirklin/eslint-config to v${package_default.version}`));
|
|
382
386
|
const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
|
|
383
387
|
const pkg = JSON.parse(pkgContent);
|
|
388
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
389
|
+
const pathFlatConfig = import_node_path.default.join(cwd, configFileName);
|
|
390
|
+
const eslintIgnores = [];
|
|
391
|
+
if (import_node_fs.default.existsSync(pathESLintIgnore)) {
|
|
392
|
+
p.log.step(import_picocolors2.default.cyan(`Migrating existing .eslintignore`));
|
|
393
|
+
const content = await import_promises.default.readFile(pathESLintIgnore, "utf-8");
|
|
394
|
+
const parsed = (0, import_parse_gitignore.default)(content);
|
|
395
|
+
const globs = parsed.globs();
|
|
396
|
+
for (const glob of globs) {
|
|
397
|
+
if (glob.type === "ignore") {
|
|
398
|
+
eslintIgnores.push(...glob.patterns);
|
|
399
|
+
} else if (glob.type === "unignore") {
|
|
400
|
+
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const configLines = [];
|
|
405
|
+
if (eslintIgnores.length) {
|
|
406
|
+
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
407
|
+
}
|
|
408
|
+
if (result.extra.includes("formatter")) {
|
|
409
|
+
configLines.push(`formatters: true,`);
|
|
410
|
+
}
|
|
411
|
+
if (result.extra.includes("unocss")) {
|
|
412
|
+
configLines.push(`unocss: true,`);
|
|
413
|
+
}
|
|
414
|
+
for (const framework of result.frameworks) {
|
|
415
|
+
configLines.push(`${framework}: true,`);
|
|
416
|
+
}
|
|
417
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
418
|
+
const additionalConfig = [];
|
|
419
|
+
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
420
|
+
await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
421
|
+
p.log.success(import_picocolors2.default.green(`Created ${configFileName}`));
|
|
422
|
+
const files = import_node_fs.default.readdirSync(cwd);
|
|
423
|
+
const legacyConfig = [];
|
|
424
|
+
files.forEach((file) => {
|
|
425
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
|
|
426
|
+
legacyConfig.push(file);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
if (legacyConfig.length) {
|
|
430
|
+
p.note(`${import_picocolors2.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// src/cli/stages/update-package-json.ts
|
|
435
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
436
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
437
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
438
|
+
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
439
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
440
|
+
async function updatePackageJson(result) {
|
|
441
|
+
const cwd = import_node_process2.default.cwd();
|
|
442
|
+
const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
|
|
443
|
+
p2.log.step(import_picocolors3.default.cyan(`Bumping @kirklin/eslint-config to v${package_default.version}`));
|
|
444
|
+
const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
|
|
445
|
+
const pkg = JSON.parse(pkgContent);
|
|
384
446
|
pkg.devDependencies ??= {};
|
|
385
447
|
pkg.devDependencies["@kirklin/eslint-config"] = `^${package_default.version}`;
|
|
386
448
|
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
|
|
@@ -421,79 +483,19 @@ async function updatePackageJson(result) {
|
|
|
421
483
|
}
|
|
422
484
|
}
|
|
423
485
|
if (addedPackages.length) {
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
427
|
-
p.log.success(import_picocolors2.default.green(`Changes wrote to package.json`));
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// src/cli/stages/update-eslint-files.ts
|
|
431
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
432
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
433
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
434
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
435
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
436
|
-
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
437
|
-
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
438
|
-
async function updateEslintFiles(result) {
|
|
439
|
-
const cwd = import_node_process2.default.cwd();
|
|
440
|
-
const pathESLintIgnore = import_node_path2.default.join(cwd, ".eslintignore");
|
|
441
|
-
const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
|
|
442
|
-
const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
|
|
443
|
-
const pkg = JSON.parse(pkgContent);
|
|
444
|
-
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
445
|
-
const pathFlatConfig = import_node_path2.default.join(cwd, configFileName);
|
|
446
|
-
const eslintIgnores = [];
|
|
447
|
-
if (import_node_fs.default.existsSync(pathESLintIgnore)) {
|
|
448
|
-
p2.log.step(import_picocolors3.default.cyan(`Migrating existing .eslintignore`));
|
|
449
|
-
const content = await import_promises2.default.readFile(pathESLintIgnore, "utf-8");
|
|
450
|
-
const parsed = (0, import_parse_gitignore.default)(content);
|
|
451
|
-
const globs = parsed.globs();
|
|
452
|
-
for (const glob of globs) {
|
|
453
|
-
if (glob.type === "ignore") {
|
|
454
|
-
eslintIgnores.push(...glob.patterns);
|
|
455
|
-
} else if (glob.type === "unignore") {
|
|
456
|
-
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
const configLines = [];
|
|
461
|
-
if (eslintIgnores.length) {
|
|
462
|
-
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
463
|
-
}
|
|
464
|
-
if (result.extra.includes("formatter")) {
|
|
465
|
-
configLines.push(`formatters: true,`);
|
|
466
|
-
}
|
|
467
|
-
if (result.extra.includes("unocss")) {
|
|
468
|
-
configLines.push(`unocss: true,`);
|
|
469
|
-
}
|
|
470
|
-
for (const framework of result.frameworks) {
|
|
471
|
-
configLines.push(`${framework}: true,`);
|
|
472
|
-
}
|
|
473
|
-
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
474
|
-
const additionalConfig = [];
|
|
475
|
-
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
476
|
-
await import_promises2.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
477
|
-
p2.log.success(import_picocolors3.default.green(`Created ${configFileName}`));
|
|
478
|
-
const files = import_node_fs.default.readdirSync(cwd);
|
|
479
|
-
const legacyConfig = [];
|
|
480
|
-
files.forEach((file) => {
|
|
481
|
-
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
|
|
482
|
-
legacyConfig.push(file);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
if (legacyConfig.length) {
|
|
486
|
-
p2.note(`${import_picocolors3.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
486
|
+
p2.note(`${import_picocolors3.default.dim(addedPackages.join(", "))}`, "Added packages");
|
|
487
487
|
}
|
|
488
|
+
await import_promises2.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
489
|
+
p2.log.success(import_picocolors3.default.green(`Changes wrote to package.json`));
|
|
488
490
|
}
|
|
489
491
|
|
|
490
492
|
// src/cli/stages/update-vscode-settings.ts
|
|
491
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
492
|
-
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
493
493
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
494
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
495
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
494
496
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
495
|
-
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
496
497
|
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
498
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
497
499
|
async function updateVscodeSettings(result) {
|
|
498
500
|
const cwd = import_node_process3.default.cwd();
|
|
499
501
|
if (!result.updateVscodeSettings) {
|