Skip to content

Commit fc06f85

Browse files
brettdhljharb
authored andcommitted
Use find instead of filter
1 parent 3ddfd1c commit fc06f85

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/rules/no-typos.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,14 @@ module.exports = {
151151
} else if (node.source && node.source.value === 'react') { // import { PropTypes } from "react"
152152
reactPackageName = node.specifiers[0].local.name;
153153

154-
propTypesPackageName = node.specifiers.length >= 1 ? (
155-
node.specifiers
156-
.filter(specifier => specifier.imported && specifier.imported.name === 'PropTypes')
157-
.map(specifier => specifier.local.name)
158-
)[0] : null;
154+
if (node.specifiers.length >= 1) {
155+
const propTypesSpecifier = node.specifiers.find(specifier => (
156+
specifier.imported && specifier.imported.name === 'PropTypes'
157+
));
158+
if (propTypesSpecifier) {
159+
propTypesPackageName = propTypesSpecifier.local.name;
160+
}
161+
}
159162
}
160163
},
161164

0 commit comments

Comments
 (0)