sindresorhus/eslint-plugin-unicorn
Rule proposal: `no-return-prototype-method`
クローズ
#1,098 opened on 2021/02/11
help wantednew rule
Repository metrics
- Stars
- (5,022 個のスター)
- PR merge metrics
- (平均マージ 4h 30m) (30d で 26 merged PRs)
説明
It's easy to forget actually calling a prototype method which leads to possibly hard-to-debug errors.
Since e.g. many array methods accept a callback or only an optional parameter, this could be handled with an allowlist per global object, e.g. Array.prototype.map wouldnt need to be checked for.
Fail
function foo(myString) {
return string.slice(3).toLowerCase
}
function foo(myArr) {
return myArr.map(val => val ** 2).reverse
}
Pass
function foo(myString) {
return string.slice(3).toLowerCase()
}
function foo(myArr) {
return myArr.map(val => val ** 2).reverse()
}