lingui / eslint-plugin

Set of ESLint rules for Lingui projects
https://www.npmjs.com/package/eslint-plugin-lingui
MIT License
21 stars 7 forks source link

Confusing results of `lingui/no-unlocalized-strings` #30

Open mustafashabib opened 9 months ago

mustafashabib commented 9 months ago

Hi there

I am seeing a bit of unexpected behavior and not sure if it's something in my configuration or a misunderstanding on my part. My expectation would be that these would all be flagged by the linter, but it isn't what I'm seeing.

To reproduce, set the configuration for the lingui/no-unlocalized-strings rule to error and lint this example function:

export const example = ()  => {
    const noLinterError = 'EEEE';
    const secondNoLinterError = "'Tomorrow'";
    const linterError = "'Linter' gets marked as an error";
    const secondLinterError = 'Tomorrow';

    console.log(noLinterError, linterError, secondNoLinterError, secondLinterError);
};

I'm confused why the first variable, noLinterError and secondNoLinterError are not linted as an error, but linterError and secondLinterError are, which is what I would expect for all four of them. It seems to do with the pattern within the string, and whether it's a single word or repeating characters, and whether the single word is quoted or not.

I'm on the 0.2.2 release of the plugin.

Thanks!

timofei-iatsenko commented 9 months ago

I think it's related to the pattern on the https://github.com/lingui/eslint-plugin/blob/main/src/rules/no-unlocalized-strings.ts#L76 line as well as on the line 87. We can ask original author @igorDolzh what was the original idea behind it.

mustafashabib commented 8 months ago

Thanks, and thanks for the work on this @igorDolzh -- any thoughts on why it behaves this way and whether you think it ought to change?