Skip to content

Commit

Permalink
Add support for prefixes in flow prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
jseminck committed Aug 22, 2017
1 parent 44ca52b commit 217d33e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ module.exports = {
*/
function getKeyValue(node) {
if (node.type === 'ObjectTypeProperty') {
const tokens = context.getFirstTokens(node, 1);
const tokens = context.getFirstTokens(node, {count: 1, filter: tokenNode => tokenNode.type === 'Identifier'});
return tokens[0].value;
}
const key = node.key || node.argument;
Expand Down
49 changes: 31 additions & 18 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2032,27 +2032,40 @@ ruleTester.run('no-unused-prop-types', rule, {
}, {
// issue #106
code: `
import React from 'react';
import SharedPropTypes from './SharedPropTypes';
import React from 'react';
import SharedPropTypes from './SharedPropTypes';
export default class A extends React.Component {
render() {
return (
<span
a={this.props.a}
b={this.props.b}
c={this.props.c}>
{this.props.children}
</span>
);
export default class A extends React.Component {
render() {
return (
<span
a={this.props.a}
b={this.props.b}
c={this.props.c}>
{this.props.children}
</span>
);
}
}
}
A.propTypes = {
a: React.PropTypes.string,
...SharedPropTypes // eslint-disable-line object-shorthand
};
`,
A.propTypes = {
a: React.PropTypes.string,
...SharedPropTypes // eslint-disable-line object-shorthand
};
`,
parser: 'babel-eslint'
}, {
// issue #933
code: `
type Props = {
+foo: number
}
class MyComponent extends React.Component {
render() {
return <div>{this.props.foo}</div>
}
}
`,
parser: 'babel-eslint'
}
],
Expand Down

0 comments on commit 217d33e

Please sign in to comment.