chris48s / v8r

✔️ A command-line JSON, YAML and TOML validator that's on your wavelength
https://chris48s.github.io/v8r/
MIT License
28 stars 5 forks source link

Change the name of `registerDocumentFormats` #488

Closed chris48s closed 3 weeks ago

chris48s commented 1 month ago

Today in "naming things is hard"..

The term "format" is too overloaded, particularly given you refer to the output formats as just --format.

Maybe change this to either registerDocumentParsers or registerDocumentFormatParsers

Compare

/**
 * Use the `registerDocumentFormats` hook to tell v8r about additional
 * document formats that can be parsed. Any formats registered with this hook
 * become valid values for the `parser` property in custom schemas.
 *
 * @returns {string[]}
 */
registerDocumentFormats() {
  return [];
}

to

/**
 * Use the `registerDocumentParsers` hook to tell v8r about additional
 * document formats that can be parsed. Any parsers registered with this hook
 * become valid values for the `parser` property in custom schemas.
 *
 * @returns {string[]}
 */
registerDocumentParsers() {
  return [];
}

I feel like the second is clearer.

chris48s commented 1 month ago

I reckon also change the name of the 3rd argument to parseDocument() from format to parser and update the docs accordingly

chris48s commented 1 month ago

Hmm, but does parser imply it is the parser function itself. At least with format it is more clear this is a string like "toml" or "json".

You could always consider a breaking change to the config file/command line args to clean up the terminology there a bit.

Decisions decisions.

chris48s commented 3 weeks ago

I ended up going with

see https://github.com/chris48s/v8r/pull/487#discussion_r1713443398