standard: rule new-cap problem
Hey, i use the package hapijs/boom for server errors and all the methods are with camelCase for example new Boom.notImplemented()
standard is throwing an error
A constructor name should not start with a lowercase letter new-cap
but i can’t disable each line individually, is there a way to disable all new-cap warnings? or maybe fix the rule so it won’t throw an error?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 19 (9 by maintainers)
Missed answering to the previous comment, so here goes: I still think that that isn’t used too much, wouldn’t one do something like this in those cases? 🤔
You can do it by adding a comment like
// eslint-disable new-capto the end of the lineMaybe we could make an exception for
.default🤔@LinusU Agreed. Let’s not add an exception for this. If others can raise valid reasons, happy to reconsider.
I personally still feel that you should always reassign it to a variable with a capitalised name, but I don’t feel too strongly about it…
It’s always better to always assign the name
defaultto a name with a capitalized first letter before calling the constructor. It should always be possible to do this. For example, @jkga’s code sample can be modified like this:Is there some reason that I’m missing why this won’t work? @LinusU do you have thoughts?
We could change the rule to this:
which would allow the original code sample to work:
But can someone make an argument for a situation where this is more desirable?
Try with
// eslint-disable-line new-capat the end of the line or// eslint-disable-next-line new-capone line above the code you want eslint to disable@LinusU but its also being used with dynamic import