+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

🐛 noConstructorReturn reasoning is wrong #4005

@lgarron

Description

@lgarron

Environment information

Rome 11.0.0

What happened?

https://docs.rome.tools/lint/rules/noconstructorreturn/ states:

While returning a value from a constructor does not produce an error, the returned value is being ignored.

This is inaccurate:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor

The constructor method may have a return value. While the base class may return anything from its constructor, the derived class must return an object or undefined, or a TypeError will be thrown.

I'm not saying it's a great idea to do so, but it's not particularly harmful to the type safety of the program if the returned object is of the same class (that the constructor would already return).

Expected result

The rule should either avoid erroring on returned objects (at least when the return type matches the constructor's class), or the documentation should be updated.

Code of Conduct

  • I agree to follow Rome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LinterArea: linterS-PlannedStatus: planned by the team, but not in the short termenhancementNew feature request or improvement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载