Skip to content

Format inconsistent with CallExpression and NewExpression breaking #18406

@leaysgur

Description

@leaysgur

Prettier 3.7.3
Playground link

--parser babel-ts # or --parser typescript

Input:

new ((
  require('./webpack/plugins/next-trace-entrypoints-plugin')
)
  .TraceEntryPointsPlugin as P)(
  {
    rootDir: dir,
  }
);

((
  require('./webpack/plugins/next-trace-entrypoints-plugin')
)
  .TraceEntryPointsPlugin as P)(
  {
    rootDir: dir,
  }
);

Output:

new (require("./webpack/plugins/next-trace-entrypoints-plugin")
  .TraceEntryPointsPlugin as P)({
  rootDir: dir,
});

(
  require("./webpack/plugins/next-trace-entrypoints-plugin")
    .TraceEntryPointsPlugin as P
)({
  rootDir: dir,
});

Formatting of CallExpression and NewExpression is inconsistent.

if (
(key === "callee" && isCallExpression(parent)) ||
(key === "object" && isMemberExpression(parent))
) {

We think the CallExpression output is actually better than NewExpression, which is better for readability.

How do you think?

refs: oxc-project/oxc#16380 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood fist issue!help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions