Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uprule new-cap problem #892
Comments
This comment has been minimized.
This comment has been minimized.
|
adding This to the top of the file should work: /* eslint-disable new-cap */Looking at the new-cap rule, there is an additional option called Right now we don't specify that option in eslint-config-standard so it falls back to the default, which is to ensure object properties are capitalized. Does anyone have any thoughts on changing the |
This comment has been minimized.
This comment has been minimized.
|
Would personally prefer to have |
This comment has been minimized.
This comment has been minimized.
jasonkarns
commented
Dec 27, 2017
•
|
Not sure if it relates to the
Actually, there's the counter-example, @LinusU: it's quite common for a default export to be a constructor function. But one is clearly not able to control the capitalization of the ESM-as-CJS |
This comment has been minimized.
This comment has been minimized.
|
removed spam from |
standard
deleted a comment
Dec 27, 2017
standard
deleted a comment
Dec 27, 2017
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
May 10, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
May 10, 2018
stale
bot
closed this
May 17, 2018
This comment has been minimized.
This comment has been minimized.
|
@LinusU Do you have thoughts on @jasonkarns's last comment regarding it being common for a default export to be a constructor function? |
feross
reopened this
May 20, 2018
stale
bot
removed
the
stale
label
May 20, 2018
feross
added
the
enhancement
label
May 20, 2018
This comment has been minimized.
This comment has been minimized.
jkga
commented
Jan 17, 2019
|
Any update on this? |
This comment has been minimized.
This comment has been minimized.
|
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? const Foobar = require('foobar').default
const blah = new Foobar() |
This comment has been minimized.
This comment has been minimized.
jkga
commented
Jan 17, 2019
|
@LinusU but its also being used with dynamic import return import('./components/my-component').then(dyamicLoadedClass => {
return new dyamicLoadedClass.default()
...
}) |
This comment has been minimized.
This comment has been minimized.
|
Maybe we could make an exception for |
This comment has been minimized.
This comment has been minimized.
dcsan
commented
Mar 6, 2019
|
yeah i have exact same problem on a Pusher library:
is there a way to disable linting on just a single line and not the whole file? |
This comment has been minimized.
This comment has been minimized.
|
You can do it by adding a comment like |
This comment has been minimized.
This comment has been minimized.
dcsan
commented
Mar 6, 2019
This comment has been minimized.
This comment has been minimized.
jkga
commented
Mar 6, 2019
|
@dcsan Try to put it on the very first line of the file |
This comment has been minimized.
This comment has been minimized.
dcsan
commented
Mar 6, 2019
|
this works at the top of the file but i just wanted to disable it for one line using the external lib call, not my own code.
|
This comment has been minimized.
This comment has been minimized.
|
Try with |
This comment has been minimized.
This comment has been minimized.
|
It's always better to always assign the name return import('./components/my-component').then(dyamicLoadedClass => {
const MyClass = dyamicLoadedClass.default
return new MyClass()
...
})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: return import('./components/my-component').then(dyamicLoadedClass => {
return new dyamicLoadedClass.default()
...
})But can someone make an argument for a situation where this is more desirable? |
This comment has been minimized.
This comment has been minimized.
|
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... const Foo = require('foo').default
new Foo()import('./components/my-component').then(module => {
const DyamicLoadedClass = module.default
new DyamicLoadedClass()
})import('./components/my-component').then(({ default: DyamicLoadedClass }) => {
new DyamicLoadedClass()
}) |
This comment has been minimized.
This comment has been minimized.
|
@LinusU Agreed. Let's not add an exception for this. If others can raise valid reasons, happy to reconsider. |


maticrivo commentedMay 23, 2017
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
but i can't disable each line individually, is there a way to disable all
new-capwarnings? or maybe fix the rule so it won't throw an error?