@coderwyd/eslint-config 1.1.1 → 2.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/dist/cli.js CHANGED
@@ -17,32 +17,30 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "1.1.1";
20
+ var version = "2.0.0";
21
21
  var devDependencies = {
22
- "@antfu/ni": "^0.21.10",
23
- "@stylistic/eslint-plugin-migrate": "^1.4.0",
24
- "@types/eslint": "^8.44.7",
22
+ "@antfu/ni": "^0.21.12",
23
+ "@types/eslint": "^8.56.0",
25
24
  "@types/fs-extra": "^11.0.4",
26
- "@types/node": "^20.9.4",
25
+ "@types/node": "^20.10.5",
27
26
  "@types/prompts": "^2.4.9",
28
27
  "@types/yargs": "^17.0.32",
29
- "@unocss/eslint-plugin": "^0.57.7",
30
- bumpp: "^9.2.0",
31
- eslint: "^8.54.0",
32
- "eslint-flat-config-viewer": "^0.1.3",
28
+ "@unocss/eslint-plugin": "^0.58.2",
29
+ bumpp: "^9.2.1",
30
+ eslint: "^8.56.0",
31
+ "eslint-flat-config-viewer": "^0.1.4",
33
32
  "eslint-plugin-react": "^7.33.2",
34
33
  "eslint-plugin-react-hooks": "^4.6.0",
35
- "eslint-plugin-react-refresh": "^0.4.4",
34
+ "eslint-plugin-react-refresh": "^0.4.5",
36
35
  esno: "^4.0.0",
37
36
  execa: "^8.0.1",
38
37
  "fast-glob": "^3.3.2",
39
- "fs-extra": "^11.1.1",
40
- "lint-staged": "^15.1.0",
38
+ "fs-extra": "^11.2.0",
39
+ "lint-staged": "^15.2.0",
41
40
  rimraf: "^5.0.5",
42
41
  "simple-git-hooks": "^2.9.0",
43
42
  tsup: "^8.0.1",
44
- typescript: "^5.3.2",
45
- vitest: "^0.34.6"
43
+ typescript: "^5.3.3"
46
44
  };
47
45
 
48
46
  // src/cli/constants.ts
@@ -65,31 +63,20 @@ var vscodeSettingsString = `
65
63
  "source.organizeImports": "never"
66
64
  },
67
65
 
68
- // Silent the stylistic rules in you IDE, but still auto fix them
69
- "eslint.rules.customizations": [
70
- { "rule": "style/*", "severity": "off" },
71
- { "rule": "*-indent", "severity": "off" },
72
- { "rule": "*-spacing", "severity": "off" },
73
- { "rule": "*-spaces", "severity": "off" },
74
- { "rule": "*-order", "severity": "off" },
75
- { "rule": "*-dangle", "severity": "off" },
76
- { "rule": "*-newline", "severity": "off" },
77
- { "rule": "*quotes", "severity": "off" },
78
- { "rule": "*semi", "severity": "off" }
79
- ],
80
-
81
66
  // Enable eslint for all supported languages
82
67
  "eslint.validate": [
83
- "javascript",
84
- "javascriptreact",
85
- "typescript",
86
- "typescriptreact",
87
- "vue",
68
+ "svelte",
69
+ "astro",
88
70
  "html",
89
- "markdown",
71
+ "css",
72
+ "less",
73
+ "scss",
90
74
  "json",
91
75
  "jsonc",
92
- "yaml"
76
+ "yaml",
77
+ "yml",
78
+ "markdown",
79
+ "toml"
93
80
  ]
94
81
  `;
95
82
 
@@ -113,11 +100,23 @@ async function run(options = {}) {
113
100
  const pathPackageJSON = path.join(cwd, "package.json");
114
101
  const pathESLintIngore = path.join(cwd, ".eslintignore");
115
102
  if (fs.existsSync(pathFlatConfig)) {
116
- console.log(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
117
- return;
103
+ console.log(
104
+ c2.yellow(
105
+ `${WARN} eslint.config.js already exists, migration wizard exited.`
106
+ )
107
+ );
108
+ return process.exit(1);
109
+ }
110
+ if (!SKIP_GIT_CHECK && !isGitClean()) {
111
+ const { confirmed } = await prompts({
112
+ initial: false,
113
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
114
+ name: "confirmed",
115
+ type: "confirm"
116
+ });
117
+ if (!confirmed)
118
+ return process.exit(1);
118
119
  }
119
- if (!SKIP_GIT_CHECK && !isGitClean())
120
- throw new Error("There are uncommitted changes in the current repository, please commit them and try again");
121
120
  console.log(c2.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`));
122
121
  const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
123
122
  const pkg = JSON.parse(pkgContent);
@@ -137,24 +136,26 @@ async function run(options = {}) {
137
136
  if (glob.type === "ignore")
138
137
  eslintIgnores.push(...glob.patterns);
139
138
  else if (glob.type === "unignore")
140
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
139
+ eslintIgnores.push(
140
+ ...glob.patterns.map((pattern) => `!${pattern}`)
141
+ );
141
142
  }
142
143
  }
143
144
  let eslintConfigContent = "";
144
145
  const coderwydConfig = `${eslintIgnores.length ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
145
146
  if (pkg.type === "module") {
146
147
  eslintConfigContent = `
147
- import coderwyd from '@coderwyd/eslint-config'
148
+ import { defineConfig } from '@coderwyd/eslint-config'
148
149
 
149
- export default coderwyd({
150
+ export default defineConfig({
150
151
  ${coderwydConfig}
151
152
  })
152
153
  `.trimStart();
153
154
  } else {
154
155
  eslintConfigContent = `
155
- const coderwyd = require('@coderwyd/eslint-config').default
156
+ const { defineConfig } = require('@coderwyd/eslint-config')
156
157
 
157
- module.exports = coderwyd({
158
+ module.exports = defineConfig({
158
159
  ${coderwydConfig}
159
160
  })
160
161
  `.trimStart();
@@ -176,22 +177,25 @@ ${coderwydConfig}
176
177
  };
177
178
  if (!SKIP_PROMPT) {
178
179
  try {
179
- promptResult = await prompts({
180
- initial: true,
181
- message: "Update .vscode/settings.json for better VS Code experience?",
182
- name: "updateVscodeSettings",
183
- type: "confirm"
184
- }, {
185
- onCancel: () => {
186
- throw new Error(`Cancelled`);
180
+ promptResult = await prompts(
181
+ {
182
+ initial: true,
183
+ message: "Update .vscode/settings.json for better VS Code experience?",
184
+ name: "updateVscodeSettings",
185
+ type: "confirm"
186
+ },
187
+ {
188
+ onCancel: () => {
189
+ throw new Error(`Cancelled`);
190
+ }
187
191
  }
188
- });
192
+ );
189
193
  } catch (cancelled) {
190
194
  console.log(cancelled.message);
191
195
  return;
192
196
  }
193
197
  }
194
- if (promptResult?.updateVscodeSettings ?? true) {
198
+ if ((promptResult == null ? void 0 : promptResult.updateVscodeSettings) ?? true) {
195
199
  const dotVscodePath = path.join(cwd, ".vscode");
196
200
  const settingsPath = path.join(dotVscodePath, "settings.json");
197
201
  if (!fs.existsSync(dotVscodePath))
@@ -211,8 +215,10 @@ ${coderwydConfig}
211
215
  }
212
216
  }
213
217
  console.log(c2.green(`${CHECK} migration completed`));
214
- console.log(`Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
215
- `);
218
+ console.log(
219
+ `Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
220
+ `
221
+ );
216
222
  }
217
223
 
218
224
  // src/cli/index.ts
@@ -223,7 +229,11 @@ ${c3.green(`@coderwyd/eslint-config `)}${c3.dim(`v${version}`)}`);
223
229
  var instance = yargs(hideBin(process2.argv)).scriptName("@coderwyd/eslint-config").usage("").command(
224
230
  "*",
225
231
  "Run the initialization or migration",
226
- (args) => args.option("yes", { alias: "y", description: "Skip prompts and use default values", type: "boolean" }).help(),
232
+ (args) => args.option("yes", {
233
+ alias: "y",
234
+ description: "Skip prompts and use default values",
235
+ type: "boolean"
236
+ }).help(),
227
237
  async (args) => {
228
238
  header();
229
239
  console.log();