Skip to content

Commit f9ee7ed

Browse files
committed
[Refactor] jsx-key: use isJSX util function instead of shouldCheckNode
1 parent f2869fd commit f9ee7ed

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/rules/jsx-key.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const pragmaUtil = require('../util/pragma');
1313
const report = require('../util/report');
1414
const astUtil = require('../util/ast');
1515
const getText = require('../util/eslint').getText;
16+
const isJSX = require('../util/jsx').isJSX;
1617

1718
// ------------------------------------------------------------------------------
1819
// Rule Definition
@@ -159,18 +160,17 @@ module.exports = {
159160
*/
160161
function checkArrowFunctionWithJSX(node) {
161162
const isArrFn = node && node.type === 'ArrowFunctionExpression';
162-
const shouldCheckNode = (n) => n && (n.type === 'JSXElement' || n.type === 'JSXFragment');
163-
if (isArrFn && shouldCheckNode(node.body)) {
163+
if (isArrFn && isJSX(node.body)) {
164164
checkIteratorElement(node.body);
165165
}
166166
if (node.body.type === 'ConditionalExpression') {
167-
if (shouldCheckNode(node.body.consequent)) {
167+
if (isJSX(node.body.consequent)) {
168168
checkIteratorElement(node.body.consequent);
169169
}
170-
if (shouldCheckNode(node.body.alternate)) {
170+
if (isJSX(node.body.alternate)) {
171171
checkIteratorElement(node.body.alternate);
172172
}
173-
} else if (node.body.type === 'LogicalExpression' && shouldCheckNode(node.body.right)) {
173+
} else if (node.body.type === 'LogicalExpression' && isJSX(node.body.right)) {
174174
checkIteratorElement(node.body.right);
175175
}
176176
}

0 commit comments

Comments
 (0)