Skip to content

Commit

Permalink
[Refactor] jsx-props-no-multi-spaces: extract type parameters to var
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryBrown0 authored and ljharb committed Sep 24, 2023
1 parent aef6e7d commit ca30f77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [Refactor] `propTypes`: extract type params to var ([#3634][] @HenryBrown0)
* [Refactor] [`boolean-prop-naming`]: invert if statement ([#3634][] @HenryBrown0)
* [Refactor] [`function-component-definition`]: exit early if no type params ([#3634][] @HenryBrown0)
* [Refactor] [`jsx-props-no-multi-spaces`]: extract type parameters to var ([#3634][] @HenryBrown0)

[#3638]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3638
[#3634]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3634
Expand Down
8 changes: 6 additions & 2 deletions lib/rules/jsx-props-no-multi-spaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ module.exports = {
}

function containsGenericType(node) {
const containsTypeParams = typeof node.typeParameters !== 'undefined';
return containsTypeParams && node.typeParameters.type === 'TSTypeParameterInstantiation';
const nodeTypeParams = node.typeParameters;
if (typeof nodeTypeParams === 'undefined') {
return false;
}

return nodeTypeParams.type === 'TSTypeParameterInstantiation';

Check warning on line 106 in lib/rules/jsx-props-no-multi-spaces.js

View check run for this annotation

Codecov / codecov/patch

lib/rules/jsx-props-no-multi-spaces.js#L106

Added line #L106 was not covered by tests
}

function getGenericNode(node) {
Expand Down

0 comments on commit ca30f77

Please sign in to comment.