Skip to content

Validate babel-cli program options #4825

@gajus

Description

@gajus

It is frustrating that babel-cli program does not validate options that are passed to it, e.g.

babel ./src --out-dir ./dist --copy-files --spurce-maps

This will run the program without any error (note the spelling error in --spurce-maps; the intetended value is --source-maps).

Ideally, a CLI program should throw an error whenever an unknown property/ value is passed to it.

As far as I can tell, https://github.com/tj/commander.js does not support "strict" options parameter (like yargs#strict). Therefore, this could be achieved by:

  • switching the implementation to yargs; or
  • implementing JSON schema validation of the options object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: cli

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions