@jsse/eslint-config 0.5.2 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @jsse/eslint-config
2
2
 
3
+ ## 0.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - update deps
8
+
3
9
  ## 0.5.2
4
10
 
5
11
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -1,9 +1,8 @@
1
- import { n as DEBUG$1, t as VERSION } from "./version-BMOOQznP.js";
1
+ import { n as DEBUG$1, t as VERSION } from "./version-B7sAPTF4.js";
2
2
  import process$1 from "node:process";
3
3
  import fs from "node:fs";
4
- import { EventEmitter } from "events";
5
4
 
6
- //#region node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
5
+ //#region node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
7
6
  function toArr(any) {
8
7
  return any == null ? [] : Array.isArray(any) ? any : [any];
9
8
  }
@@ -11,7 +10,7 @@ function toVal(out, key, val, opts) {
11
10
  var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
12
11
  out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
13
12
  }
14
- function mri2(args, opts) {
13
+ function lib_default(args, opts) {
15
14
  args = args || [];
16
15
  opts = opts || {};
17
16
  var k, arr, arg, name, val, out = { _: [] };
@@ -22,13 +21,9 @@ function mri2(args, opts) {
22
21
  opts.alias = opts.alias || {};
23
22
  opts.string = toArr(opts.string);
24
23
  opts.boolean = toArr(opts.boolean);
25
- if (alibi) {
26
- for (k in opts.alias) {
27
- arr = opts.alias[k] = toArr(opts.alias[k]);
28
- for (i = 0; i < arr.length; i++) {
29
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
30
- }
31
- }
24
+ if (alibi) for (k in opts.alias) {
25
+ arr = opts.alias[k] = toArr(opts.alias[k]);
26
+ for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
32
27
  }
33
28
  for (i = opts.boolean.length; i-- > 0;) {
34
29
  arr = opts.alias[opts.boolean[i]] || [];
@@ -38,16 +33,12 @@ function mri2(args, opts) {
38
33
  arr = opts.alias[opts.string[i]] || [];
39
34
  for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
40
35
  }
41
- if (defaults) {
42
- for (k in opts.default) {
43
- name = typeof opts.default[k];
44
- arr = opts.alias[k] = opts.alias[k] || [];
45
- if (opts[name] !== void 0) {
46
- opts[name].push(k);
47
- for (i = 0; i < arr.length; i++) {
48
- opts[name].push(arr[i]);
49
- }
50
- }
36
+ if (defaults) for (k in opts.default) {
37
+ name = typeof opts.default[k];
38
+ arr = opts.alias[k] = opts.alias[k] || [];
39
+ if (opts[name] !== void 0) {
40
+ opts[name].push(k);
41
+ for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
51
42
  }
52
43
  }
53
44
  const keys = strict ? Object.keys(opts.alias) : [];
@@ -57,21 +48,14 @@ function mri2(args, opts) {
57
48
  out._ = out._.concat(args.slice(++i));
58
49
  break;
59
50
  }
60
- for (j = 0; j < arg.length; j++) {
61
- if (arg.charCodeAt(j) !== 45) break;
62
- }
63
- if (j === 0) {
64
- out._.push(arg);
65
- } else if (arg.substring(j, j + 3) === "no-") {
51
+ for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
52
+ if (j === 0) out._.push(arg);
53
+ else if (arg.substring(j, j + 3) === "no-") {
66
54
  name = arg.substring(j + 3);
67
- if (strict && !~keys.indexOf(name)) {
68
- return opts.unknown(arg);
69
- }
55
+ if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
70
56
  out[name] = false;
71
57
  } else {
72
- for (idx = j + 1; idx < arg.length; idx++) {
73
- if (arg.charCodeAt(idx) === 61) break;
74
- }
58
+ for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
75
59
  name = arg.substring(j, idx);
76
60
  val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
77
61
  arr = j === 2 ? [name] : name;
@@ -83,24 +67,18 @@ function mri2(args, opts) {
83
67
  }
84
68
  }
85
69
  if (defaults) {
86
- for (k in opts.default) {
87
- if (out[k] === void 0) {
88
- out[k] = opts.default[k];
89
- }
90
- }
70
+ for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
91
71
  }
92
- if (alibi) {
93
- for (k in out) {
94
- arr = opts.alias[k] || [];
95
- while (arr.length > 0) {
96
- out[arr.shift()] = out[k];
97
- }
98
- }
72
+ if (alibi) for (k in out) {
73
+ arr = opts.alias[k] || [];
74
+ while (arr.length > 0) out[arr.shift()] = out[k];
99
75
  }
100
76
  return out;
101
77
  }
102
- const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
103
- const findAllBrackets = (v) => {
78
+ function removeBrackets(v) {
79
+ return v.replace(/[<[].+/, "").trim();
80
+ }
81
+ function findAllBrackets(v) {
104
82
  const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
105
83
  const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
106
84
  const res = [];
@@ -118,99 +96,95 @@ const findAllBrackets = (v) => {
118
96
  };
119
97
  };
120
98
  let angledMatch;
121
- while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
122
- res.push(parse(angledMatch));
123
- }
99
+ while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(angledMatch));
124
100
  let squareMatch;
125
- while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
126
- res.push(parse(squareMatch));
127
- }
101
+ while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
128
102
  return res;
129
- };
130
- const getMriOptions = (options) => {
103
+ }
104
+ function getMriOptions(options) {
131
105
  const result = {
132
106
  alias: {},
133
107
  boolean: []
134
108
  };
135
109
  for (const [index, option] of options.entries()) {
136
- if (option.names.length > 1) {
137
- result.alias[option.names[0]] = option.names.slice(1);
138
- }
139
- if (option.isBoolean) {
140
- if (option.negated) {
141
- const hasStringTypeOption = options.some((o, i) => {
142
- return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
143
- });
144
- if (!hasStringTypeOption) {
145
- result.boolean.push(option.names[0]);
146
- }
147
- } else {
148
- result.boolean.push(option.names[0]);
149
- }
150
- }
110
+ if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
111
+ if (option.isBoolean) if (option.negated) {
112
+ if (!options.some((o, i) => {
113
+ return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
114
+ })) result.boolean.push(option.names[0]);
115
+ } else result.boolean.push(option.names[0]);
151
116
  }
152
117
  return result;
153
- };
154
- const findLongest = (arr) => {
118
+ }
119
+ function findLongest(arr) {
155
120
  return arr.sort((a, b) => {
156
121
  return a.length > b.length ? -1 : 1;
157
122
  })[0];
158
- };
159
- const padRight = (str, length) => {
123
+ }
124
+ function padRight(str, length) {
160
125
  return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
161
- };
162
- const camelcase = (input) => {
163
- return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
126
+ }
127
+ function camelcase(input) {
128
+ return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
164
129
  return p1 + p2.toUpperCase();
165
130
  });
166
- };
167
- const setDotProp = (obj, keys, val) => {
168
- let i = 0;
169
- let length = keys.length;
170
- let t = obj;
171
- let x;
172
- for (; i < length; ++i) {
173
- x = t[keys[i]];
174
- t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
131
+ }
132
+ function setDotProp(obj, keys, val) {
133
+ let current = obj;
134
+ for (let i = 0; i < keys.length; i++) {
135
+ const key = keys[i];
136
+ if (i === keys.length - 1) {
137
+ current[key] = val;
138
+ return;
139
+ }
140
+ if (current[key] == null) {
141
+ const nextKeyIsArrayIndex = +keys[i + 1] > -1;
142
+ current[key] = nextKeyIsArrayIndex ? [] : {};
143
+ }
144
+ current = current[key];
175
145
  }
176
- };
177
- const setByType = (obj, transforms) => {
146
+ }
147
+ function setByType(obj, transforms) {
178
148
  for (const key of Object.keys(transforms)) {
179
149
  const transform = transforms[key];
180
150
  if (transform.shouldTransform) {
181
- obj[key] = Array.prototype.concat.call([], obj[key]);
182
- if (typeof transform.transformFunction === "function") {
183
- obj[key] = obj[key].map(transform.transformFunction);
184
- }
151
+ obj[key] = [obj[key]].flat();
152
+ if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
185
153
  }
186
154
  }
187
- };
188
- const getFileName = (input) => {
189
- const m = /([^\\\/]+)$/.exec(input);
155
+ }
156
+ function getFileName(input) {
157
+ const m = /([^\\/]+)$/.exec(input);
190
158
  return m ? m[1] : "";
191
- };
192
- const camelcaseOptionName = (name) => {
159
+ }
160
+ function camelcaseOptionName(name) {
193
161
  return name.split(".").map((v, i) => {
194
162
  return i === 0 ? camelcase(v) : v;
195
163
  }).join(".");
196
- };
164
+ }
197
165
  var CACError = class extends Error {
198
166
  constructor(message) {
199
167
  super(message);
200
- this.name = this.constructor.name;
201
- if (typeof Error.captureStackTrace === "function") {
202
- Error.captureStackTrace(this, this.constructor);
203
- } else {
204
- this.stack = new Error(message).stack;
205
- }
168
+ this.name = "CACError";
169
+ if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
206
170
  }
207
171
  };
208
172
  var Option = class {
173
+ rawName;
174
+ description;
175
+ /** Option name */
176
+ name;
177
+ /** Option name and aliases */
178
+ names;
179
+ isBoolean;
180
+ required;
181
+ config;
182
+ negated;
209
183
  constructor(rawName, description, config) {
210
184
  this.rawName = rawName;
211
185
  this.description = description;
212
186
  this.config = Object.assign({}, config);
213
- rawName = rawName.replace(/\.\*/g, "");
187
+ rawName = rawName.replaceAll(".*", "");
214
188
  this.negated = false;
215
189
  this.names = removeBrackets(rawName).split(",").map((v) => {
216
190
  let name = v.trim().replace(/^-{1,2}/, "");
@@ -220,22 +194,39 @@ var Option = class {
220
194
  }
221
195
  return camelcaseOptionName(name);
222
196
  }).sort((a, b) => a.length > b.length ? 1 : -1);
223
- this.name = this.names[this.names.length - 1];
224
- if (this.negated && this.config.default == null) {
225
- this.config.default = true;
226
- }
227
- if (rawName.includes("<")) {
228
- this.required = true;
229
- } else if (rawName.includes("[")) {
230
- this.required = false;
231
- } else {
232
- this.isBoolean = true;
233
- }
197
+ this.name = this.names.at(-1);
198
+ if (this.negated && this.config.default == null) this.config.default = true;
199
+ if (rawName.includes("<")) this.required = true;
200
+ else if (rawName.includes("[")) this.required = false;
201
+ else this.isBoolean = true;
234
202
  }
235
203
  };
236
- const processArgs = process.argv;
237
- const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
204
+ let runtimeProcessArgs;
205
+ let runtimeInfo;
206
+ if (typeof process !== "undefined") {
207
+ let runtimeName;
208
+ if (typeof Deno !== "undefined" && typeof Deno.version?.deno === "string") runtimeName = "deno";
209
+ else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
210
+ else runtimeName = "node";
211
+ runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
212
+ runtimeProcessArgs = process.argv;
213
+ } else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
214
+ else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
238
215
  var Command = class {
216
+ rawName;
217
+ description;
218
+ config;
219
+ cli;
220
+ options;
221
+ aliasNames;
222
+ name;
223
+ args;
224
+ commandAction;
225
+ usageText;
226
+ versionNumber;
227
+ examples;
228
+ helpCallback;
229
+ globalCommand;
239
230
  constructor(rawName, description, config = {}, cli) {
240
231
  this.rawName = rawName;
241
232
  this.description = description;
@@ -268,6 +259,12 @@ var Command = class {
268
259
  this.examples.push(example);
269
260
  return this;
270
261
  }
262
+ /**
263
+ * Add a option for this command
264
+ * @param rawName Raw option name(s)
265
+ * @param description Option description
266
+ * @param config Option config
267
+ */
271
268
  option(rawName, description, config) {
272
269
  const option = new Option(rawName, description, config);
273
270
  this.options.push(option);
@@ -281,6 +278,10 @@ var Command = class {
281
278
  this.commandAction = callback;
282
279
  return this;
283
280
  }
281
+ /**
282
+ * Check if a command name is matched by this command
283
+ * @param name Command name
284
+ */
284
285
  isMatched(name) {
285
286
  return this.name === name || this.aliasNames.includes(name);
286
287
  }
@@ -290,6 +291,10 @@ var Command = class {
290
291
  get isGlobalCommand() {
291
292
  return this instanceof GlobalCommand;
292
293
  }
294
+ /**
295
+ * Check if an option is registered in this command
296
+ * @param name Option name
297
+ */
293
298
  hasOption(name) {
294
299
  name = name.split(".")[0];
295
300
  return this.options.find((option) => {
@@ -304,24 +309,20 @@ var Command = class {
304
309
  title: "Usage",
305
310
  body: ` $ ${name} ${this.usageText || this.rawName}`
306
311
  });
307
- const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
308
- if (showCommands) {
312
+ if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
309
313
  const longestCommandName = findLongest(commands.map((command) => command.rawName));
310
314
  sections.push({
311
315
  title: "Commands",
312
316
  body: commands.map((command) => {
313
317
  return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
314
318
  }).join("\n")
315
- });
316
- sections.push({
319
+ }, {
317
320
  title: `For more info, run any command with the \`--help\` flag`,
318
321
  body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
319
322
  });
320
323
  }
321
324
  let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
322
- if (!this.isGlobalCommand && !this.isDefaultCommand) {
323
- options = options.filter((option) => option.name !== "version");
324
- }
325
+ if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option) => option.name !== "version");
325
326
  if (options.length > 0) {
326
327
  const longestOptionName = findLongest(options.map((option) => option.rawName));
327
328
  sections.push({
@@ -331,48 +332,41 @@ var Command = class {
331
332
  }).join("\n")
332
333
  });
333
334
  }
334
- if (this.examples.length > 0) {
335
- sections.push({
336
- title: "Examples",
337
- body: this.examples.map((example) => {
338
- if (typeof example === "function") {
339
- return example(name);
340
- }
341
- return example;
342
- }).join("\n")
343
- });
344
- }
345
- if (helpCallback) {
346
- sections = helpCallback(sections) || sections;
347
- }
348
- console.log(sections.map((section) => {
349
- return section.title ? `${section.title}:
350
- ${section.body}` : section.body;
335
+ if (this.examples.length > 0) sections.push({
336
+ title: "Examples",
337
+ body: this.examples.map((example) => {
338
+ if (typeof example === "function") return example(name);
339
+ return example;
340
+ }).join("\n")
341
+ });
342
+ if (helpCallback) sections = helpCallback(sections) || sections;
343
+ console.info(sections.map((section) => {
344
+ return section.title ? `${section.title}:\n${section.body}` : section.body;
351
345
  }).join("\n\n"));
352
346
  }
353
347
  outputVersion() {
354
348
  const { name } = this.cli;
355
349
  const { versionNumber } = this.cli.globalCommand;
356
- if (versionNumber) {
357
- console.log(`${name}/${versionNumber} ${platformInfo}`);
358
- }
350
+ if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
359
351
  }
360
352
  checkRequiredArgs() {
361
353
  const minimalArgsCount = this.args.filter((arg) => arg.required).length;
362
- if (this.cli.args.length < minimalArgsCount) {
363
- throw new CACError(`missing required args for command \`${this.rawName}\``);
364
- }
354
+ if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
365
355
  }
356
+ /**
357
+ * Check if the parsed options contain any unknown options
358
+ *
359
+ * Exit and output error when true
360
+ */
366
361
  checkUnknownOptions() {
367
362
  const { options, globalCommand } = this.cli;
368
363
  if (!this.config.allowUnknownOptions) {
369
- for (const name of Object.keys(options)) {
370
- if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
371
- throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
372
- }
373
- }
364
+ for (const name of Object.keys(options)) if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
374
365
  }
375
366
  }
367
+ /**
368
+ * Check if the required string-type options exist
369
+ */
376
370
  checkOptionValue() {
377
371
  const { options: parsedOptions, globalCommand } = this.cli;
378
372
  const options = [...globalCommand.options, ...this.options];
@@ -380,20 +374,47 @@ ${section.body}` : section.body;
380
374
  const value = parsedOptions[option.name.split(".")[0]];
381
375
  if (option.required) {
382
376
  const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
383
- if (value === true || value === false && !hasNegated) {
384
- throw new CACError(`option \`${option.rawName}\` value is missing`);
385
- }
377
+ if (value === true || value === false && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
386
378
  }
387
379
  }
388
380
  }
381
+ /**
382
+ * Check if the number of args is more than expected
383
+ */
384
+ checkUnusedArgs() {
385
+ const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
386
+ if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
387
+ }
389
388
  };
390
389
  var GlobalCommand = class extends Command {
391
390
  constructor(cli) {
392
391
  super("@@global@@", "", {}, cli);
393
392
  }
394
393
  };
395
- var __assign = Object.assign;
396
- var CAC = class extends EventEmitter {
394
+ var CAC = class extends EventTarget {
395
+ /** The program name to display in help and version message */
396
+ name;
397
+ commands;
398
+ globalCommand;
399
+ matchedCommand;
400
+ matchedCommandName;
401
+ /**
402
+ * Raw CLI arguments
403
+ */
404
+ rawArgs;
405
+ /**
406
+ * Parsed CLI arguments
407
+ */
408
+ args;
409
+ /**
410
+ * Parsed CLI options, camelCased
411
+ */
412
+ options;
413
+ showHelpOnExit;
414
+ showVersionOnExit;
415
+ /**
416
+ * @param name The program name to display in help and version message
417
+ */
397
418
  constructor(name = "") {
398
419
  super();
399
420
  this.name = name;
@@ -404,84 +425,119 @@ var CAC = class extends EventEmitter {
404
425
  this.globalCommand = new GlobalCommand(this);
405
426
  this.globalCommand.usage("<command> [options]");
406
427
  }
428
+ /**
429
+ * Add a global usage text.
430
+ *
431
+ * This is not used by sub-commands.
432
+ */
407
433
  usage(text) {
408
434
  this.globalCommand.usage(text);
409
435
  return this;
410
436
  }
437
+ /**
438
+ * Add a sub-command
439
+ */
411
440
  command(rawName, description, config) {
412
441
  const command = new Command(rawName, description || "", config, this);
413
442
  command.globalCommand = this.globalCommand;
414
443
  this.commands.push(command);
415
444
  return command;
416
445
  }
446
+ /**
447
+ * Add a global CLI option.
448
+ *
449
+ * Which is also applied to sub-commands.
450
+ */
417
451
  option(rawName, description, config) {
418
452
  this.globalCommand.option(rawName, description, config);
419
453
  return this;
420
454
  }
455
+ /**
456
+ * Show help message when `-h, --help` flags appear.
457
+ *
458
+ */
421
459
  help(callback) {
422
460
  this.globalCommand.option("-h, --help", "Display this message");
423
461
  this.globalCommand.helpCallback = callback;
424
462
  this.showHelpOnExit = true;
425
463
  return this;
426
464
  }
465
+ /**
466
+ * Show version number when `-v, --version` flags appear.
467
+ *
468
+ */
427
469
  version(version, customFlags = "-v, --version") {
428
470
  this.globalCommand.version(version, customFlags);
429
471
  this.showVersionOnExit = true;
430
472
  return this;
431
473
  }
474
+ /**
475
+ * Add a global example.
476
+ *
477
+ * This example added here will not be used by sub-commands.
478
+ */
432
479
  example(example) {
433
480
  this.globalCommand.example(example);
434
481
  return this;
435
482
  }
483
+ /**
484
+ * Output the corresponding help message
485
+ * When a sub-command is matched, output the help message for the command
486
+ * Otherwise output the global one.
487
+ *
488
+ */
436
489
  outputHelp() {
437
- if (this.matchedCommand) {
438
- this.matchedCommand.outputHelp();
439
- } else {
440
- this.globalCommand.outputHelp();
441
- }
490
+ if (this.matchedCommand) this.matchedCommand.outputHelp();
491
+ else this.globalCommand.outputHelp();
442
492
  }
493
+ /**
494
+ * Output the version number.
495
+ *
496
+ */
443
497
  outputVersion() {
444
498
  this.globalCommand.outputVersion();
445
499
  }
446
500
  setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
447
501
  this.args = args;
448
502
  this.options = options;
449
- if (matchedCommand) {
450
- this.matchedCommand = matchedCommand;
451
- }
452
- if (matchedCommandName) {
453
- this.matchedCommandName = matchedCommandName;
454
- }
503
+ if (matchedCommand) this.matchedCommand = matchedCommand;
504
+ if (matchedCommandName) this.matchedCommandName = matchedCommandName;
455
505
  return this;
456
506
  }
457
507
  unsetMatchedCommand() {
458
508
  this.matchedCommand = void 0;
459
509
  this.matchedCommandName = void 0;
460
510
  }
461
- parse(argv = processArgs, { run = true } = {}) {
462
- this.rawArgs = argv;
463
- if (!this.name) {
464
- this.name = argv[1] ? getFileName(argv[1]) : "cli";
511
+ /**
512
+ * Parse argv
513
+ */
514
+ parse(argv, { run = true } = {}) {
515
+ if (!argv) {
516
+ if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
517
+ argv = runtimeProcessArgs;
465
518
  }
519
+ this.rawArgs = argv;
520
+ if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
466
521
  let shouldParse = true;
467
522
  for (const command of this.commands) {
468
523
  const parsed = this.mri(argv.slice(2), command);
469
524
  const commandName = parsed.args[0];
470
525
  if (command.isMatched(commandName)) {
471
526
  shouldParse = false;
472
- const parsedInfo = __assign(__assign({}, parsed), { args: parsed.args.slice(1) });
527
+ const parsedInfo = {
528
+ ...parsed,
529
+ args: parsed.args.slice(1)
530
+ };
473
531
  this.setParsedInfo(parsedInfo, command, commandName);
474
- this.emit(`command:${commandName}`, command);
532
+ this.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
475
533
  }
476
534
  }
477
535
  if (shouldParse) {
478
- for (const command of this.commands) {
479
- if (command.name === "") {
480
- shouldParse = false;
481
- const parsed = this.mri(argv.slice(2), command);
482
- this.setParsedInfo(parsed, command);
483
- this.emit(`command:!`, command);
484
- }
536
+ for (const command of this.commands) if (command.isDefaultCommand) {
537
+ shouldParse = false;
538
+ const parsed = this.mri(argv.slice(2), command);
539
+ this.setParsedInfo(parsed, command);
540
+ this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
485
541
  }
486
542
  }
487
543
  if (shouldParse) {
@@ -502,12 +558,8 @@ var CAC = class extends EventEmitter {
502
558
  args: this.args,
503
559
  options: this.options
504
560
  };
505
- if (run) {
506
- this.runMatchedCommand();
507
- }
508
- if (!this.matchedCommand && this.args[0]) {
509
- this.emit("command:*");
510
- }
561
+ if (run) this.runMatchedCommand();
562
+ if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
511
563
  return parsedArgv;
512
564
  }
513
565
  mri(argv, command) {
@@ -515,38 +567,32 @@ var CAC = class extends EventEmitter {
515
567
  const mriOptions = getMriOptions(cliOptions);
516
568
  let argsAfterDoubleDashes = [];
517
569
  const doubleDashesIndex = argv.indexOf("--");
518
- if (doubleDashesIndex > -1) {
570
+ if (doubleDashesIndex !== -1) {
519
571
  argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
520
572
  argv = argv.slice(0, doubleDashesIndex);
521
573
  }
522
- let parsed = mri2(argv, mriOptions);
574
+ let parsed = lib_default(argv, mriOptions);
523
575
  parsed = Object.keys(parsed).reduce((res, name) => {
524
- return __assign(__assign({}, res), { [camelcaseOptionName(name)]: parsed[name] });
576
+ return {
577
+ ...res,
578
+ [camelcaseOptionName(name)]: parsed[name]
579
+ };
525
580
  }, { _: [] });
526
581
  const args = parsed._;
527
582
  const options = { "--": argsAfterDoubleDashes };
528
583
  const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
529
- let transforms = Object.create(null);
584
+ const transforms = Object.create(null);
530
585
  for (const cliOption of cliOptions) {
531
- if (!ignoreDefault && cliOption.config.default !== void 0) {
532
- for (const name of cliOption.names) {
533
- options[name] = cliOption.config.default;
534
- }
535
- }
536
- if (Array.isArray(cliOption.config.type)) {
537
- if (transforms[cliOption.name] === void 0) {
538
- transforms[cliOption.name] = Object.create(null);
539
- transforms[cliOption.name]["shouldTransform"] = true;
540
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
541
- }
586
+ if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
587
+ if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
588
+ transforms[cliOption.name] = Object.create(null);
589
+ transforms[cliOption.name].shouldTransform = true;
590
+ transforms[cliOption.name].transformFunction = cliOption.config.type[0];
542
591
  }
543
592
  }
544
- for (const key of Object.keys(parsed)) {
545
- if (key !== "_") {
546
- const keys = key.split(".");
547
- setDotProp(options, keys, parsed[key]);
548
- setByType(options, transforms);
549
- }
593
+ for (const key of Object.keys(parsed)) if (key !== "_") {
594
+ setDotProp(options, key.split("."), parsed[key]);
595
+ setByType(options, transforms);
550
596
  }
551
597
  return {
552
598
  args,
@@ -559,18 +605,19 @@ var CAC = class extends EventEmitter {
559
605
  command.checkUnknownOptions();
560
606
  command.checkOptionValue();
561
607
  command.checkRequiredArgs();
608
+ command.checkUnusedArgs();
562
609
  const actionArgs = [];
563
610
  command.args.forEach((arg, index) => {
564
- if (arg.variadic) {
565
- actionArgs.push(args.slice(index));
566
- } else {
567
- actionArgs.push(args[index]);
568
- }
611
+ if (arg.variadic) actionArgs.push(args.slice(index));
612
+ else actionArgs.push(args[index]);
569
613
  });
570
614
  actionArgs.push(options);
571
615
  return command.commandAction.apply(this, actionArgs);
572
616
  }
573
617
  };
618
+ /**
619
+ * @param name The program name to display in help and version message
620
+ */
574
621
  const cac = (name = "") => new CAC(name);
575
622
 
576
623
  //#endregion
package/dist/index.d.ts CHANGED
@@ -3022,6 +3022,7 @@ interface EslintCommentsRuleOptions {
3022
3022
  /**
3023
3023
  * disallow unused `eslint-disable` comments
3024
3024
  * @see https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html
3025
+ * @deprecated
3025
3026
  */
3026
3027
  "eslint-comments/no-unused-disable"?: Linter.RuleEntry<[]>;
3027
3028
  /**
@@ -14700,7 +14701,7 @@ declare function defineConfig(options?: OptionsConfig & Config, ...userConfigs:
14700
14701
  type DefineConfig = typeof defineConfig;
14701
14702
  //#endregion
14702
14703
  //#region src/generated/version.d.ts
14703
- declare const VERSION = "0.5.2";
14704
+ declare const VERSION = "0.5.3";
14704
14705
  declare namespace globs_d_exports {
14705
14706
  export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_JS_SRC_EXT, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_TS_SRC_EXT, GLOB_YAML };
14706
14707
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./chunk-CdeBBKNj.js";
2
- import { n as DEBUG, r as SLOW_RULES, t as VERSION } from "./version-BMOOQznP.js";
2
+ import { n as DEBUG, r as SLOW_RULES, t as VERSION } from "./version-B7sAPTF4.js";
3
3
  import { builtinModules, createRequire } from "node:module";
4
4
  import process$1 from "node:process";
5
5
  import fs, { promises, realpathSync, statSync } from "node:fs";
@@ -13130,7 +13130,7 @@ const imports = async (options) => {
13130
13130
  };
13131
13131
 
13132
13132
  //#endregion
13133
- //#region node_modules/.pnpm/globals@17.3.0/node_modules/globals/globals.json
13133
+ //#region node_modules/.pnpm/globals@17.4.0/node_modules/globals/globals.json
13134
13134
  var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13135
13135
  module.exports = {
13136
13136
  "amd": {
@@ -13312,6 +13312,8 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13312
13312
  "CookieStore": false,
13313
13313
  "CookieStoreManager": false,
13314
13314
  "CountQueuingStrategy": false,
13315
+ "crashReport": false,
13316
+ "CrashReportContext": false,
13315
13317
  "createImageBitmap": false,
13316
13318
  "CreateMonitor": false,
13317
13319
  "Credential": false,
@@ -13900,6 +13902,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13900
13902
  "Option": false,
13901
13903
  "OrientationSensor": false,
13902
13904
  "origin": false,
13905
+ "Origin": false,
13903
13906
  "originAgentCluster": false,
13904
13907
  "OscillatorNode": false,
13905
13908
  "OTPCredential": false,
@@ -13939,6 +13942,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13939
13942
  "PerformanceScriptTiming": false,
13940
13943
  "PerformanceServerTiming": false,
13941
13944
  "PerformanceTiming": false,
13945
+ "PerformanceTimingConfidence": false,
13942
13946
  "PeriodicSyncManager": false,
13943
13947
  "PeriodicWave": false,
13944
13948
  "Permissions": false,
@@ -14688,6 +14692,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14688
14692
  "structuredClone": false,
14689
14693
  "SubtleCrypto": false,
14690
14694
  "SuppressedError": false,
14695
+ "Temporal": false,
14691
14696
  "TextDecoder": false,
14692
14697
  "TextDecoderStream": false,
14693
14698
  "TextEncoder": false,
@@ -16244,6 +16249,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16244
16249
  "onsync": true,
16245
16250
  "onunhandledrejection": true,
16246
16251
  "origin": false,
16252
+ "Origin": false,
16247
16253
  "Path2D": false,
16248
16254
  "PaymentRequestEvent": false,
16249
16255
  "performance": false,
@@ -16587,6 +16593,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16587
16593
  "onrejectionhandled": true,
16588
16594
  "onunhandledrejection": true,
16589
16595
  "origin": false,
16596
+ "Origin": false,
16590
16597
  "Path2D": false,
16591
16598
  "performance": false,
16592
16599
  "Performance": false,
@@ -16975,6 +16982,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16975
16982
  "onrtctransform": true,
16976
16983
  "onunhandledrejection": true,
16977
16984
  "origin": false,
16985
+ "Origin": false,
16978
16986
  "Path2D": false,
16979
16987
  "performance": false,
16980
16988
  "Performance": false,
@@ -17148,7 +17156,7 @@ var require_globals$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17148
17156
  }));
17149
17157
 
17150
17158
  //#endregion
17151
- //#region node_modules/.pnpm/globals@17.3.0/node_modules/globals/index.js
17159
+ //#region node_modules/.pnpm/globals@17.4.0/node_modules/globals/index.js
17152
17160
  var require_globals = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17153
17161
  module.exports = require_globals$1();
17154
17162
  }));
@@ -36,7 +36,7 @@ const SLOW_RULES = [
36
36
 
37
37
  //#endregion
38
38
  //#region src/generated/version.ts
39
- const VERSION = "0.5.2";
39
+ const VERSION = "0.5.3";
40
40
 
41
41
  //#endregion
42
42
  export { DEBUG as n, SLOW_RULES as r, VERSION as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jsse/eslint-config",
3
3
  "type": "module",
4
- "version": "0.5.2",
4
+ "version": "0.5.3",
5
5
  "description": "@jsse/eslint-config ~ WYSIWYG",
6
6
  "author": "jessekrubin <jessekrubin@gmail.com> (https://github.com/jessekrubin/)",
7
7
  "license": "MIT",
@@ -60,20 +60,21 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
63
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
64
64
  "@eslint/compat": "^2.0.2",
65
65
  "@eslint/js": "^9.39.2",
66
66
  "@eslint/markdown": "^7.5.1",
67
67
  "@stylistic/eslint-plugin": "5.9.0",
68
68
  "@typescript-eslint/eslint-plugin": "^8.55.0",
69
69
  "@typescript-eslint/parser": "^8.55.0",
70
+ "@typescript-eslint/rule-tester": "^8.56.1",
70
71
  "@vitest/eslint-plugin": "^1.6.7",
71
72
  "debug": "^4.4.3",
72
73
  "eslint-config-flat-gitignore": "^2.1.0",
73
74
  "eslint-merge-processors": "^2.0.0",
74
75
  "eslint-plugin-antfu": "^3.2.0",
75
76
  "eslint-plugin-command": "^3.4.0",
76
- "eslint-plugin-de-morgan": "^2.0.0",
77
+ "eslint-plugin-de-morgan": "^2.1.1",
77
78
  "eslint-plugin-import-lite": "^0.5.0",
78
79
  "eslint-plugin-jsdoc": "^62.5.4",
79
80
  "eslint-plugin-jsonc": "^3.1.1",
@@ -84,34 +85,35 @@
84
85
  "eslint-plugin-react": "^7.37.5",
85
86
  "eslint-plugin-react-hooks": "^7.0.1",
86
87
  "eslint-plugin-react-refresh": "^0.5.0",
87
- "eslint-plugin-toml": "^1.0.4",
88
+ "eslint-plugin-toml": "^1.3.1",
88
89
  "eslint-plugin-tsdoc": "^0.5.0",
89
90
  "eslint-plugin-unicorn": "^63.0.0",
90
91
  "eslint-plugin-unused-imports": "^4.4.1",
91
- "eslint-plugin-yml": "^3.1.2",
92
+ "eslint-plugin-yml": "^3.3.1",
92
93
  "jsonc-eslint-parser": "^3.1.0",
93
94
  "toml-eslint-parser": "^1.0.3",
94
95
  "typescript-eslint": "^8.55.0",
95
96
  "yaml-eslint-parser": "^2.0.0"
96
97
  },
97
98
  "devDependencies": {
98
- "@changesets/cli": "^2.29.8",
99
+ "@changesets/cli": "^2.30.0",
99
100
  "@jsse/prettier-config": "^1.0.2",
100
101
  "@jsse/tsconfig": "^0.4.0",
101
102
  "@types/debug": "^4.1.12",
102
103
  "@types/fs-extra": "^11.0.4",
103
- "@types/node": "^25.2.3",
104
- "cac": "^6.7.14",
104
+ "@types/node": "^25.3.3",
105
+ "cac": "^7.0.0",
105
106
  "eslint": "^9.39.2",
106
107
  "eslint-flat-config-utils": "^3.0.1",
107
108
  "eslint-typegen": "^2.3.0",
108
109
  "execa": "~9.6.1",
109
110
  "fast-equals": "^6.0.0",
110
111
  "fast-glob": "^3.3.3",
111
- "fs-extra": "^11.3.3",
112
- "globals": "^17.3.0",
112
+ "fs-extra": "^11.3.4",
113
+ "globals": "^17.4.0",
113
114
  "local-pkg": "^1.1.2",
114
- "oxlint": "^1.46.0",
115
+ "oxfmt": "^0.36.0",
116
+ "oxlint": "^1.51.0",
115
117
  "picocolors": "^1.1.1",
116
118
  "prettier": "^3.8.1",
117
119
  "react": "~19.2.4",