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

🐛 noconstructorreturn doesn't make sense in ES6 #4471

Closed
1 task done
GeorgeTailor opened this issue May 14, 2023 · 2 comments
Closed
1 task done

🐛 noconstructorreturn doesn't make sense in ES6 #4471

GeorgeTailor opened this issue May 14, 2023 · 2 comments
Labels
S-To triage Status: user report of a possible bug that needs to be triaged

Comments

@GeorgeTailor
Copy link

GeorgeTailor commented May 14, 2023

Environment information

since `Rome 11.0.0`

What happened?

The default rome lint rule https://docs.rome.tools/lint/rules/noconstructorreturn/
does not make sense in ES6, which is marking creation of OOP-style singletons as incorrect. Blindly copy-pasting rules from eslint, imo, is not a good idea.

Consider the following code:

export class NotePositionService {
	static instance: NotePositionService;
	constructor() {
		if (NotePositionService.instance) {
			return NotePositionService.instance;
		}
		NotePositionService.instance = this;
		// some heavy initiazer logic, which should be run only once
	}
}

Sadly, #4005 turned into a noop.

Expected result

https://docs.rome.tools/lint/rules/noconstructorreturn/
should not be the default.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@GeorgeTailor GeorgeTailor added the S-To triage Status: user report of a possible bug that needs to be triaged label May 14, 2023
@ematipico
Copy link
Contributor

@GeorgeTailor, if you suggest making this rule not recommended, I think it's best to create a github discussion and give some reasons (like in this issue).

Instead, you should provide a reproduction code if there's a bug, like a false-positive.

@GeorgeTailor
Copy link
Author

#4472
created

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-To triage Status: user report of a possible bug that needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants