Skip to content

AssignmentExpression with ClassExpression are systematically wrapped regardless of length #9740

@PyvesB

Description

@PyvesB

Prettier 2.2.0
Playground link

--parser babel

Input:

module.exports = class A extends B {
  method () {
    console.log("foo");
  }
};

Output:

module.exports = class A extends (
  B
) {
  method() {
    console.log("foo");
  }
};

Expected behavior:

The input should not be modified by Prettier when the superclass name is of reasonable length and/or does not have any namespaces. This behavior was changed in Prettier 2.2.0 and is probably caused by this new feature which was implemented in #9341. The intent was to wrap assignments with long superclass names when using the Google Closure library for example. However, it applies to everything, even if the superclass name is a single letter. This seems to do more harm than good on code readability.

Metadata

Metadata

Assignees

Labels

lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions