Closed timofei-iatsenko closed 2 weeks ago
@thekip I'd suggest making making recommended settings first e.g. plugin:lingui/recommended
.
Most of the rules doesn't check that components are actually belongs to Lingui. It just checking it by name such as Trans and t. It means if you have your own Trans component it will be also subject of validation despite it imported from diffrent package. The rules doesn't support renamed symbols. If you have import Trans as $Trans from "@lingui/macro" rules would not be applied to $Trans usages
I dug a bit into eslint plugins architecture, and it seems for us implementing such mechanism will bring more harm than help. I'm pretty satisfied with how that works now, just matching macros by their's name.
Rules do understand only few macros, such as t but don't understand defineMessage and msg. They also don't understand any other usage of the rule than TaggedTemplateExpression. Means calls such as t({message: "Hello!"}) would be ignored or even fail.
I added support for different lingui signatures to all rules.
Currently, the rules are "happy path" only. It means it doesn't cover every edge case. In this issue i will start collecting problems which I noticed (not a complete list though):
Trans
andt
. It means if you have your ownTrans
component it will be also subject of validation despite it imported from diffrent package.import Trans as $Trans from "@lingui/macro"
rules would not be applied to$Trans
usagest
but don't understanddefineMessage
andmsg
. They also don't understand any other usage of the rule thanTaggedTemplateExpression
. Means calls such ast({message: "Hello!"})
would be ignored or even fail.