Registry / testing / ilib-lint-react

ilib-lint-react

JSON →
library2.0.4jsnpmunverified

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.

npm install ilib-lint-react
INSTALL
IMPORT
SIG · ILIB-LINT-REACT
I
ilib-lint-react
testingjavascriptv2.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSParser
import { JSParser } from 'ilib-lint-react'
const JSParser = require('ilib-lint-react')
ESM-only since v2; commonjs require will fail.
JSXParser
import { JSXParser } from 'ilib-lint-react'
import { JSXParser } from 'ilib-lint-react/src/JSXParser'
Main export from package; no need for deep import.
banFormattedCompMessage
import { banFormattedCompMessage } from 'ilib-lint-react'
import { banFormattedCompMessage } from 'ilib-lint-react/dist/rules'
Rule names are camelCase exports from the main package.

Configuration for ilib-lint to use the react plugin with parsers for JSX and JS files.

// ilib-lint.config.json { "plugins": ["react"], "filetypes": { "jsx": { "parser": "jsx", "ruleset": ["react"] }, "js": { "parser": "js", "ruleset": ["javascript"] } }, "paths": { "src/**/*.jsx": "jsx", "src/**/*.js": "js" } } // Run lint: // npx ilib-lint -c ilib-lint.config.json
Debug
Known issues
breakingESM-only: This package is ESM-only and cannot be imported with CommonJS require().
fix
Use import syntax or dynamic import() in Node.js >=12.
affects: >=2.0.0
deprecatedFormattedCompMessage rule: The ban-formattedcompmessage rule is deprecated because the component is deprecated.
fix
Update your code to avoid using FormattedCompMessage; the rule will flag it.
affects: >=1.0.0
gotchaParser selection: Use JSXParser for .js files if they contain JSX; JSParser will fail.
fix
Set parser to 'jsx' in configuration for files that may contain JSX.
affects: >=2.0.0
gotchaNode.js version requirement: Requires Node.js >=12 (ESM support); older versions not supported.
fix
Upgrade Node.js to at least version 12.
affects: >=2.0.0
breakingPlugin configuration: Must be specified in ilib-lint config under 'plugins' array.
fix
Add "react" to the plugins list in your ilib-lint configuration.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: ilib_lint_react__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function
Attempting to import the package as default export, but only named exports are provided.
fix
Use named imports: import { JSParser } from 'ilib-lint-react';
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/ilib-lint-react/index.js from not supported
Using require() to import an ESM-only module.
fix
Switch to import syntax or use dynamic import().
Cannot find module 'ilib-lint-react/src/JSXParser'
Trying to deep-import a parser that is not exposed as a separate module.
fix
Import from the top-level package: import { JSXParser } from 'ilib-lint-react';
Rule 'ban-formattedcompmessage' is not defined in ruleset 'react'
The rule name is misspelled or the rule is not loaded because of config issue.
fix
Ensure plugin is in 'plugins' list and ruleset 'react' is used. The rule name is 'ban-formattedcompmessage'.
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies
ilib-commonrequiredProvides utilities used by ilib-lint plugins
ilib-lintrequiredCore linter framework that this plugin extends
Agent activity
4 hits · last 30 days
node
4
Resources
ilib-lint-react — npm install ilib-lint-react · libregistry