JS: Update UnusedOrUndefinedStateProperty

Using RelatedLocations to add clarity
This commit is contained in:
Asger F
2025-02-11 17:12:53 +01:00
parent 605999454a
commit 87ed86e4fd
7 changed files with 17 additions and 17 deletions

View File

@@ -74,7 +74,7 @@ function l() {
x ** 2; // $ Alert
}
1n + 1; // $ MISSED: Alert
1n + 1; // $ MISSING: Alert
(function(){
let sum = 0;

View File

@@ -59,7 +59,7 @@ function useThingPossiblySync(b) {
if (thing == null) {}
return thing + "bar"; // $ MISSED: Alert
return thing + "bar"; // $ MISSING: Alert
}
function useThingInVoid() {

View File

@@ -6,7 +6,7 @@ function foo() {
function bar() {
var g;
g(); // $ MISSED: Alert
g(); // $ MISSING: Alert
eval("g = alert");
}

View File

@@ -12,7 +12,7 @@ let c = new C();
C(); // $ Alert
new (x=>x); // $ Alert
c.m();
new c.m(); // $ MISSED: Alert
new c.m(); // $ MISSING: Alert
var o = {
f: function() {},
@@ -21,7 +21,7 @@ var o = {
o.f();
new o.f();
o.g();
new o.g(); // $ MISSED: Alert
new o.g(); // $ MISSING: Alert
function f(b) {
var g;

View File

@@ -9,10 +9,10 @@ class C1 extends React.Component {
}
}
class C2 extends React.Component {
class C2 extends React.Component { // $ Alert
state = {
p1: ''
p1: '' // $ RelatedLocation
}
static getDerivedStateFromProps_unmodeled(props, state) {

View File

@@ -1,12 +1,12 @@
class C1 extends React.Component {
class C1 extends React.Component { // $ Alert
constructor() {
this.state.writtenDirectly = 42;
this.setState({
writtenInSetState: 42
});
this.state.writtenInOtherMethod;
this.state.notWritten; // $ Alert
this.state.notWrittenButReadInChain; // $ Alert
this.state.notWritten; // $ RelatedLocation
this.state.notWrittenButReadInChain; // $ RelatedLocation
this.state.writtenDirectly;
this.state.writtenInSetState;
@@ -29,10 +29,10 @@ class C2 extends React.Component {
}
class C3 extends React.Component {
class C3 extends React.Component { // $ Alert
constructor() {
this.state.writtenThrougExternalPropertyAccess;
this.state.notWrittenThrougExternalPropertyAccess; // $ Alert
this.state.notWrittenThrougExternalPropertyAccess; // $ RelatedLocation
}
}

View File

@@ -1,9 +1,9 @@
class C1 extends React.Component {
class C1 extends React.Component { // $ Alert
constructor() {
this.state.readDirectly = 42;
this.state.readInChain = {};
this.state.readInOtherMethod = {};
this.state.notRead = 42; // $ Alert
this.state.notRead = 42; // $ RelatedLocation
this.state.readDirectly;
this.state.readInChain.foo;
}
@@ -18,16 +18,16 @@ function f(s){
}
class C2 extends React.Component {
constructor() {
this.state.readWhenEscaped = 42; // $ Alert
this.state.readWhenEscaped = 42; // $ MISSING: Alert
f(this.state);
}
}
class C3 extends React.Component {
class C3 extends React.Component { // $ Alert
constructor() {
this.state.readThrougExternaPropertyAccess = 42;
this.state.notReadThrougExternaPropertyAccess = 42; // $ Alert
this.state.notReadThrougExternaPropertyAccess = 42; // $ RelatedLocation
}
}