{"id":25750,"library":"ilib-lint-react","title":"ilib-lint-react","description":"An ilib-lint plugin for linting React files for internationalization (i18n) problems. Current stable version is 2.0.4, released as part of the ilib-mono monorepo. It provides parsers for JavaScript, JSX, TypeScript TSX, Flow, and properties files, along with rules like no-hard-coded-strings and no-nested-messages for react-intl. It is ESM-only, requires Node.js >=12, and is designed for integration with the ilib-lint framework. Key differentiators include deep i18n-aware linting for React apps, support for both JSX and TSX, and a plugin-based architecture.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/iLib-js/ilib-mono","tags":["javascript"],"install":[{"cmd":"npm install ilib-lint-react","lang":"bash","label":"npm"},{"cmd":"yarn add ilib-lint-react","lang":"bash","label":"yarn"},{"cmd":"pnpm add ilib-lint-react","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides utilities used by ilib-lint plugins","package":"ilib-common","optional":false},{"reason":"Core linter framework that this plugin extends","package":"ilib-lint","optional":false}],"imports":[{"note":"ESM-only since v2; commonjs require will fail.","wrong":"const JSParser = require('ilib-lint-react')","symbol":"JSParser","correct":"import { JSParser } from 'ilib-lint-react'"},{"note":"Main export from package; no need for deep import.","wrong":"import { JSXParser } from 'ilib-lint-react/src/JSXParser'","symbol":"JSXParser","correct":"import { JSXParser } from 'ilib-lint-react'"},{"note":"Rule names are camelCase exports from the main package.","wrong":"import { banFormattedCompMessage } from 'ilib-lint-react/dist/rules'","symbol":"banFormattedCompMessage","correct":"import { banFormattedCompMessage } from 'ilib-lint-react'"}],"quickstart":{"code":"// ilib-lint.config.json\n{\n  \"plugins\": [\"react\"],\n  \"filetypes\": {\n    \"jsx\": {\n      \"parser\": \"jsx\",\n      \"ruleset\": [\"react\"]\n    },\n    \"js\": {\n      \"parser\": \"js\",\n      \"ruleset\": [\"javascript\"]\n    }\n  },\n  \"paths\": {\n    \"src/**/*.jsx\": \"jsx\",\n    \"src/**/*.js\": \"js\"\n  }\n}\n\n// Run lint:\n// npx ilib-lint -c ilib-lint.config.json","lang":"json","description":"Configuration for ilib-lint to use the react plugin with parsers for JSX and JS files."},"warnings":[{"fix":"Use import syntax or dynamic import() in Node.js >=12.","message":"ESM-only: This package is ESM-only and cannot be imported with CommonJS require().","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update your code to avoid using FormattedCompMessage; the rule will flag it.","message":"FormattedCompMessage rule: The ban-formattedcompmessage rule is deprecated because the component is deprecated.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set parser to 'jsx' in configuration for files that may contain JSX.","message":"Parser selection: Use JSXParser for .js files if they contain JSX; JSParser will fail.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Upgrade Node.js to at least version 12.","message":"Node.js version requirement: Requires Node.js >=12 (ESM support); older versions not supported.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add \"react\" to the plugins list in your ilib-lint configuration.","message":"Plugin configuration: Must be specified in ilib-lint config under 'plugins' array.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use named imports: import { JSParser } from 'ilib-lint-react';","cause":"Attempting to import the package as default export, but only named exports are provided.","error":"TypeError: ilib_lint_react__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function"},{"fix":"Switch to import syntax or use dynamic import().","cause":"Using require() to import an ESM-only module.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/ilib-lint-react/index.js from not supported"},{"fix":"Import from the top-level package: import { JSXParser } from 'ilib-lint-react';","cause":"Trying to deep-import a parser that is not exposed as a separate module.","error":"Cannot find module 'ilib-lint-react/src/JSXParser'"},{"fix":"Ensure plugin is in 'plugins' list and ruleset 'react' is used. The rule name is 'ban-formattedcompmessage'.","cause":"The rule name is misspelled or the rule is not loaded because of config issue.","error":"Rule 'ban-formattedcompmessage' is not defined in ruleset 'react'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}