@godaddy/react-intl/id-missing not alerting if id is missing from some (not all) files
henrymunro opened this issue · 1 comments
Currently the rule @godaddy/react-intl/id-missing
raises an error if an id is missing from ALL localeFiles
. In our project, we're attempting to use this plug in to validate that we are not missing an id from ANY localeFiles
.
Am I correct in the above? If so, is our use case something you want to support? I might be able to have a bash at a PR if that's the case.
Our config
const fs = require('fs');
const path = require('path');
const TRANSLATIONS_DIRECTORY = 'translations/formattedTranslations';
const translationsFilePaths = fs
.readdirSync(path.join(__dirname, TRANSLATIONS_DIRECTORY))
.map(filename => path.join(TRANSLATIONS_DIRECTORY, filename));
module.exports = {
root: false,
extends: [],
plugins: ['@godaddy/react-intl'],
rules: {
'@godaddy/react-intl/id-missing': 'error',
},
env: {
browser: true,
},
settings: {
localeFiles: translationsFilePaths, // A list with multiple locale files
projectRoot: __dirname,
},
};
The idea for this eslint plugin it to vet ids in your React code against primary translation files (for example, just en
files). Translation could be split up amongst various files, such as translation per page or per component. In this case, it would be expected to that ids would not be found in ALL locale file.
Use this plugin to lint your React code, use https://github.com/godaddy/eslint-plugin-i18n-json to lint your JSON locale files. The i18n-json/identical-keys
sounds like what you may be looking for.