Skip to content

Commit 217d33e

Browse files
committed
Add support for prefixes in flow prop-types
1 parent 44ca52b commit 217d33e

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ module.exports = {
265265
*/
266266
function getKeyValue(node) {
267267
if (node.type === 'ObjectTypeProperty') {
268-
const tokens = context.getFirstTokens(node, 1);
268+
const tokens = context.getFirstTokens(node, {count: 1, filter: tokenNode => tokenNode.type === 'Identifier'});
269269
return tokens[0].value;
270270
}
271271
const key = node.key || node.argument;

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

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,27 +2032,40 @@ ruleTester.run('no-unused-prop-types', rule, {
20322032
}, {
20332033
// issue #106
20342034
code: `
2035-
import React from 'react';
2036-
import SharedPropTypes from './SharedPropTypes';
2035+
import React from 'react';
2036+
import SharedPropTypes from './SharedPropTypes';
20372037
2038-
export default class A extends React.Component {
2039-
render() {
2040-
return (
2041-
<span
2042-
a={this.props.a}
2043-
b={this.props.b}
2044-
c={this.props.c}>
2045-
{this.props.children}
2046-
</span>
2047-
);
2038+
export default class A extends React.Component {
2039+
render() {
2040+
return (
2041+
<span
2042+
a={this.props.a}
2043+
b={this.props.b}
2044+
c={this.props.c}>
2045+
{this.props.children}
2046+
</span>
2047+
);
2048+
}
20482049
}
2049-
}
20502050
2051-
A.propTypes = {
2052-
a: React.PropTypes.string,
2053-
...SharedPropTypes // eslint-disable-line object-shorthand
2054-
};
2055-
`,
2051+
A.propTypes = {
2052+
a: React.PropTypes.string,
2053+
...SharedPropTypes // eslint-disable-line object-shorthand
2054+
};
2055+
`,
2056+
parser: 'babel-eslint'
2057+
}, {
2058+
// issue #933
2059+
code: `
2060+
type Props = {
2061+
+foo: number
2062+
}
2063+
class MyComponent extends React.Component {
2064+
render() {
2065+
return <div>{this.props.foo}</div>
2066+
}
2067+
}
2068+
`,
20562069
parser: 'babel-eslint'
20572070
}
20582071
],

0 commit comments

Comments
 (0)