Skip to content

Unexpected --cache Behavior with --list-different #13015

@rwaskiewicz

Description

@rwaskiewicz

Environments:

  • Prettier Version: 2.7.1
  • Running Prettier via: npx commands
  • Runtime: Node v16.14.0, npm v8.3.1
  • Operating System: macOS
  • Prettier plugins (if any): none
    Steps to reproduce:

Minimal Reproduction: https://github.com/rwaskiewicz/prettier-caching
Steps to Reproduce can be found in the README at the root of the repository

Expected behavior:

Running the following commands in sequence:

npx prettier . --list-different --cache
npx prettier . --write --cache

should format a project's code.

Actual behavior:

Calling npx prettier . --list-different --cache writes a cache. Calling npx prettier . --write --cache afterwards uses that cache and does not format/write the changes to disk.

Additional Information

This caught me off guard more than anything. The workaround (or perhaps the desired behavior) would be to not run the first command with --cache like so:

npx prettier . --list-different
npx prettier . --write --cache

Alternatively, I can see the perspective of --list-different --cache not being allowed to use together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliIssues with Prettier's Command Line Interface

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions