mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
JS: Add inline expectations to React test
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
var Hello = React.createClass({
|
||||
displayName: 'Hello',
|
||||
render: function() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
return <div>Hello {this.props.name}</div>; // $ threatModelSource=view-component-input
|
||||
},
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
name: 'world'
|
||||
name: 'world' // $ getACandidatePropsValue
|
||||
};
|
||||
}
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
Hello.info = function() {
|
||||
return "Nothing to see here.";
|
||||
@@ -17,6 +17,6 @@ Hello.info = function() {
|
||||
var createReactClass = require('create-react-class');
|
||||
var Greeting = createReactClass({
|
||||
render: function() {
|
||||
return <h1>Hello, {this.props.name}</h1>;
|
||||
return <h1>Hello, {this.props.name}</h1>; // $ threatModelSource=view-component-input
|
||||
}
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class Hello extends React.Component {
|
||||
class Hello extends React.Component { // $ threatModelSource=view-component-input
|
||||
render() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
return <div>Hello {this.props.name}</div>; // $ threatModelSource=view-component-input
|
||||
}
|
||||
static info() {
|
||||
return "Nothing to see here.";
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
Hello.displayName = 'Hello';
|
||||
Hello.defaultProps = {
|
||||
name: 'world'
|
||||
@@ -17,4 +17,4 @@ class Hello2 extends React.Component {
|
||||
this.state.bar.foo = 42;
|
||||
this.state = { baz: 42};
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export function MyComponent(props) {
|
||||
export function MyComponent(props) { // $ threatModelSource=view-component-input
|
||||
return <div style={{color: props.color}}/>
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MyComponent } from "./exportedComponent";
|
||||
|
||||
export function render({color, location}) {
|
||||
return <MyComponent color={color}/>
|
||||
}
|
||||
export function render({color, location}) { // $ threatModelSource=view-component-input locationSource threatModelSource=remote
|
||||
return <MyComponent color={color}/> // $ getACandidatePropsValue
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component } from "react";
|
||||
|
||||
class C extends Component {}
|
||||
class C extends Component {} // $ threatModelSource=view-component-input reactComponent
|
||||
|
||||
class D extends C {}
|
||||
class D extends C {} // $ threatModelSource=view-component-input reactComponent
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
function Hello(props) {
|
||||
function Hello(props) { // $ threatModelSource=view-component-input
|
||||
return <div>Hello {props.name}</div>;
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
function Hello2(props) {
|
||||
function Hello2(props) { // $ threatModelSource=view-component-input
|
||||
return React.createElement("div");
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
function Hello3(props) {
|
||||
function Hello3(props) { // $ threatModelSource=view-component-input
|
||||
var x = React.createElement("div");
|
||||
return x;
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
function NotAComponent(props) {
|
||||
if (y)
|
||||
@@ -17,8 +17,8 @@ function NotAComponent(props) {
|
||||
return g();
|
||||
}
|
||||
|
||||
function SpuriousComponent(props) {
|
||||
function SpuriousComponent(props) { // $ threatModelSource=view-component-input
|
||||
if (y)
|
||||
return React.createElement("div");
|
||||
return 42;
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class Hello extends Preact.Component {
|
||||
render(props, state) {
|
||||
class Hello extends Preact.Component { // $ threatModelSource=view-component-input
|
||||
render(props, state) { // $ threatModelSource=view-component-input
|
||||
props.name;
|
||||
state.name;
|
||||
return <div/>;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
class Hello extends preact.Component {
|
||||
class Hello extends preact.Component { // $ threatModelSource=view-component-input
|
||||
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Hello extends Component {
|
||||
class Hello extends Component { // $ threatModelSource=view-component-input
|
||||
render() {
|
||||
this.props.name;
|
||||
this.props.name; // $ threatModelSource=view-component-input
|
||||
return <div/>;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
function ES2015() {
|
||||
class C extends React.Component {
|
||||
}
|
||||
class C extends React.Component { // $ threatModelSource=view-component-input
|
||||
} // $ reactComponent
|
||||
|
||||
C.defaultProps = { propFromDefaultProps: "propFromDefaultProps" };
|
||||
C.defaultProps = { propFromDefaultProps: "propFromDefaultProps" }; // $ getACandidatePropsValue
|
||||
|
||||
(<C propFromJSX={"propFromJSX"}/>);
|
||||
(<C propFromJSX={"propFromJSX"}/>); // $ getACandidatePropsValue
|
||||
|
||||
new C({propFromConstructor: "propFromConstructor"});
|
||||
new C({propFromConstructor: "propFromConstructor"}); // $ getACandidatePropsValue
|
||||
}
|
||||
|
||||
function ES5() {
|
||||
var C = React.createClass({
|
||||
getDefaultProps() {
|
||||
return { propFromDefaultProps: "propFromDefaultProps" };
|
||||
return { propFromDefaultProps: "propFromDefaultProps" }; // $ getACandidatePropsValue
|
||||
}
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
(<C propFromJSX={"propFromJSX"}/>);
|
||||
(<C propFromJSX={"propFromJSX"}/>); // $ getACandidatePropsValue
|
||||
|
||||
C({propFromConstructor: "propFromConstructor"});
|
||||
C({propFromConstructor: "propFromConstructor"}); // $ getACandidatePropsValue
|
||||
|
||||
}
|
||||
|
||||
function Functional() {
|
||||
function C(props) {
|
||||
function C(props) { // $ threatModelSource=view-component-input
|
||||
return <div/>;
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
C.defaultProps = { propFromDefaultProps: "propFromDefaultProps" };
|
||||
C.defaultProps = { propFromDefaultProps: "propFromDefaultProps" }; // $ getACandidatePropsValue
|
||||
|
||||
(<C propFromJSX={"propFromJSX"}/>);
|
||||
(<C propFromJSX={"propFromJSX"}/>); // $ getACandidatePropsValue
|
||||
|
||||
new C({propFromConstructor: "propFromConstructor"});
|
||||
new C({propFromConstructor: "propFromConstructor"}); // $ getACandidatePropsValue
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class C extends React.Component {
|
||||
class C extends React.Component { // $ threatModelSource=view-component-input
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
return {};
|
||||
}
|
||||
@@ -8,4 +8,4 @@ class C extends React.Component {
|
||||
getSnapshotBeforeUpdate(prevProps, prevState) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -10,4 +10,4 @@ class Reads extends React.Component {
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
prevState.p4;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -31,15 +31,15 @@ class Writes extends React.Component {
|
||||
state = {
|
||||
p7: 42
|
||||
};
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
React.createClass({
|
||||
render: function() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
return <div>Hello {this.props.name}</div>; // $ threatModelSource=view-component-input
|
||||
},
|
||||
getInitialState: function() {
|
||||
return {
|
||||
p8: 42
|
||||
};
|
||||
}
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
@@ -13,7 +13,7 @@ class C extends React.Component {
|
||||
someInstanceMethod() {
|
||||
this;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
React.createClass({
|
||||
render: function() {
|
||||
@@ -26,14 +26,14 @@ React.createClass({
|
||||
someInstanceMethod: function() {
|
||||
this;
|
||||
}
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
(function (props) {
|
||||
(function (props) { // $ threatModelSource=view-component-input
|
||||
(function () {
|
||||
this; props;
|
||||
}).bind(this);
|
||||
return <div/>;
|
||||
})
|
||||
}) // $ reactComponent
|
||||
|
||||
React.createClass({
|
||||
render: function() {
|
||||
@@ -42,14 +42,14 @@ React.createClass({
|
||||
}, this)
|
||||
return <div/>;
|
||||
},
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
class C2 extends React.Component {
|
||||
constructor (y) {
|
||||
constructor (y) { // $ threatModelSource=view-component-input
|
||||
this.state = x;
|
||||
this.state = y;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
class C3 extends React.Component {
|
||||
constructor() {
|
||||
@@ -60,4 +60,4 @@ class C3 extends React.Component {
|
||||
var foo = <this.name></this.name>;
|
||||
var bar = <this.this></this.this>;
|
||||
}
|
||||
}
|
||||
} // $ reactComponent
|
||||
|
||||
@@ -12,4 +12,4 @@ React.createClass({
|
||||
|
||||
return <div/>;
|
||||
},
|
||||
});
|
||||
}); // $ reactComponent
|
||||
|
||||
@@ -2,17 +2,17 @@ import SomeComponent from './higherOrderComponent';
|
||||
import { lazy } from 'react';
|
||||
|
||||
function foo() {
|
||||
return <SomeComponent color="red"/>
|
||||
return <SomeComponent color="red"/> // $ getACandidatePropsValue
|
||||
}
|
||||
|
||||
const LazyLoadedComponent = lazy(() => import('./higherOrderComponent'));
|
||||
|
||||
function bar() {
|
||||
return <LazyLoadedComponent color="lazy"/>
|
||||
return <LazyLoadedComponent color="lazy"/> // $ getACandidatePropsValue
|
||||
}
|
||||
|
||||
const LazyLoadedComponent2 = lazy(() => import('./exportedComponent').then(m => m.MyComponent));
|
||||
|
||||
function barz() {
|
||||
return <LazyLoadedComponent2 color="lazy2"/>
|
||||
return <LazyLoadedComponent2 color="lazy2"/> // $ getACandidatePropsValue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user