Skip to content

formatter: oxfmt moves eslint-disable-next-line above parenthesized JSX expression in template interpolation #21941

@mcharles-stack

Description

@mcharles-stack

Input

const doc = md`
${
	(
		// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- reason
		<div style={{ marginTop: token('space.100') }}>
			<Child />
		</div>
	)
}
`;

Oxfmt output

Oxfmt version: latest (0.47.0)

const doc = md`
${
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- reason
  (
    <div style={{ marginTop: token("space.100") }}>
      <Child />
    </div>
  )
}
`;

Oxfmt playground link

oxfmt playground

Prettier output

Prettier version: 3.8.3

const doc = md`
${
  (
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- reason
    <div style={{ marginTop: token("space.100") }}>
      <Child />
    </div>
  )
}
`;

Prettier playground link

prettier playground

Additional notes

oxfmt moves the eslint-disable-next-line comment out of a parenthesized JSX expression inside a template interpolation.

This is behaviour-changing because eslint-disable-next-line is line-sensitive. After formatting, the directive applies to the line containing ( instead of the JSX element line it was intended to suppress.

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