Skip to content

Specifying a flag twice throws an error #5369

@hawkrives

Description

@hawkrives

Environments:

  • Prettier Version: 1.15.1
  • Running Prettier via: CLI
  • Runtime: node 11.1.0
  • Operating System: macOS 10.14

Steps to reproduce:

$ echo '{"name": "a-package"}' > ./package.json
$ prettier --tab-width 2 --use-tabs --tab-width 4 ./package.json

Expected behavior:

$ prettier --tab-width 2 --use-tabs --tab-width 4 ./package.json
{
	"name": "a-package"
}

Actual behavior:

$ prettier --tab-width 2 --use-tabs --tab-width 4 package.json
[error] Invalid --tab-width value. Expected an integer, but received null.

I happen to find myself in a situation where I need to override a CLI flag with another one, which appended to the invocation later. I cannot just remove the first flag, unfortunately.

What I would expect would be for Prettier to use the last value given for a flag, instead of trying to combine them into an array? (At least, I think that's what minimist is doing; I'm not sure where the error about "null" is coming from.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliIssues with Prettier's Command Line Interfacelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions