lingui / eslint-plugin

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

Rules name refinement #1

Open thekip opened 11 months ago

thekip commented 11 months ago

This issue for ongoing discussion for better name of the rules before it goes live.

Offer better naming for this rules, i don't really happy with what i'm came up.

vonovak commented 11 months ago

Hello! very exciting to have this eslint plugin!

I read the docs and TBH I'm not sure I understood what all the rules are about because the descriptions are sometimes quite short. It would be nice to explain in the readme (and also in the error messages), what the right approach is.

anyways, here are some suggestions for naming:

missing-lingui-transformation - no-raw-strings, no-unlocalized-strings, no-hardcoded-text

t-call-in-function - no-constant-translation, no-stale-translation

i18n-only-identifiers - prefer-named-constants, prefer-constants-in-interpolation, prefer-constants-in-text (as far as I can tell, t`hello ${func()}!` is valid but will be extracted as hello {0} which is harder to translate.

no-single-varibles-to-translate - missing-localizable-content, no-lonely-variable, nothing-to-translate

thank you! 🙂

thekip commented 11 months ago

@vonovak https://github.com/igorDolzh/eslint-plugin-lingui/pull/6 check the readme updates here

thekip commented 11 months ago

I like missing-lingui-transformation -> no-unlocalized-strings really self-explanatory!

i18n-only-identifiers - prefer-named-constants, prefer-constants-in-interpolation, prefer-constants-in-text

i think constant here is confusing

let userName = user.name;
t`Hello {userName}`;

I think identifier is more right word, or turn this upside-down no-expression-in-message

vonovak commented 11 months ago

no-expression-in-message sounds best imho! 👍

thekip commented 11 months ago

Created a PR, changed named of rules which are have no doubts.

Didn't change no-single-varibles-to-translate because not sure about the options

igorDolzh commented 11 months ago

@vonovak I like your suggestion for rule names

  1. missing-lingui-transformation -> no-unlocalized-strings 👍
  2. About this (t-call-in-function - no-constant-translation, no-stale-translation) I'm not sure, since this rule is for t only. Following the pattern no-${something} it could be renamed to no-t-outside-of-function something like that.
  3. About this i18n-only-identifiers. Something like no-complex-interpolation maybe? I believe it is better to avoid having prefer since the level of severity of the rule could be adjusted outside of the rule name.
  4. About no-single-varibles-to-translate at the moment, seems fine. If theoretically to consider to expand the rule to keep track that there is something to translate between Trans or t. I like missing-localisable-content or no-keys-without-text

What do you think?

thekip commented 11 months ago

@igorDolzh you a bit late 😃 We already merged renaming for

missing-lingui-transformation -> no-unlocalized-strings i18n-only-identifiers -> no-expression-in-message

it could be renamed to no-t-outside-of-function

I like this one. Sounds pretty self-describing.

About no-single-varibles-to-translate at the moment, seems fine. If theoretically to consider to expand the rule to keep track that there is something to translate between Trans or t. I like missing-localisable-content or no-keys-without-text

I like missing-localisable-content but this naming is not consistent with other no-{something} rules. Not sure it should... no-single-varibles-to-translate sounds quite well, actually. Because t`${one}${two}` is already something to translate (the translator could change the order in diffrent language if needed), and the rule should not complain here. So highlighting that there should not be a single variable is right thing.

vonovak commented 11 months ago

how about renaming no-single-variables-to-translate to no-single-variable-to-translate? The singular here sounds a little better imho.