Skip to content

Commit 42f23b3

Browse files
committed
[Fix] no-unused-prop-types, usedPropTypes: avoid crash with typescript-eslint parser
note: rules still do not work properly with the old TS parser
1 parent 3d5d47e commit 42f23b3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1313
* [`propTypes`]: add `VoidFunctionComponent` to react generic list ([#3092][] @vedadeepta)
1414
* [`jsx-fragments`], [`jsx-no-useless-fragment`]: avoid a crash on fragment syntax in `typescript-eslint` parser (@ljharb)
1515
* [`jsx-props-no-multi-spaces`]: avoid a crash on long member chains in tag names in `typescript-eslint` parser (@ljharb)
16+
* [`no-unused-prop-types`], `usedPropTypes`: avoid crash with typescript-eslint parser (@ljharb)
1617

1718
[#3092]: https://github.com/yannickcr/eslint-plugin-react/pull/3092
1819
[#2166]: https://github.com/yannickcr/eslint-plugin-react/pull/2166

lib/util/usedPropTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function isInLifeCycleMethod(node, checkAsyncSafeLifeCycles) {
145145
* @return {boolean}
146146
*/
147147
function isSetStateUpdater(node) {
148-
const unwrappedParentCalleeNode = node.parent.type === 'CallExpression'
148+
const unwrappedParentCalleeNode = node.parent && node.parent.type === 'CallExpression'
149149
&& ast.unwrapTSAsExpression(node.parent.callee);
150150

151151
return unwrappedParentCalleeNode

0 commit comments

Comments
 (0)