Skip to content

Commit

Permalink
[Fix] displayName (but really, propTypes detection): do not crash…
Browse files Browse the repository at this point in the history
… on empty flow type spreads

Fixes #2570.
  • Loading branch information
ljharb committed Feb 8, 2020
1 parent 0a717a5 commit 66c0d66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/util/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ function getKeyValue(context, node) {
if (node.type === 'GenericTypeAnnotation') {
return node.id.name;
}
if (node.type === 'ObjectTypeAnnotation') {
return;
}
const key = node.key || node.argument;
return key.type === 'Identifier' ? key.name : key.value;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ ruleTester.run('display-name', rule, {
return <div>{items}</div>;
}
`
}, {
code: `
import {Component} from "react";
type LinkProps = {...{}};
class Link extends Component<LinkProps> {}
`,
parser: parsers.BABEL_ESLINT
}],

invalid: [{
Expand Down

0 comments on commit 66c0d66

Please sign in to comment.