If I check for ESLint docs there is a perfect plugin available for camel case properties, whereas the same thing I'm trying to identify functions if they are either camelcase or not.
index.js
var first_name;
var lastName;
function getFirstName(a,b){
return firstName;
}
.eslintrc
module.exports = {
"rules": {
"camelcase": [2, {"properties": "always"}]
}
}
if I ran eslint index.js, I will be getting a proper lint error like this
2:5 error Identifier 'first_name' is not in camel case camelcase
✖ 1 problem (1 error, 0 warnings)
Similarly, I want to achieve this for functions too. Here, getfirstname
is not in proper camelcase. I need to get a lint error, so I have changed the rule to
module.exports = {
"rules": {
**"camelcase": [2, {"functions": "always"}]**
}
}
if I set the above, I'm not getting the error. what should I do to validate linting for functions using the eslint module? please suggest another way to identify this linting.
You will not be able to detect automatically things like
getfirstname
that is not a proper camel case. The linter can be sure that it's not camel case if it sees an underscore but here it just looks like one word and it's not that intelligent to know that it isn't.If it did then it would have to reject things like
XMLHttpRequest
,setTimeout
andfs.realpath
.