changelog_unreleased/javascript/18397.md
if/while/do..while condition, to reduce diff when changing condition to negated value.// Input
if (!(
// `import("foo")`
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
)) {
} else if (
// `import("foo")`
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
) {
}
// Prettier stable
if (
!(
// `import("foo")`
(
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
)
)
) {
} else if (
// `import("foo")`
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
) {
}
// Prettier main
if (!(
// `import("foo")`
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
)) {
} else if (
// `import("foo")`
node.type === "ImportExpression" ||
// `type foo = import("foo")`
node.type === "TSImportType"
) {
}
This code example above is a real world case right here in the Prettier codebase