![](/img/trans.png)
[英]ESlint rule for function names with TypeScript (camelCase with lower case for first letter)
[英]How to set ESLint rule to identify functions are either camelcase or not?
如果我檢查ESLint文檔,那么有一個完美的插件可用於駝峰式案例屬性 ,而同一件事我正在嘗試識別是否為駝峰式案例的函數。
index.js
var first_name;
var lastName;
function getFirstName(a,b){
return firstName;
}
.eslintrc
module.exports = {
"rules": {
"camelcase": [2, {"properties": "always"}]
}
}
如果我運行eslint index.js ,我將得到一個像這樣的正確的皮棉錯誤
2:5 error Identifier 'first_name' is not in camel case camelcase
✖ 1 problem (1 error, 0 warnings)
同樣,我也想為功能實現這一點。 在這里, getfirstname
不在正確的getfirstname
中。 我需要得到一個皮棉錯誤,所以我將規則更改為
module.exports = {
"rules": {
**"camelcase": [2, {"functions": "always"}]**
}
}
如果我設置了上述值,則不會出錯。 我應該怎么做才能使用eslint模塊對功能進行驗證? 請提出另一種方法來識別這種棉絨。
在上面的問題中,類似地,我也希望此功能也能實現,在此getfirstname不適用於此情況,因此我需要獲取lint錯誤
您將無法自動檢測到諸如getfirstname
的不正確的駝峰式情況。 短絨棉絨靴可以肯定的是,如果看到下划線,這不是駱駝的情況,但是在這里看起來就像一個單詞,知道不是這樣的話並不是很聰明。
如果這樣做的話,它將不得不拒絕XMLHttpRequest
, setTimeout
和fs.realpath
類的東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.