Skip to content

formatter: Diff with Prettier on blank line after "use client" directive #21152

@jsmecham

Description

@jsmecham

Input

"use client"; // browser only

import { Foo } from "foo";
import { Bar } from "bar";

Config

{}

Oxfmt output

Oxfmt version: 0.44.0

"use client"; // browser only
import { Foo } from "foo";
import { Bar } from "bar";

Oxfmt playground link

https://playground.oxc.rs/?t=formatter&formatterPanels=output,prettier&code=%22use%20client%22%3B%20//%20browser%20only%0A%0Aimport%20%7B%20Foo%20%7D%20from%20%22foo%22%3B%0Aimport%20%7B%20Bar%20%7D%20from%20%22bar%22%3B

Prettier output

Prettier version: 3.8.1

"use client"; // browser only

import { Foo } from "foo";
import { Bar } from "bar";

Additional notes

oxfmt removes the blank line between a "use client" (or "use server") directive and the first import statement. Prettier preserves this blank line.

The blank line is a common convention to visually separate the directive from the rest of the module, similar to how a blank line is preserved after "use strict".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions