eslint-plugin-format-message
raw JSON → 6.2.4 verified Sat Apr 25 auth: no javascript maintenance
ESLint plugin providing i18n-specific lint rules for format-message, an ICU Message Format internationalization library. Version 6.2.4 is the current stable release (last updated 2020). It includes 8 rules: literal-pattern, literal-locale, no-identical-translation, no-invalid-pattern, no-invalid-translation, no-missing-params, no-missing-translation, and translation-match-params. Requires eslint >=2.0.0. Key differentiator: integrates compile-time checks for format-message patterns, translations, and parameter usage, preventing runtime errors in i18n workflows.
Common errors
error Error: Failed to load plugin 'format-message' declared in '...' ↓
cause ESLint cannot find the plugin module; likely not installed or not in node_modules.
fix
Run 'npm install eslint-plugin-format-message --save-dev' and ensure the package is in your project's node_modules.
error Definition for rule 'format-message/no-missing-params' was not found ↓
cause Plugin not enabled in the ESLint configuration or misspelled rule name.
fix
Add '"plugins": ["format-message"]' to your ESLint config and verify rule names are correct.
error Cannot find module 'format-message' from '...' ↓
cause format-message (the main library) is not installed; plugin rules may reference it.
fix
Install format-message: 'npm install format-message' or ensure it's a peer dependency.
error Expected a pattern but found '...' ↓
cause Invalid ICU Message Format pattern used in a formatMessage call.
fix
Review the pattern syntax against ICU Message Format spec; fix curly braces and escaped characters.
Warnings
gotcha The settings object must have 'translations' pointing to a directory containing JSON translation files; missing files cause silent rule failures. ↓
fix Ensure the 'translations' path exists and contains valid JSON translation files.
breaking Rule 'no-missing-params' changed default behavior: 'allowNonLiteral' defaults to true in v6, but was false in v5. Update config explicitly if you want the old strict behavior. ↓
fix Set 'allowNonLiteral' to false in the rule options to restore v5 strict checks.
gotcha Plugins must be installed globally or locally; ESLint may not find them if not properly resolved with --resolve-plugins-relative-to flag. ↓
fix Install eslint-plugin-format-message in the project or use '--resolve-plugins-relative-to' with ESLint CLI.
breaking Support for ESLint <2.0.0 dropped in v6; plugin will not load with older ESLint versions. ↓
fix Upgrade ESLint to version 2.0.0 or later.
gotcha Translation matching rules expect a flat structure; nested keys in translations may not be recognized. ↓
fix Flatten the translation JSON files with separate keys for each message.
Install
npm install eslint-plugin-format-message yarn add eslint-plugin-format-message pnpm add eslint-plugin-format-message Imports
- default wrong
import 'eslint-plugin-format-message'correctmodule.exports = { plugins: ['format-message'] } - rules wrong
import { rules } from 'eslint-plugin-format-message'correctconst plugin = require('eslint-plugin-format-message'); const rules = plugin.rules; - configs wrong
import { configs } from 'eslint-plugin-format-message'correctconst plugin = require('eslint-plugin-format-message'); const recommended = plugin.configs.recommended;
Quickstart
// .eslintrc.json
{
"plugins": ["format-message"],
"rules": {
"format-message/literal-pattern": 1,
"format-message/literal-locale": 1,
"format-message/no-identical-translation": 1,
"format-message/no-invalid-pattern": 2,
"format-message/no-invalid-translation": 2,
"format-message/no-missing-params": [2, { "allowNonLiteral": true }],
"format-message/no-missing-translation": 1,
"format-message/translation-match-params": 2
},
"settings": {
"format-message": {
"sourceLocale": "en",
"translations": "./locales"
}
}
}