Skip to content

Commit 6cfe6eb

Browse files
committed
adding test cases from jsx-eslint#811
1 parent bc5435d commit 6cfe6eb

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
@@ -1914,6 +1914,49 @@ ruleTester.run('no-unused-prop-types', rule, {
19141914
' test: React.PropTypes.bool',
19151915
'};'
19161916
].join('\n')
1917+
}, {
1918+
// issue 811
1919+
code: [
1920+
'const Button = React.createClass({',
1921+
'displayName: "Button",',
1922+
1923+
'propTypes: {',
1924+
' name: React.PropTypes.string.isRequired,',
1925+
' isEnabled: React.PropTypes.bool.isRequired',
1926+
'},',
1927+
1928+
'render() {',
1929+
' const item = this.props;',
1930+
' const disabled = !this.props.isEnabled;',
1931+
' return (',
1932+
' <div>',
1933+
' <button type="button" disabled={disabled}>{item.name}</button>',
1934+
' </div>',
1935+
' );',
1936+
'}',
1937+
'});'
1938+
].join('\n')
1939+
}, {
1940+
// issue 811
1941+
code: [
1942+
'class Foo extends React.Component {',
1943+
' static propTypes = {',
1944+
' foo: PropTypes.func.isRequired,',
1945+
'}',
1946+
1947+
'constructor(props) {',
1948+
' super(props);',
1949+
1950+
' const { foo } = props;',
1951+
' this.message = foo("blablabla");',
1952+
'}',
1953+
1954+
'render() {',
1955+
' return <div>{this.message}</div>;',
1956+
'}',
1957+
'}'
1958+
].join('\n'),
1959+
parser: 'babel-eslint'
19171960
}
19181961
],
19191962

0 commit comments

Comments
 (0)