Range formatting ignores a `// prettier-ignore` comment just before the range
Author: leonidazCreated Sep 28, 2026Updated Sep 28, 2026
Prettier 3.9.9 Playground link
--parser typescript
--range-start 19
--range-end 42Input:
// 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).
Source: prettier/prettier