Skip to content

Commit

Permalink
[no-unused-prop-types] Silence false positive on never type in TS.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcorpet committed Oct 1, 2020
1 parent 2b0d70c commit 6301a82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rules/no-unused-prop-types.js
Expand Up @@ -102,6 +102,11 @@ module.exports = {
return;
}

if (prop.node && prop.node.typeAnnotation && prop.node.typeAnnotation.typeAnnotation
&& prop.node.typeAnnotation.typeAnnotation.type === 'TSNeverKeyword') {
return;
}

if (prop.node && !isPropUsed(component, prop)) {
context.report({
node: prop.node.key || prop.node,
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -3668,6 +3668,19 @@ ruleTester.run('no-unused-prop-types', rule, {
`,
parser: parsers['@TYPESCRIPT_ESLINT']
},
{
code: `
interface Person {
firstname: string
lastname?: never
};
const Hello = ({firstname}: Person) => {
return <div><span>{firstname}</span></div>;
};
`,
parser: parsers['@TYPESCRIPT_ESLINT']
},
{
code: `
class App extends Component {
Expand Down

0 comments on commit 6301a82

Please sign in to comment.