getter-return
NOTE: this rule is part of the
推荐
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["推荐"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["getter-return"], "exclude": ["getter-return"] } } }
要求所有属性获取器函数返回一个值。
获取器函数返回属性的值。如果函数不返回值,则违反了此合同。
无效:
let foo = {
get bar() {},
};
class Person {
get name() {}
}
有效:
let foo = {
get bar() {
return true;
},
};
class Person {
get name() {
return "alice";
}
}