To prevent hardcoding content and to enforce usage of appropriate i18n keys
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-no-hardcoding
:
$ npm install eslint-plugin-no-hardcoding --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-no-hardcoding
globally.
Add @zohodesk/no-hardcoding
to the plugins section of your .eslintrc
configuration file.
{
"plugins": ["@zohodesk/no-hardcoding"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"@zohodesk/no-hardcoding/no-hardcoding": 2,
"@zohodesk/no-hardcoding/use-getI18NValue-method-appropriately": 2
}
}
Note: For the working of no-hardcoding rule of this plugin a properties file of name noHardcodingRuleExcludes.properties should be present in the location build/eslint in the root dirctory of the project.
Note: For the working of use-getI18NValue-method-appropriately rule of this plugin a properties file of name getI18NValueEslintRuleExcludes.properties should be present in the location build/eslint in the root dirctory of the project.
- @zohodesk/no-hardcoding/no-hardcoding,
- @zohodesk/no-hardcoding/use-getI18NValue-method-appropriately