{"id":19764,"library":"eslint-plugin-formatjs","title":"eslint-plugin-formatjs","description":"ESLint plugin for FormatJS that enforces best practices for internationalized messages. Current stable version is 6.4.6, with regular releases tied to the FormatJS monorepo. It provides rules for validating ICU message syntax, enforcing message extraction patterns, preventing missing descriptions, and ensuring consistent translation keys. Differentiates from generic i18n ESLint plugins by deep integration with intl-messageformat and react-intl, supporting both flat and nested message structures, and offering auto-fix for many rules. Requires ESLint 9 or 10.","status":"active","version":"6.4.6","language":"javascript","source_language":"en","source_url":"https://github.com/formatjs/formatjs","tags":["javascript","eslint","eslintplugin","formatjs","i18n","typescript"],"install":[{"cmd":"npm install eslint-plugin-formatjs","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-formatjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-formatjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: ESLint 9 or 10 required for plugin to function","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v6; CommonJS require will fail.","wrong":"const eslintPluginFormatjs = require('eslint-plugin-formatjs')","symbol":"default","correct":"import eslintPluginFormatjs from 'eslint-plugin-formatjs'"},{"note":"All rules are available as named exports for custom configurations.","wrong":null,"symbol":"rules","correct":"import { rules } from 'eslint-plugin-formatjs'"},{"note":"Exposes 'recommended' and 'flat' configs for easy setup.","symbol":"configs","correct":"import { configs } from 'eslint-plugin-formatjs'"}],"quickstart":{"code":"import eslintPluginFormatjs from 'eslint-plugin-formatjs';\nexport default [\n  {\n    plugins: {\n      formatjs: eslintPluginFormatjs\n    },\n    rules: {\n      'formatjs/enforce-description': 'error',\n      'formatjs/no-literal-string-in-jsx': 'warn'\n    }\n  }\n];","lang":"typescript","description":"ESLint flat config setup with two FormatJS rules enabled."},"warnings":[{"fix":"Upgrade ESLint to 9.x or 10.x, or use eslint-plugin-formatjs@5.x.","message":"Version 6 dropped support for ESLint 8; requires ESLint 9 or 10.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Use import syntax or dynamic import() in CommonJS projects.","message":"The plugin is ESM-only since v6; using require() will throw an error.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Migrate to ESLint flat config using configs['flat'].","message":"The 'flat' config is now the default; the old .eslintrc format is deprecated for this plugin.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Install @formatjs/ts-transformer as a dev dependency for TypeScript projects.","message":"Some rules require @formatjs/ts-transformer to be installed when using TypeScript.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Ensure your build pipeline includes babel-plugin-formatjs or @formatjs/unplugin.","message":"The rule 'formatjs/no-literal-string-in-jsx' only works with react-intl; requires babel-plugin-formatjs or equivalent.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install eslint-plugin-formatjs --save-dev","cause":"Plugin not installed or ESLint cannot resolve it.","error":"Error: Failed to load plugin 'formatjs': Cannot find module 'eslint-plugin-formatjs'"},{"fix":"Change to import statement: import eslintPluginFormatjs from 'eslint-plugin-formatjs'","cause":"Using require() on an ESM-only module.","error":"TypeError: (0 , _eslintPluginFormatjs.default) is not a function"},{"fix":"Check node_modules for duplicate installations and deduplicate with npm dedupe.","cause":"Multiple versions of the plugin installed or name collision.","error":"ESLint couldn't determine the plugin 'formatjs' uniquely. This may be caused by a plugin conflict."},{"fix":"Set parserOptions: { sourceType: 'module' } in ESLint config.","cause":"ESLint parser does not support ES modules; need to configure parserOptions.","error":"Parsing error: The keyword 'import' is reserved"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}