opral / inlang-sherlock

Issue tracker for Sherlock
https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension
2 stars 0 forks source link

VSCode warning: "The message ID 'myNamespace:translationKey' is not a valid javascript identifier" #50

Closed billomore closed 1 month ago

billomore commented 1 month ago

Hi, thanks for the great extension!

Just one strange quirk: when I enable the extension, VSCode starts complaining on each instance of the t function call; it says "[myNamespace:translationKey] - The message ID 'myNamespace:translationKey' is not a valid javascript identifier". Sample code looks like this:

import { useTranslation } from 'react-i18next';

const MyComponent = () => {
  const { t } = useTranslation('myNamespace');
  const translatedString = t('translationKey'); // <--- warning here
}

The code works fine, all the other extension functionality too - it adds the translation to the t call, shows all the messages in the sidebar - flawless. But now my translation-heavy components are all yellow with ugly numbers :) When I disable the extension the error disappears, but it's very, very nice and I'm battling the OCD to use it :D

samuelstroschein commented 1 month ago

The message ID 'myNamespace:translationKey' is not a valid javascript identifier".

Remove the valid js identifier lint rule from your settings file https://inlang.com/m/teldgniy/messageLintRule-inlang-validJsIdentifier

samuelstroschein commented 1 month ago

i removed the lint rule from the default installed lint rules https://github.com/opral/monorepo/commit/a61b4d914417bc40e057cb4378723f6a1b0cb122

billomore commented 1 month ago

thank you :)