#20164·prettier

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

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

Input:

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

Output:

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

Expected output:

typescript
// 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).