Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom-error-definition: Cover exports name #313

Merged

Conversation

MrHen
Copy link
Contributor

@MrHen MrHen commented Jun 3, 2019

Fixes #190.

I cheated a bit for this one. If the rule is turned on it will force the error name to be correct so the rule only has to check for a mismatch on the exports identifier in the case where the right hand side is an error class.

There was another interesting case that I did NOT cover:

class FooError extends Error {
	constructor(error) {
		super(error);
		this.name = 'FooError';
	}
};
exports.fooError = FooError;

It would theoretically be possible to find an error definition from earlier in the same file. If we want this scenario covered, then I can add it in.

@sindresorhus
Copy link
Owner

It would theoretically be possible to find an error definition from earlier in the same file. If we want this scenario covered, then I can add it in.

Nah. Not worth the effort since we'll have ESM in Node.js soon.

@sindresorhus sindresorhus merged commit 3f2e9a6 into sindresorhus:master Jun 10, 2019
@MrHen MrHen deleted the bug/190-custom-error-definition-exports branch June 10, 2019 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom-error-definition rule does not validate against exported name
2 participants