Monday, 10 April 2017

How to set ESLint rule to identify functions are came-case or not?

If i check for ESLint docs there is perfect plugin available for camel case properties,where as same thing i'm trying to acheive for functions to verify either it is 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 getting proper lint error

  2:5  error  Identifier 'first_name' is not in camel case  camelcase

✖ 1 problem (1 error, 0 warnings)

In the above problem similarly i want this to achieve for functions too,here getfirstname is not proper camel case for this i need to get lint error,so i changed rule to

 module.exports = {
        "rules": {
             **"camelcase": [2, {"functions": "always"}]**  
        }
    }

if i set the above i'm getting error,in this case how to validate linting for function using eslint module or else suggest me any other way to identify these linting



via rselvaganesh

No comments:

Post a Comment