mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): false positives with setters in the getter-return rule. (#3714)
related but won't close #2312 [oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9547942249/job/26314030884)
This commit is contained in:
parent
4134de8dcf
commit
1190dee47f
1 changed files with 7 additions and 1 deletions
|
|
@ -124,10 +124,13 @@ impl GetterReturn {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
AstKind::ObjectProperty(ObjectProperty { kind, .. }) => {
|
||||
AstKind::ObjectProperty(ObjectProperty { kind, key: prop_key, .. }) => {
|
||||
if matches!(kind, PropertyKind::Get) {
|
||||
return true;
|
||||
}
|
||||
if prop_key.name().is_some_and(|key| key != "get") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(parent_2) = ctx.nodes().parent_node(parent.id()) {
|
||||
if let Some(parent_3) = ctx.nodes().parent_node(parent_2.id()) {
|
||||
|
|
@ -328,8 +331,11 @@ fn test() {
|
|||
("class foo { get bar(){return;} }", Some(serde_json::json!([{ "allowImplicit": true }]))),
|
||||
("Object.defineProperty(foo, \"bar\", { get: function () {return true;}});", None),
|
||||
("Object.defineProperty(foo, \"bar\", { get: function () { ~function (){ return true; }();return true;}});", None),
|
||||
("Object.defineProperty(foo, \"bar\", { set: function () {}});", None),
|
||||
("Object.defineProperty(foo, \"bar\", { set: () => {}});", None),
|
||||
("Object.defineProperties(foo, { bar: { get: function () {return true;}} });", None),
|
||||
("Object.defineProperties(foo, { bar: { get: function () { ~function (){ return true; }(); return true;}} });", None),
|
||||
("Object.defineProperties(foo, { bar: { set: function () {}} });", None),
|
||||
("Reflect.defineProperty(foo, \"bar\", { get: function () {return true;}});", None),
|
||||
("Reflect.defineProperty(foo, \"bar\", { get: function () { ~function (){ return true; }();return true;}});", None),
|
||||
("Object.create(foo, { bar: { get() {return true;} } });", None),
|
||||
|
|
|
|||
Loading…
Reference in a new issue