diff --git a/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js b/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js index e754edabc4341..62a451377f6e6 100644 --- a/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js +++ b/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js @@ -177,7 +177,7 @@ export default { if (init == null) { return false; } - while (init.type === 'TSAsExpression') { + while (init.type === 'TSAsExpression' || init.type === 'AsExpression') { init = init.expression; } // Detect primitive constants @@ -1525,7 +1525,7 @@ function getConstructionExpressionType(node) { } return null; case 'TypeCastExpression': - return getConstructionExpressionType(node.expression); + case 'AsExpression': case 'TSAsExpression': return getConstructionExpressionType(node.expression); } diff --git a/scripts/eslint-rules/safe-string-coercion.js b/scripts/eslint-rules/safe-string-coercion.js index 26a1098333e00..62a59d115fb66 100644 --- a/scripts/eslint-rules/safe-string-coercion.js +++ b/scripts/eslint-rules/safe-string-coercion.js @@ -291,7 +291,11 @@ function checkBinaryExpression(context, node) { (isEmptyLiteral(node.left) || isEmptyLiteral(node.right)) ) { let valueToTest = isEmptyLiteral(node.left) ? node.right : node.left; - if (valueToTest.type === 'TypeCastExpression' && valueToTest.expression) { + if ( + (valueToTest.type === 'TypeCastExpression' || + valueToTest.type === 'AsExpression') && + valueToTest.expression + ) { valueToTest = valueToTest.expression; }