mxmvshnvsk / i18n-unused

The static analyze tool for finding, marking and removing unused and missing i18n translations in your JavaScript project
MIT License
127 stars 21 forks source link

Can't find translation keys in the return block of a React component #38

Closed FinnWinchester closed 1 year ago

FinnWinchester commented 1 year ago

The tool finds the translation keys within the body of a function component but not in its return statement.

In the example below, the tool finds myKey but not otherKey. It detects otherKey as unused...

function MyComponent() {
   const [t] = useTranslation();
   const text = t('myKey');

   return (
      <div>{t('otherKey')}</div>
   );
}
FinnWinchester commented 1 year ago

Turns out the regexp was not finding it!