diff --git a/src/cli-util.js b/src/cli-util.js index e46643dd0..10ac1e195 100644 --- a/src/cli-util.js +++ b/src/cli-util.js @@ -36,12 +36,6 @@ function getOptions(argv) { } function getParserOption(argv) { - const value = argv.parser; - - if (value === undefined) { - return value; - } - // For backward compatibility. Deprecated in 0.0.10 /* istanbul ignore if */ if (argv["flow-parser"]) { @@ -49,17 +43,14 @@ function getParserOption(argv) { return "flow"; } - return value; + return argv["parser"]; } function getIntOption(argv, optionName) { const value = argv[optionName]; - if (value === undefined) { - return value; - } - validator.validateIntOption(value, constant.options[optionName], { + // cursorOffset defaults to -1 and rangeEnd defaults to Infinity, which is not considered an integer. exceptions: [apiDefaultOptions[kebabToCamel(optionName)]] }); @@ -76,10 +67,12 @@ function getTrailingComma(argv) { 'Specify "none", "es5", or "all".' ); return "es5"; - case undefined: - return value; default: - validator.validateChoiceOption(value, constant.options["trailing-comma"]); + validator.validateChoiceOption( + value, + constant.options["trailing-comma"], + { exceptions: [undefined] } + ); return value; } } diff --git a/src/cli-validator.js b/src/cli-validator.js index 186b2a216..c5f8c23c2 100644 --- a/src/cli-validator.js +++ b/src/cli-validator.js @@ -24,7 +24,7 @@ function validateIntOption(value, option, opts) { } } -function validateChoiceOption(value, option, opts) { +function validateChoiceOption(value, option) { if (option.choices.indexOf(value) === -1) { throw new Error( `Invalid option for --${option.name}.\nExpected ${getJoinedChoices()}, but received: "${value}"` @@ -33,9 +33,6 @@ function validateChoiceOption(value, option, opts) { function getJoinedChoices() { const choices = option.choices.map(choice => `"${choice}"`); - if (choices.length === 1) { - return choices[0]; - } const head = choices.slice(0, -2); const tail = choices.slice(-2); return head.concat(tail.join(" or ")).join(", ");