Skip to content

Commit 2aa5b4d

Browse files
committed
Support Flow as expressions in ESLint rules
1 parent 97047a8 commit 2aa5b4d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export default {
177177
if (init == null) {
178178
return false;
179179
}
180-
while (init.type === 'TSAsExpression') {
180+
while (init.type === 'TSAsExpression' || init.type === 'AsExpression') {
181181
init = init.expression;
182182
}
183183
// Detect primitive constants
@@ -1520,7 +1520,7 @@ function getConstructionExpressionType(node) {
15201520
}
15211521
return null;
15221522
case 'TypeCastExpression':
1523-
return getConstructionExpressionType(node.expression);
1523+
case 'AsExpression':
15241524
case 'TSAsExpression':
15251525
return getConstructionExpressionType(node.expression);
15261526
}

scripts/eslint-rules/safe-string-coercion.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ function checkBinaryExpression(context, node) {
291291
(isEmptyLiteral(node.left) || isEmptyLiteral(node.right))
292292
) {
293293
let valueToTest = isEmptyLiteral(node.left) ? node.right : node.left;
294-
if (valueToTest.type === 'TypeCastExpression' && valueToTest.expression) {
294+
if (
295+
(valueToTest.type === 'TypeCastExpression' ||
296+
valueToTest.type === 'AsExpression') &&
297+
valueToTest.expression
298+
) {
295299
valueToTest = valueToTest.expression;
296300
}
297301

0 commit comments

Comments
 (0)