opral / inlang-message-sdk

0 stars 0 forks source link

lint rule: "a message should only be used once" #7

Open samuelstroschein opened 3 months ago

samuelstroschein commented 3 months ago

Discussed in https://github.com/opral/monorepo/discussions/2253

Originally posted by **samuelstroschein** February 18, 2024 ## Problem Referencing the same message in multiple places leads to a broken message. No guarantee exists that a message with the content like "learn more" won't be changed by someone to "learn more about unlimited inboxes". If the message is rendering all "learn more" references, the example website below will break at 2 and 3. ![CleanShot 2024-02-18 at 14 08 36@2x](https://github.com/opral/monorepo/assets/35429197/60becb79-79c4-4905-8c30-c2091ff23ff8) ![CleanShot 2024-02-18 at 14 08 36@2x](https://github.com/opral/monorepo/assets/35429197/d85b4635-ceba-497d-98f7-9d3ec331eba5) ## Proposal A lint rule that detects if a message id is used multiple times in source code. ```tsx // unlimited inboxes

{m.elephant_big_tree()}

// manage team members // 💥 error m.elephant is used multiple times

{m.elephant_big_tree()}

// spam report // 💥 error m.elephant is used multiple times

{m.blue_box({ title: m.elephant_big_tree() })}

``` (Creating new messages is cheaper than _trying_ to manage shared messages.) ## Additional information - emerged in a conversation on discord https://discord.com/channels/897438559458430986/1206732202839253052/1208848809304530974 - requires https://github.com/opral/monorepo/discussions/2126
linear[bot] commented 3 months ago

MESDK-42 lint rule: "a message should only be used once"