Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when JSX key attribute is "SyntaxKind.ConditionalExpression" #1092

Open
trevorharwell opened this issue Dec 3, 2024 · 0 comments
Open

Comments

@trevorharwell
Copy link

🐛 Bug Report

If you specify the key attribute as a conditional key={condition ? "key1" : "key2"}, no warning is logged.

To Reproduce

<Trans i18nKey={someCondition ? "key1" : "key"} />

Expected behavior

I don't expect that the values of that condition would be resolved but just that a warning would be logged. I have "failOnWarnings" set to true and I would want to make sure no one on my team ever did this.

FYI I am happy to submit a PR for this. Starting with an issue per the contribution guidelines.

Also, if you do want me to submit a PR, would you prefer I add SyntaxKind.ConditionalExpression here https://github.com/i18next/i18next-parser/blob/master/src/lexers/jsx-lexer.js#L82 or change that to log a warning if any value is not a SyntaxKing.StringLiteral?

Your Environment

  • runtime version: node 22
  • i18next version: 9.0.2
  • os: Mac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant