@villedemontreal/caporal 3.1.10 → 4.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.
Files changed (100) hide show
  1. package/dist/src/autocomplete/index.js +3 -3
  2. package/dist/src/autocomplete/index.js.map +1 -1
  3. package/dist/src/command/__tests__/command.spec.js +1 -0
  4. package/dist/src/command/__tests__/command.spec.js.map +1 -1
  5. package/dist/src/command/find.js +1 -1
  6. package/dist/src/command/find.js.map +1 -1
  7. package/dist/src/command/index.d.ts.map +1 -1
  8. package/dist/src/command/index.js +4 -7
  9. package/dist/src/command/index.js.map +1 -1
  10. package/dist/src/error/fatal.js +1 -1
  11. package/dist/src/error/fatal.js.map +1 -1
  12. package/dist/src/error/multi-validation.d.ts.map +1 -1
  13. package/dist/src/error/multi-validation.js +3 -5
  14. package/dist/src/error/multi-validation.js.map +1 -1
  15. package/dist/src/error/unknown-command.d.ts.map +1 -1
  16. package/dist/src/error/unknown-command.js +7 -8
  17. package/dist/src/error/unknown-command.js.map +1 -1
  18. package/dist/src/error/unknown-option.d.ts.map +1 -1
  19. package/dist/src/error/unknown-option.js +3 -6
  20. package/dist/src/error/unknown-option.js.map +1 -1
  21. package/dist/src/error/validation.js +2 -2
  22. package/dist/src/error/validation.js.map +1 -1
  23. package/dist/src/help/index.js +1 -1
  24. package/dist/src/help/index.js.map +1 -1
  25. package/dist/src/help/templates/command.js +4 -0
  26. package/dist/src/help/templates/command.js.map +1 -1
  27. package/dist/src/help/templates/header.d.ts.map +1 -1
  28. package/dist/src/help/templates/header.js +1 -7
  29. package/dist/src/help/templates/header.js.map +1 -1
  30. package/dist/src/help/templates/usage.js +1 -1
  31. package/dist/src/help/templates/usage.js.map +1 -1
  32. package/dist/src/help/utils.d.ts.map +1 -1
  33. package/dist/src/help/utils.js +2 -2
  34. package/dist/src/help/utils.js.map +1 -1
  35. package/dist/src/logger/__tests__/logger.spec.js +0 -1
  36. package/dist/src/logger/__tests__/logger.spec.js.map +1 -1
  37. package/dist/src/logger/index.d.ts.map +1 -1
  38. package/dist/src/logger/index.js +2 -1
  39. package/dist/src/logger/index.js.map +1 -1
  40. package/dist/src/option/__tests__/global.spec.js +0 -1
  41. package/dist/src/option/__tests__/global.spec.js.map +1 -1
  42. package/dist/src/option/index.d.ts.map +1 -1
  43. package/dist/src/option/index.js +0 -2
  44. package/dist/src/option/index.js.map +1 -1
  45. package/dist/src/option/utils.js.map +1 -1
  46. package/dist/src/parser/index.js +2 -2
  47. package/dist/src/parser/index.js.map +1 -1
  48. package/dist/src/program/__tests__/program.spec.js +1 -1
  49. package/dist/src/program/__tests__/program.spec.js.map +1 -1
  50. package/dist/src/program/index.d.ts.map +1 -1
  51. package/dist/src/program/index.js +2 -7
  52. package/dist/src/program/index.js.map +1 -1
  53. package/dist/src/utils/__tests__/suggest.spec.js +4 -4
  54. package/dist/src/utils/__tests__/suggest.spec.js.map +1 -1
  55. package/dist/src/utils/version.js +2 -2
  56. package/dist/src/utils/version.js.map +1 -1
  57. package/dist/src/utils/web/autocomplete.d.ts.map +1 -1
  58. package/dist/src/utils/web/autocomplete.js +0 -2
  59. package/dist/src/utils/web/autocomplete.js.map +1 -1
  60. package/dist/src/utils/web/process.d.ts.map +1 -1
  61. package/dist/src/utils/web/process.js +2 -5
  62. package/dist/src/utils/web/process.js.map +1 -1
  63. package/dist/src/validator/caporal.js +2 -2
  64. package/dist/src/validator/caporal.js.map +1 -1
  65. package/dist/src/validator/regexp.js +1 -1
  66. package/dist/src/validator/regexp.js.map +1 -1
  67. package/dist/src/validator/utils.d.ts.map +1 -1
  68. package/dist/src/validator/utils.js +2 -1
  69. package/dist/src/validator/utils.js.map +1 -1
  70. package/dist/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +17 -13
  72. package/src/autocomplete/index.ts +3 -3
  73. package/src/command/__tests__/command.spec.ts +1 -0
  74. package/src/command/find.ts +1 -1
  75. package/src/command/index.ts +4 -9
  76. package/src/error/fatal.ts +1 -1
  77. package/src/error/multi-validation.ts +3 -6
  78. package/src/error/unknown-command.ts +7 -8
  79. package/src/error/unknown-option.ts +3 -6
  80. package/src/error/validation.ts +2 -2
  81. package/src/help/index.ts +1 -1
  82. package/src/help/templates/command.ts +4 -4
  83. package/src/help/templates/header.ts +3 -9
  84. package/src/help/templates/usage.ts +1 -1
  85. package/src/help/utils.ts +2 -3
  86. package/src/logger/__tests__/logger.spec.ts +0 -1
  87. package/src/logger/index.ts +2 -1
  88. package/src/option/__tests__/global.spec.ts +0 -1
  89. package/src/option/index.ts +1 -2
  90. package/src/option/utils.ts +2 -2
  91. package/src/parser/index.ts +2 -2
  92. package/src/program/__tests__/program.spec.ts +1 -1
  93. package/src/program/index.ts +6 -9
  94. package/src/utils/__tests__/suggest.spec.ts +4 -4
  95. package/src/utils/version.ts +2 -2
  96. package/src/utils/web/autocomplete.ts +1 -2
  97. package/src/utils/web/process.ts +1 -3
  98. package/src/validator/caporal.ts +2 -2
  99. package/src/validator/regexp.ts +1 -1
  100. package/src/validator/utils.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@villedemontreal/caporal",
3
- "version": "3.1.10",
3
+ "version": "4.0.0",
4
4
  "description": "A full-featured framework for building command line applications (cli) with node.js",
5
5
  "main": "./dist/src/index.js",
6
6
  "typings": "dist/src",
@@ -13,8 +13,8 @@
13
13
  "test": "vitest run src",
14
14
  "compile": "tsc --build",
15
15
  "show-tsconfig": "tsc --showConfig",
16
- "lint": "eslint -c .eslintrc.js --ext .ts src",
17
- "lint-fix": "eslint -c .eslintrc.js --fix --ext .ts src",
16
+ "lint": "eslint",
17
+ "lint-fix": "eslint --fix",
18
18
  "ncu": "ncu --target minor -x @types/node",
19
19
  "ncu-fix": "ncu -u --target minor -x @types/node"
20
20
  },
@@ -46,28 +46,32 @@
46
46
  },
47
47
  "license": "MIT",
48
48
  "devDependencies": {
49
+ "@eslint/eslintrc": "3.3.3",
50
+ "@eslint/js": "9.39.2",
49
51
  "@tsconfig/node22": "22.0.5",
50
52
  "@types/lodash": "^4.17.21",
51
- "@types/node": "20.5.6",
53
+ "@types/node": "25.0.3",
52
54
  "@types/tabtab": "^3.0.4",
53
- "@typescript-eslint/eslint-plugin": "5.62.0",
54
- "@typescript-eslint/parser": "5.62.0",
55
- "eslint": "8.57.1",
56
- "eslint-config-prettier": "8.10.2",
55
+ "@typescript-eslint/eslint-plugin": "8.50.1",
56
+ "@typescript-eslint/parser": "8.50.1",
57
+ "@typescript-eslint/utils": "^8.50.1",
58
+ "eslint": "9.39.2",
59
+ "eslint-config-prettier": "10.1.8",
57
60
  "eslint-plugin-prettier": "5.5.4",
61
+ "globals": "16.5.0",
58
62
  "json": "^11.0.0",
59
- "prettier": "3.7.3",
63
+ "prettier": "3.7.4",
60
64
  "strip-ansi": "^7.1.2",
61
65
  "typescript": "5.9.3",
62
- "vitest": "^3.2.4"
66
+ "vitest": "^4.0.16"
63
67
  },
64
68
  "dependencies": {
65
- "chalk": "4.1.2",
66
- "glob": "^11.1.0",
69
+ "chalk": "5.6.2",
70
+ "glob": "^13.0.0",
67
71
  "lodash": "^4.17.21",
68
72
  "lodash.truncate": "^4.4.2",
69
73
  "table": "^6.9.0",
70
74
  "tabtab": "^3.0.2",
71
- "winston": "^3.18.3"
75
+ "winston": "^3.19.0"
72
76
  }
73
77
  }
@@ -147,7 +147,7 @@ async function getCompOptValues(ctx: CompletionContext): Promise<CompletionItem[
147
147
  if (currentOpt.choices.length) {
148
148
  return currentOpt.choices.map((choice) => ({
149
149
  name: choice.toString(),
150
- description: "Value for option " + currentOpt.synopsis,
150
+ description: `Value for option ${currentOpt.synopsis}`,
151
151
  }))
152
152
  }
153
153
 
@@ -188,7 +188,7 @@ async function getCompArgValues(ctx: CompletionContext): Promise<CompletionItem[
188
188
  return arg.choices
189
189
  .map((choice) => ({
190
190
  name: choice.toString(),
191
- description: "Value for argument " + arg.synopsis,
191
+ description: `Value for argument ${arg.synopsis}`,
192
192
  }))
193
193
  .filter((choice) => !lastPartial || choice.name.toString().startsWith(lastPartial))
194
194
  }
@@ -214,7 +214,7 @@ async function hanldleCompleter(
214
214
  return item
215
215
  }
216
216
  return {
217
- name: "" + item,
217
+ name: `${item}`,
218
218
  description: `Value for ${type} ${argOrOpt.synopsis}`,
219
219
  }
220
220
  })
@@ -169,6 +169,7 @@ describe("Command", () => {
169
169
 
170
170
  it(".run() should throw an ActionError when action throws a message", async () => {
171
171
  const action = vi.fn(() => {
172
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
172
173
  throw "User Error"
173
174
  })
174
175
  const cmd = prog.command("order", "Order something").action(action)
@@ -52,6 +52,6 @@ async function discoverCommand(
52
52
  }
53
53
  return cmdBuilder(options)
54
54
  // eslint-disable-next-line no-empty
55
- } catch (e) {}
55
+ } catch {}
56
56
  return undefined
57
57
  }
@@ -267,16 +267,11 @@ export class Command {
267
267
  ? "<OPTIONS...>"
268
268
  : "[OPTIONS...]"
269
269
  : ""
270
- const name = this._name !== PROG_CMD ? " " + this._name : ""
270
+ const name = this._name !== PROG_CMD ? ` ${this._name}` : ""
271
271
 
272
- return (
273
- this.program.getBin() +
274
- name +
275
- " " +
276
- this.args.map((a) => a.synopsis).join(" ") +
277
- " " +
278
- opts
279
- ).trim()
272
+ return `${this.program.getBin() + name} ${this.args
273
+ .map((a) => a.synopsis)
274
+ .join(" ")} ${opts}`.trim()
280
275
  }
281
276
 
282
277
  /**
@@ -14,7 +14,7 @@ export function fatalError(error: BaseError): void {
14
14
  logger.log({
15
15
  level: "error",
16
16
  ...error,
17
- message: error.message + "\n\n" + error.stack,
17
+ message: `${error.message}\n\n${error.stack}`,
18
18
  stack: error.stack,
19
19
  name: error.name,
20
20
  })
@@ -11,12 +11,9 @@ import type { Command } from "../command"
11
11
  export class ValidationSummaryError extends BaseError {
12
12
  constructor(cmd: Command, errors: CommonError[]) {
13
13
  const plural = errors.length > 1 ? "s" : ""
14
- const msg =
15
- `The following error${plural} occured:\n` +
16
- errors.map((e) => "- " + e.message.replace(/\n/g, "\n ")).join("\n") +
17
- "\n\n" +
18
- chalk.dim("Synopsis: ") +
19
- colorize(cmd.synopsis)
14
+ const msg = `The following error${plural} occured:\n${errors
15
+ .map((e) => `- ${e.message.replace(/\n/g, "\n ")}`)
16
+ .join("\n")}\n\n${chalk.dim("Synopsis: ")}${colorize(cmd.synopsis)}`
20
17
  super(msg, { errors })
21
18
  }
22
19
  }
@@ -23,17 +23,16 @@ export class UnknownOrUnspecifiedCommandError extends BaseError {
23
23
  msg = `Unknown command ${chalk.bold(command)}.`
24
24
  const suggestions = getSuggestions(command, possibilities)
25
25
  if (suggestions.length) {
26
- msg +=
27
- " Did you mean " +
28
- suggestions.map((s) => boldDiffString(command, s)).join(" or maybe ") +
29
- " ?"
26
+ msg += ` Did you mean ${suggestions
27
+ .map((s) => boldDiffString(command, s))
28
+ .join(" or maybe ")} ?`
30
29
  }
31
30
  } else {
32
31
  msg =
33
- "Unspecified command. Available commands are:\n" +
34
- possibilities.map((p) => chalk.whiteBright(p)).join(", ") +
35
- "." +
36
- `\n\nFor more help, type ${chalk.whiteBright(program.getBin() + " --help")}`
32
+ `Unspecified command. Available commands are:\n${possibilities
33
+ .map((p) => chalk.whiteBright(p))
34
+ .join(", ")}.` +
35
+ `\n\nFor more help, type ${chalk.whiteBright(`${program.getBin()} --help`)}`
37
36
  }
38
37
 
39
38
  super(msg, { command })
@@ -28,12 +28,9 @@ export class UnknownOptionError extends BaseError {
28
28
 
29
29
  let msg = `Unknown option ${c.bold.redBright(getDashedOpt(flag))}. `
30
30
  if (suggestions.length) {
31
- msg +=
32
- "Did you mean " +
33
- suggestions
34
- .map((s) => boldDiffString(getDashedOpt(flag), getDashedOpt(s)))
35
- .join(" or maybe ") +
36
- " ?"
31
+ msg += `Did you mean ${suggestions
32
+ .map((s) => boldDiffString(getDashedOpt(flag), getDashedOpt(s)))
33
+ .join(" or maybe ")} ?`
37
34
  }
38
35
  super(msg, { flag, command })
39
36
  }
@@ -63,7 +63,7 @@ export class ValidationError extends BaseError {
63
63
  'Invalid value for %s %s.\nExpected one of %s, but got "%s".',
64
64
  varName,
65
65
  c.redBright(name),
66
- "'" + validator.join("', '") + "'",
66
+ `'${validator.join("', '")}'`,
67
67
  c.redBright(value),
68
68
  )
69
69
  } else if (validator instanceof RegExp) {
@@ -75,6 +75,6 @@ export class ValidationError extends BaseError {
75
75
  c.redBright(value),
76
76
  )
77
77
  }
78
- super(message + "")
78
+ super(`${message}`)
79
79
  }
80
80
  }
package/src/help/index.ts CHANGED
@@ -85,7 +85,7 @@ export function getContext(program: Program, command?: Command): TemplateContext
85
85
  table: buildTable,
86
86
  spaces,
87
87
  indent(str: string, sp = spaces) {
88
- return sp + replace(str.trim(), /(\r\n|\r|\n)/g, "\n" + sp)
88
+ return sp + replace(str.trim(), /(\r\n|\r|\n)/g, `\n${sp}`)
89
89
  },
90
90
  eol: "\n",
91
91
  eol2: "\n\n",
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * @internal
4
4
  */
5
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
5
+
6
6
  import type { TemplateContext, Template } from "../types"
7
7
  import { getOptionsTable, getArgumentsTable } from "../utils"
8
8
  import sortBy from "lodash/sortBy"
@@ -10,14 +10,14 @@ import sortBy from "lodash/sortBy"
10
10
  export const command: Template = async (ctx: TemplateContext) => {
11
11
  const { cmd, globalOptions: globalFlags, eol, eol3, colorize, tpl } = ctx
12
12
 
13
- const options = sortBy(cmd!.options, "name"),
13
+ const options = sortBy(cmd.options, "name"),
14
14
  globalOptions = Array.from(globalFlags.keys())
15
15
 
16
16
  const help =
17
- cmd!.synopsis +
17
+ cmd.synopsis +
18
18
  eol3 +
19
19
  (await tpl("custom", ctx)) +
20
- getArgumentsTable(cmd!.args, ctx) +
20
+ getArgumentsTable(cmd.args, ctx) +
21
21
  eol +
22
22
  getOptionsTable(options, ctx) +
23
23
  eol +
@@ -7,13 +7,7 @@ import type { TemplateContext, Template } from "../types"
7
7
  export const header: Template = (ctx: TemplateContext) => {
8
8
  const { prog, chalk: c, spaces, eol, eol2 } = ctx
9
9
  const version = process.env?.NODE_ENV === "test" ? "" : prog.getVersion()
10
- return (
11
- eol +
12
- spaces +
13
- (prog.getName() || prog.getBin()) +
14
- " " +
15
- (version || "") +
16
- (prog.getDescription() ? " \u2014 " + c.dim(prog.getDescription()) : "") +
17
- eol2
18
- )
10
+ return `${eol + spaces + (prog.getName() || prog.getBin())} ${version || ""}${
11
+ prog.getDescription() ? ` \u2014 ${c.dim(prog.getDescription())}` : ""
12
+ }${eol2}`
19
13
  }
@@ -15,7 +15,7 @@ export const usage: Template = async (ctx: TemplateContext) => {
15
15
  }
16
16
 
17
17
  // usage
18
- const usage = `${spaces + c.bold("USAGE")} ${cmd?.name ? "— " + c.dim(cmd.name) : ""}
18
+ const usage = `${spaces + c.bold("USAGE")} ${cmd?.name ? `— ${c.dim(cmd.name)}` : ""}
19
19
  ${eol + spaces + spaces + c.dim("\u25B8")} `
20
20
 
21
21
  const next = cmd ? await tpl("command", ctx) : await tpl("program", ctx)
package/src/help/utils.ts CHANGED
@@ -36,7 +36,7 @@ export function buildTable(data: string[][], options = {}): string {
36
36
  export function getDefaultValueHint(obj: Argument | Option): string | undefined {
37
37
  return obj.default !== undefined &&
38
38
  !("boolean" in obj && obj.boolean && obj.default === false)
39
- ? "default: " + JSON.stringify(obj.default)
39
+ ? `default: ${JSON.stringify(obj.default)}`
40
40
  : undefined
41
41
  }
42
42
 
@@ -97,8 +97,7 @@ export function getCommandsTable(
97
97
  ): string {
98
98
  const { chalk, prog, eol2, table, spaces } = ctx
99
99
  const cmdHint = `Type '${prog.getBin()} help <command>' to get some help about a command`
100
- const help =
101
- spaces + chalk.bold(title) + ` ${chalk.dim("\u2014")} ` + chalk.dim(cmdHint) + eol2
100
+ const help = `${spaces + chalk.bold(title)} ${chalk.dim("\u2014")} ${chalk.dim(cmdHint)}${eol2}`
102
101
  const rows = commands
103
102
  .filter((c) => c.visible)
104
103
  .map((cmd) => {
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-console */
2
1
  import { program } from "../../index"
3
2
  import { Program } from "../../program"
4
3
  import { logger } from ".."
@@ -11,7 +11,8 @@ import { EOL } from "os"
11
11
 
12
12
  const caporalFormat = format.printf((data) => {
13
13
  const { level, ...meta } = data
14
- let { message } = data
14
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
15
+ let message = data.message?.toString() ?? ""
15
16
  let prefix = ""
16
17
 
17
18
  const levelStr = getLevelString(level)
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-console */
2
1
  import { program } from "../../index"
3
2
  import { Program } from "../../program"
4
3
  import { logger } from "../../logger"
@@ -73,7 +73,7 @@ export { showHelp }
73
73
  */
74
74
  const showHelp: Action = async ({ program, command }: ActionParameters) => {
75
75
  const help = await getHelp(program, command)
76
- // eslint-disable-next-line no-console
76
+
77
77
  console.log(help)
78
78
  program.emit("help", help)
79
79
  return false
@@ -84,7 +84,6 @@ const showHelp: Action = async ({ program, command }: ActionParameters) => {
84
84
  * @internal
85
85
  */
86
86
  showVersion: Action = ({ program }: ActionParameters) => {
87
- // eslint-disable-next-line no-console
88
87
  console.log(program.getVersion())
89
88
  program.emit("version", program.getVersion())
90
89
  return false
@@ -132,8 +132,8 @@ export function parseOptionSynopsis(synopsis: string): OptionSynopsis {
132
132
  throw new OptionSynopsisSyntaxError(synopsis)
133
133
  }
134
134
 
135
- infos.name = infos.longName || (infos.shortName as string)
136
- infos.notation = infos.longNotation || (infos.shortNotation as string)
135
+ infos.name = infos.longName || infos.shortName
136
+ infos.notation = infos.longNotation || infos.shortNotation
137
137
 
138
138
  const fullSynopsis = { ...infos } as OptionSynopsis
139
139
 
@@ -34,7 +34,7 @@ function castAsBool(value: string | boolean): boolean {
34
34
  }
35
35
 
36
36
  function castAsString(val: string | boolean): string {
37
- return val + ""
37
+ return `${val}`
38
38
  }
39
39
 
40
40
  function autoCast(val: string): ParserTypes {
@@ -330,7 +330,7 @@ class OptionParser {
330
330
  multi.forEach((o, index) => {
331
331
  const alias = this.config.alias[o]
332
332
  this.options[o] = index + 1 === n ? cast(o, val as string, this.config) : true
333
- this.rawOptions["-" + o] = this.options[o]
333
+ this.rawOptions[`-${o}`] = this.options[o]
334
334
  if (alias) {
335
335
  this.options[alias] = this.options[o]
336
336
  }
@@ -134,7 +134,7 @@ describe("Program", () => {
134
134
  })
135
135
 
136
136
  it("should be able to call discovered commands", async () => {
137
- prog.discover(__dirname + "/../../command/__fixtures__")
137
+ prog.discover(`${__dirname}/../../command/__fixtures__`)
138
138
  await expect(prog.run(["example-cmd"])).resolves.toBe("hey")
139
139
  })
140
140
 
@@ -148,7 +148,7 @@ export class Program extends EventEmitter {
148
148
  const command = args.command
149
149
  ? await findCommand(this, [args.command as string])
150
150
  : undefined
151
- // eslint-disable-next-line no-console
151
+
152
152
  showHelp({ ...actionParams, command })
153
153
  return -1
154
154
  })
@@ -207,12 +207,9 @@ export class Program extends EventEmitter {
207
207
  * @internal
208
208
  */
209
209
  async getSynopsis(): Promise<string> {
210
- return (
211
- this.getBin() +
212
- " " +
213
- ((await this.hasCommands()) ? "<command> " : "") +
214
- "[ARGUMENTS...] [OPTIONS...]"
215
- ).trim()
210
+ return `${this.getBin()} ${
211
+ (await this.hasCommands()) ? "<command> " : ""
212
+ }[ARGUMENTS...] [OPTIONS...]`.trim()
216
213
  }
217
214
 
218
215
  /**
@@ -487,7 +484,7 @@ export class Program extends EventEmitter {
487
484
  try {
488
485
  stat = fs.statSync(dirPath)
489
486
  // eslint-disable-next-line no-empty
490
- } catch (e) {}
487
+ } catch {}
491
488
  if (!stat || !stat.isDirectory()) {
492
489
  throw new Error(
493
490
  "Caporal setup error: parameter `dirPath` of discover() should be a directory",
@@ -576,7 +573,7 @@ export class Program extends EventEmitter {
576
573
  We are forced to catch a potential error to prevent the rejected
577
574
  promise to propagate un in the stack.
578
575
  */
579
- // eslint-disable-next-line @typescript-eslint/no-empty-function
576
+
580
577
  return this._run(result, cmd) /*
581
578
  .catch((e) => e) */
582
579
  }
@@ -11,19 +11,19 @@ describe("Suggest", () => {
11
11
  })
12
12
  describe("boldDiffString()", () => {
13
13
  it("should make the diff bold at the end of the word", () => {
14
- expect(boldDiffString("foo", "foob")).toEqual("foo" + c.bold.greenBright("b"))
14
+ expect(boldDiffString("foo", "foob")).toEqual(`foo${c.bold.greenBright("b")}`)
15
15
  })
16
16
  it("should make the diff bold at the beginning of the word", () => {
17
- expect(boldDiffString("foo", "doo")).toBe(c.bold.greenBright("d") + "oo")
17
+ expect(boldDiffString("foo", "doo")).toBe(`${c.bold.greenBright("d")}oo`)
18
18
  })
19
19
 
20
20
  it("should make the diff bold at the middle of the word", () => {
21
- expect(boldDiffString("foo", "fao")).toBe("f" + c.bold.greenBright("a") + "o")
21
+ expect(boldDiffString("foo", "fao")).toBe(`f${c.bold.greenBright("a")}o`)
22
22
  })
23
23
 
24
24
  it("should make the diff bold anywhere in the word", () => {
25
25
  expect(boldDiffString("minimum", "maximum")).toBe(
26
- "m" + c.bold.greenBright("a") + c.bold.greenBright("x") + "imum",
26
+ `m${c.bold.greenBright("a")}${c.bold.greenBright("x")}imum`,
27
27
  )
28
28
  })
29
29
  })
@@ -6,9 +6,9 @@ import path from "path"
6
6
 
7
7
  export function detectVersion(): string | undefined {
8
8
  try {
9
- // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
10
  return require(path.join(__filename, "..", "..", "..", "package.json")).version
11
11
  // eslint-disable-next-line no-empty
12
- } catch (e) {}
12
+ } catch {}
13
13
  return undefined
14
14
  }
@@ -6,8 +6,7 @@
6
6
  */
7
7
  import type { Program } from "../../program"
8
8
  import type { Argument, Option } from "../../types"
9
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
10
- /* eslint-disable @typescript-eslint/no-empty-function */
9
+
11
10
  /* eslint-disable @typescript-eslint/no-unused-vars */
12
11
  export function registerCompletion(
13
12
  argOrOpt: Argument | Option,
@@ -4,9 +4,7 @@
4
4
  * @packageDocumentation
5
5
  * @internal
6
6
  */
7
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
8
- /* eslint-disable @typescript-eslint/no-empty-function */
9
- /* eslint-disable no-console */
7
+
10
8
  export const version = process.version
11
9
  export const argv = ["node", "play.ts"]
12
10
  export const execArgv = [] as any[]
@@ -72,7 +72,7 @@ export function validateNumericFlag(
72
72
  value: ParserTypes,
73
73
  context: Argument | Option,
74
74
  ): number {
75
- const str = value + ""
75
+ const str = `${value}`
76
76
  if (Array.isArray(value) || !isNumeric(str)) {
77
77
  throw new ValidationError({
78
78
  value,
@@ -100,5 +100,5 @@ export function validateArrayFlag(
100
100
  * @ignore
101
101
  */
102
102
  export function validateStringFlag(value: ParserTypes | ParserTypes[]): string {
103
- return value + ""
103
+ return `${value}`
104
104
  }
@@ -23,7 +23,7 @@ export function validateWithRegExp(
23
23
  return validateWithRegExp(validator, v, context) as ParserTypes
24
24
  })
25
25
  }
26
- if (!validator.test(value + "")) {
26
+ if (!validator.test(`${value}`)) {
27
27
  throw new ValidationError({
28
28
  validator: validator,
29
29
  value,
@@ -15,6 +15,7 @@ export function isCaporalValidator(
15
15
  return false
16
16
  }
17
17
  const mask = getCaporalValidatorsMask()
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
18
19
  const exist = (mask & validator) === validator
19
20
  return exist
20
21
  }
@@ -77,7 +78,7 @@ export function getTypeHint(obj: Argument | Option): string | undefined {
77
78
  } else if (Array.isArray(obj.validator)) {
78
79
  const stringified = JSON.stringify(obj.validator)
79
80
  if (stringified.length < 300) {
80
- hint = "one of " + stringified.substr(1, stringified.length - 2)
81
+ hint = `one of ${stringified.substr(1, stringified.length - 2)}`
81
82
  }
82
83
  }
83
84
  return hint