Skip to content

Commit

Permalink
Allow nested expressions in noGoogleTranslateCrashingSyntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Aug 7, 2024
1 parent 4f7ce5f commit 86adbe3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const noGoogleTranslateCrashingSyntax = [
{
selector:
'JSXElement > JSXExpressionContainer > LogicalExpression[operator="&&"]' +
' > JSXFragment > .children:not(JSXElement, JSXText[value=/^\\s+$/])',
' > JSXFragment > .children:not(JSXElement, JSXText[value=/^\\s+$/], JSXExpressionContainer)',
message:
'[b] Conditional plain text nodes could break React if used with Google Translate. Wrap text into an element.',
},
Expand Down Expand Up @@ -47,7 +47,7 @@ const noGoogleTranslateCrashingSyntax = [
{
selector:
'JSXElement > JSXExpressionContainer > ConditionalExpression' +
' > JSXFragment > .children:not(JSXElement, JSXText[value=/^\\s+$/])',
' > JSXFragment > .children:not(JSXElement, JSXText[value=/^\\s+$/], JSXExpressionContainer)',
message:
'[f] Conditional plain text nodes could break React if used with Google Translate. Wrap text into an element.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ export function TransactionHistory() {
'Some transactions are currently in a pending state.',
)}
</AlertBox>
{/* eslint-disable no-restricted-syntax */}
{!!pendingTransactionComponents.length && (
<Box gap="medium" data-testid="pending-txs" margin={{ top: 'small' }}>
{pendingTransactionComponents}
</Box>
)}
{/* eslint-enable no-restricted-syntax */}
</>
)}
<Heading level="2">{t('account.summary.activity', 'Activity')}</Heading>
Expand Down
4 changes: 4 additions & 0 deletions src/utils/eslint-test-noGoogleTranslateCrashingSyntax.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const textBeforeAndOperator = (
{!condition && <span>good</span>}
{!condition && (
<>
{/* good */}
{!condition && <span>good</span>}
<span>good</span>
<span>good</span>
</>
Expand Down Expand Up @@ -167,6 +169,8 @@ const textInTernaryOperator = (
{!condition ? <span>{good}</span> : <span>{good}</span>}
{!condition ? (
<>
{/* good */}
{!condition && <span>good</span>}
<span>good</span>
<span>good</span>
</>
Expand Down

0 comments on commit 86adbe3

Please sign in to comment.