8000 Prettier 3.x refuses to format an explicitly given path that is a symbolic link · Issue #15843 · prettier/prettier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Prettier 3.x refuses to format an explicitly given path that is a symbolic link #15843
Open
@lopopolo

Description

@lopopolo

Prettier 3.x added explicit behavior to refuse formatting of paths that are symbolic links in #14627. I'm not sure what motivated this change, but to me it seems inappropriate that a tool that accepts file paths would care about what type of path it is given.

I run prettier as part of my bazel monorepo to enforce that source code is formatted correctly using a custom Bazel rule which invokes prettier as a test. This means that prettier is run in the Bazel sandbox and source code files to be tested are symlinked from the source repository into the Bazel sandbox.

The prettier invocation explicitly enumerates all paths on the command line, like path/to/prettier --check a/b/c.js x/y/z.md.

In prettier 2.x, prettier will read the contents and perform format checking. prettier 3.x refuses to read contents at these paths because the paths are symlinks.

#15533 added the ability to suppress the hard error by silently skipping symlinks. I don't consider this an appropriate fix. I want prettier to format code when given a path regardless of whether that path is a symlink or not.

Environments:

  • Prettier Version: 3.1.1
  • Running Prettier via: CLI
  • Runtime: Node.js v20 LTS
  • Operating System: Running prettier under Bazel on Linux, macOS
  • Prettier plugins (if any): none

Steps to reproduce:

prettier --check symlinked/path/to/file.js

Expected behavior: When given an explicit path that does not contain a glob, prettier reads the contents and checks formatting, regardless of the type of path given

Actual behavior: Prettier throws an error and refuses to format paths that are symbolic links.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0