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

throw-new-error false positive #2360

Open
brokenmass opened this issue May 16, 2024 · 2 comments
Open

throw-new-error false positive #2360

brokenmass opened this issue May 16, 2024 · 2 comments

Comments

@brokenmass
Copy link

brokenmass commented May 16, 2024

after last release throw new error reports any call to function that are PascalCase and contains the word “Error” as invalid.

Example:

‘’’
const ParseError = () => 0;

// this is reported as invalid
cont result = ParseError();
‘’’

In my specific case I’m getting the error when using a class decorator to track custom error classes

‘’’
@RegisterServiceError()
class SomeError extends BaseError {}
’’’

easiest solution would be to at least allow a list of name exceptions to the rule.

@fregante
Copy link
Collaborator

fregante commented May 21, 2024

It's not quite clear why that should be valid. Generally only classes and JSX functions should be in pascal case. RegisterServiceError is neither so it should be registerServiceError and it's automatically ignored by the rule.

@brokenmass
Copy link
Author

brokenmass commented May 21, 2024

Using PascalCase for decorators (especially decorators factories) is pretty much standard.

Said so, using PascalCase only for classes and components is a naming convention, not a js requirement.
It’s like getting a false positive because the line is indented with tabs instead of with spaces.
This plugin should not rely on such conventions and/or allow the user to configure alternative regexes or exceptions

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

No branches or pull requests

2 participants