Skip to content

Commit bca3c88

Browse files
DianaSuvorovaljharb
authored andcommitted
adding test cases from jsx-eslint#811
1 parent bd23406 commit bca3c88

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

+43
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,49 @@ ruleTester.run('no-unused-prop-types', rule, {
19291929
' property2: React.propTypes.string.isRequired',
19301930
'}'
19311931
].join('\n')
1932+
}, {
1933+
// issue 811
1934+
code: [
1935+
'const Button = React.createClass({',
1936+
'displayName: "Button",',
1937+
1938+
'propTypes: {',
1939+
' name: React.PropTypes.string.isRequired,',
1940+
' isEnabled: React.PropTypes.bool.isRequired',
1941+
'},',
1942+
1943+
'render() {',
1944+
' const item = this.props;',
1945+
' const disabled = !this.props.isEnabled;',
1946+
' return (',
1947+
' <div>',
1948+
' <button type="button" disabled={disabled}>{item.name}</button>',
1949+
' </div>',
1950+
' );',
1951+
'}',
1952+
'});'
1953+
].join('\n')
1954+
}, {
1955+
// issue 811
1956+
code: [
1957+
'class Foo extends React.Component {',
1958+
' static propTypes = {',
1959+
' foo: PropTypes.func.isRequired,',
1960+
'}',
1961+
1962+
'constructor(props) {',
1963+
' super(props);',
1964+
1965+
' const { foo } = props;',
1966+
' this.message = foo("blablabla");',
1967+
'}',
1968+
1969+
'render() {',
1970+
' return <div>{this.message}</div>;',
1971+
'}',
1972+
'}'
1973+
].join('\n'),
1974+
parser: 'babel-eslint'
19321975
}
19331976
],
19341977

0 commit comments

Comments
 (0)