I am using airbnb style check. One of the enabled rules is new-cap
. It will flag missing new in case such as
import { Record } from 'typed-immutable';
const user = User();
The error message is 'A function with a name starting with an uppercase letter should only be used as a constructor'
It should be
const user = new User();
However eslint for some reason flags expressions like this:
class User extends Record(DEFAULTS)'
It is a false positive.
However can I avoid getting new-cap
error for class declaration?
I am using eslint 3.9.1 and eslint-config-airbnb 12.0.0
I add this exception to the .eslintrc
file
"rules": {
"new-cap": [
"error", {
"capIsNewExceptionPattern": "^(Immutable.)?Record$"
}
],
...