Skip to content

Range formatting ignores a // prettier-ignore comment just before the range #20164

Description

@leonidaz

Prettier 3.9.9
Playground link

--parser typescript
--range-start 19
--range-end 42

Input:

// prettier-ignore
const a  =  [1,2,   3];

Output:

// prettier-ignore
const a = [1, 2, 3];

Expected output:

// prettier-ignore
const a  =  [1,2,   3];

Why?

The range is exactly the ignored statement. The // prettier-ignore comment is outside the range, so the statement is formatted. Formatting the whole file keeps it as written.

Also reproduces on main (88d8e96).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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