【发布时间】:2017-09-05 03:46:18
【问题描述】:
如果我检查 ESLint 文档,有一个完美的插件可用于 camel case properties,而同样的事情我试图识别函数是否是驼峰式。
index.js
var first_name;
var lastName;
function getFirstName(a,b){
return firstName;
}
.eslintrc
module.exports = {
"rules": {
"camelcase": [2, {"properties": "always"}]
}
}
如果我运行 eslint index.js,我将收到类似这样的正确 lint 错误
2:5 error Identifier 'first_name' is not in camel case camelcase
✖ 1 problem (1 error, 0 warnings)
同样,我也想为函数实现这一点。在这里,getfirstname 不是正确的驼峰式。我需要得到一个 lint 错误,所以我将规则更改为
module.exports = {
"rules": {
**"camelcase": [2, {"functions": "always"}]**
}
}
如果我设置了上述内容,我不会收到错误消息。我应该怎么做才能使用 eslint 模块验证函数的 linting?请提出另一种方法来识别这种棉绒。
【问题讨论】:
标签: javascript error-handling eslint lint