@kirklin/eslint-config 8.1.0 → 8.2.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/dist/cli.mjs CHANGED
@@ -7,10 +7,8 @@ import c, { green } from "ansis";
7
7
  import { cac } from "cac";
8
8
  import parse from "parse-gitignore";
9
9
  import { execSync } from "node:child_process";
10
-
11
10
  //#region package.json
12
- var version = "8.1.0";
13
-
11
+ var version = "8.2.0";
14
12
  //#endregion
15
13
  //#region src/cli/constants.ts
16
14
  const vscodeSettingsString = `
@@ -105,18 +103,13 @@ const dependenciesMap = {
105
103
  formatter: ["eslint-plugin-format"],
106
104
  formatterAstro: ["prettier-plugin-astro"],
107
105
  nextjs: ["@next/eslint-plugin-next"],
108
- react: [
109
- "@eslint-react/eslint-plugin",
110
- "eslint-plugin-react-hooks",
111
- "eslint-plugin-react-refresh"
112
- ],
106
+ react: ["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"],
113
107
  slidev: ["prettier-plugin-slidev"],
114
108
  solid: ["eslint-plugin-solid"],
115
109
  svelte: ["eslint-plugin-svelte", "svelte-eslint-parser"],
116
110
  unocss: ["@unocss/eslint-plugin"],
117
111
  vue: []
118
112
  };
119
-
120
113
  //#endregion
121
114
  //#region src/cli/utils.ts
122
115
  function isGitClean() {
@@ -136,9 +129,10 @@ ${mainConfig}
136
129
  }${additionalConfigs?.map((config) => `,{\n${config}\n}`)})
137
130
  `.trimStart();
138
131
  }
139
-
140
132
  //#endregion
141
133
  //#region src/cli/stages/update-eslint-files.ts
134
+ const ESLINT_OR_PRETTIER = /eslint|prettier/;
135
+ const ESLINT_CONFIG = /eslint\.config\./;
142
136
  async function updateEslintFiles(result) {
143
137
  const cwd = process.cwd();
144
138
  const pathESLintIgnore = path.join(cwd, ".eslintignore");
@@ -164,30 +158,27 @@ async function updateEslintFiles(result) {
164
158
  const files = fs$1.readdirSync(cwd);
165
159
  const legacyConfig = [];
166
160
  files.forEach((file) => {
167
- if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
161
+ if (ESLINT_OR_PRETTIER.test(file) && !ESLINT_CONFIG.test(file)) legacyConfig.push(file);
168
162
  });
169
163
  if (legacyConfig.length) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
170
164
  }
171
-
172
165
  //#endregion
173
166
  //#region src/cli/constants-generated.ts
174
167
  const versionsMap = {
175
- "@eslint-react/eslint-plugin": "^2.13.0",
176
- "@next/eslint-plugin-next": "^16.1.6",
177
- "@unocss/eslint-plugin": "^66.6.0",
178
- "astro-eslint-parser": "^1.3.0",
179
- "eslint": "^10.0.0",
168
+ "@eslint-react/eslint-plugin": "^3.0.0",
169
+ "@next/eslint-plugin-next": "^16.2.2",
170
+ "@unocss/eslint-plugin": "^66.6.7",
171
+ "astro-eslint-parser": "^1.4.0",
172
+ "eslint": "^10.1.0",
180
173
  "eslint-plugin-astro": "^1.6.0",
181
- "eslint-plugin-format": "^1.4.0",
182
- "eslint-plugin-react-hooks": "^7.0.1",
183
- "eslint-plugin-react-refresh": "^0.5.0",
174
+ "eslint-plugin-format": "^2.0.1",
175
+ "eslint-plugin-react-refresh": "^0.5.2",
184
176
  "eslint-plugin-solid": "^0.14.5",
185
- "eslint-plugin-svelte": "^3.15.0",
177
+ "eslint-plugin-svelte": "^3.16.0",
186
178
  "prettier-plugin-astro": "^0.14.1",
187
179
  "prettier-plugin-slidev": "^1.0.5",
188
- "svelte-eslint-parser": "^1.4.1"
180
+ "svelte-eslint-parser": "^1.6.0"
189
181
  };
190
-
191
182
  //#endregion
192
183
  //#region src/cli/stages/update-package-json.ts
193
184
  async function updatePackageJson(result) {
@@ -228,9 +219,9 @@ async function updatePackageJson(result) {
228
219
  await fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
229
220
  p.log.success(c.green`Changes wrote to package.json`);
230
221
  }
231
-
232
222
  //#endregion
233
223
  //#region src/cli/stages/update-vscode-settings.ts
224
+ const LAST_LINE_PATTERN = /\s*\}$/;
234
225
  async function updateVscodeSettings(result) {
235
226
  const cwd = process.cwd();
236
227
  if (!result.updateVscodeSettings) return;
@@ -242,14 +233,13 @@ async function updateVscodeSettings(result) {
242
233
  p.log.success(green`Created .vscode/settings.json`);
243
234
  } else {
244
235
  let settingsContent = await fs.readFile(settingsPath, "utf8");
245
- settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
236
+ settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
246
237
  settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
247
238
  settingsContent += `${vscodeSettingsString}}\n`;
248
239
  await fs.writeFile(settingsPath, settingsContent, "utf-8");
249
240
  p.log.success(green`Updated .vscode/settings.json`);
250
241
  }
251
242
  }
252
-
253
243
  //#endregion
254
244
  //#region src/cli/run.ts
255
245
  async function run(options = {}) {
@@ -314,7 +304,6 @@ async function run(options = {}) {
314
304
  p.log.success(c.green`Setup completed`);
315
305
  p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
316
306
  }
317
-
318
307
  //#endregion
319
308
  //#region src/cli/index.ts
320
309
  function header() {
@@ -335,6 +324,5 @@ cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip
335
324
  cli.help();
336
325
  cli.version(version);
337
326
  cli.parse();
338
-
339
327
  //#endregion
340
- export { };
328
+ export {};