edvardchen / eslint-plugin-i18next

ESLint plugin for i18next. Prevent to display non-localized text for users
MIT License
137 stars 39 forks source link

how to catch untranslated object property values #131

Open ryancwalsh opened 2 months ago

ryancwalsh commented 2 months ago

Thanks for this library. It looks like it will be super useful.

Currently, my rule in my .eslintrc.json is:

"i18next/no-literal-string": [
            "warn",
            {
                "jsx-attributes": {
                    "include": ["alt", "placeholder", "aria-label", "title", "subtitle"]
                },
                "message": "Use i18n translation keys instead of literal strings.",
                "mode": "jsx-only",
                "object-properties": {
                    "include": ["title", "body", "label"]
                }
            }
        ]

It's working well in some cases like:

image

But I was hoping it would also flag a warning for objects like this:

const dialogProps: DialogProps = {
  type: 'icon',
  title: 'Card Verification failed',
  body: 'Something went wrong. Please recheck your card details and try again.',
  dismissButton: {
    label: 'Dismiss',
  },
  dismiss: unshift,
};

No warnings:

image

What changes can I make to get it to catch strings like those?

Thank you so much for your help!

edvardchen commented 2 months ago

Use mode: 'all' instead. You might be surprised what it captures