@blaze-money/eslint-plugin-spark
v1.0.1
Published
ESLint plugin for Spark project with custom rules
Readme
@blaze-money/eslint-plugin-spark
ESLint plugin for the Spark project with custom rules to enforce coding standards.
Rules
matching-email-translation-structure
This rule ensures that all email translation files have the same structure as the English translation file (en.messages.ts). It checks for missing keys and extra keys in non-English translation files.
Usage
The rule is automatically enabled in the Spark ESLint configuration. It will run when you run yarn lint or when you commit changes (via the pre-commit hook).
You can also run the rule manually with:
yarn email:check-translationsHow it works
The rule:
- Identifies all
.messages.tsfiles in the email translation directories - Skips the English translation file (
en.messages.ts) as it's the reference - Compares each non-English translation file with the English one
- Reports any missing keys or extra keys
Fixing issues
When the rule reports missing keys, you should add those keys to the translation file with appropriate translations. When it reports extra keys, you should either:
- Add those keys to the English translation file if they should be there
- Remove them from the non-English translation file if they're no longer needed
Adding new translations
When adding new email templates or messages:
- Add the new keys to
en.messages.tsfirst - Run
yarn email:check-translationsto identify which translation files need to be updated - Add the missing keys to all non-English translation files
Development
To add new rules to this plugin:
- Create a new rule file in the
rulesdirectory - Add the rule to the
index.jsfile - Update the ESLint configuration to enable the rule
