Skip to content

Commit 99150f2

Browse files
committed
JS: Use RelatedLocations in UnusedOrUndefinedStateProperty
1 parent 4ddd95c commit 99150f2

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/issue7506.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class C1 extends React.Component {
99
}
1010
}
1111

12-
class C2 extends React.Component {
12+
class C2 extends React.Component { // $ Alert
1313

1414
state = {
15-
p1: ''
15+
p1: '' // $ RelatedLocation
1616
}
1717

1818
static getDerivedStateFromProps_unmodeled(props, state) {

javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/undefined.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
class C1 extends React.Component {
1+
class C1 extends React.Component { // $ Alert
22
constructor() {
33
this.state.writtenDirectly = 42;
44
this.setState({
55
writtenInSetState: 42
66
});
77
this.state.writtenInOtherMethod;
8-
this.state.notWritten; // $ MISSING: Alert
9-
this.state.notWrittenButReadInChain; // $ MISSING: Alert
8+
this.state.notWritten; // $ RelatedLocation
9+
this.state.notWrittenButReadInChain; // $ RelatedLocation
1010
this.state.writtenDirectly;
1111
this.state.writtenInSetState;
1212

@@ -29,10 +29,10 @@ class C2 extends React.Component {
2929
}
3030

3131

32-
class C3 extends React.Component {
32+
class C3 extends React.Component { // $ Alert
3333
constructor() {
3434
this.state.writtenThrougExternalPropertyAccess;
35-
this.state.notWrittenThrougExternalPropertyAccess; // $ MISSING: Alert
35+
this.state.notWrittenThrougExternalPropertyAccess; // $ RelatedLocation
3636
}
3737
}
3838

javascript/ql/test/query-tests/React/UnusedOrUndefinedStateProperty/unused.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class C1 extends React.Component {
1+
class C1 extends React.Component { // $ Alert
22
constructor() {
33
this.state.readDirectly = 42;
44
this.state.readInChain = {};
55
this.state.readInOtherMethod = {};
6-
this.state.notRead = 42; // $ MISSING: Alert
6+
this.state.notRead = 42; // $ RelatedLocation
77
this.state.readDirectly;
88
this.state.readInChain.foo;
99
}
@@ -24,10 +24,10 @@ class C2 extends React.Component {
2424
}
2525

2626

27-
class C3 extends React.Component {
27+
class C3 extends React.Component { // $ Alert
2828
constructor() {
2929
this.state.readThrougExternaPropertyAccess = 42;
30-
this.state.notReadThrougExternaPropertyAccess = 42; // $ MISSING: Alert
30+
this.state.notReadThrougExternaPropertyAccess = 42; // $ RelatedLocation
3131
}
3232
}
3333

0 commit comments

Comments
 (0)