Registry / devops / i18n-lint-plugin

i18n-lint-plugin

JSON →
library0.2.3jsnpmunverified

A webpack plugin for linting hardcoded Chinese characters (i18n violations) in JavaScript, Vue, JSON, and other files. Version 0.2.3 is the latest stable release. The plugin runs as a webpack plugin or via CLI, and supports configurable rules via .i18nlintrc.js. It integrates with husky for pre-commit hooks. No known alternatives exist for this specific use case.

npm install i18n-lint-plugin
INSTALL
IMPORT
SIG · I18N-LINT-PLUGIN
I
i18n-lint-plugin
devopsjavascriptv0.2.3
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.

I18nLintPlugin
const I18nLintPlugin = require('i18n-lint-plugin')
import I18nLintPlugin from 'i18n-lint-plugin'
Package does not provide ESM exports; use CommonJS require as shown. Node >=8 is required.
i18n-lint
npx i18n-lint
i18n-lint (without npx if not installed globally)
CLI command is available after install; run via npx or add to scripts in package.json
.i18nlintrc.js
module.exports = { /* config */ }
export default { /* config */ }
Configuration file uses CommonJS module.exports; ESM export is not supported.

Install plugin, add to webpack config, create .i18nlintrc.js, and run via webpack or CLI.

// Step 1: Install // npm install i18n-lint-plugin --save-dev // Step 2: In webpack config (e.g., vue.config.js) const I18nLintPlugin = require('i18n-lint-plugin'); module.exports = { configureWebpack: { plugins: [ new I18nLintPlugin() ] } }; // Step 3: Create .i18nlintrc.js in project root module.exports = { report: 'warnings', rules: [{ glob: 'src/**/*.{js,vue}', test: /[\u4e00-\u9fa5]+/ }], ignores: 'src/views/components/**/*', staticPath: 'dataview/*.json', lintSuffix: ['js', 'vue', 'coffee', 'ts'], ignoreComment: true, ignoreConsole: true }; // Step 4: Run via webpack build or CLI: npx i18n-lint
Debug
Known issues
breakingPlugin only works with webpack; cannot be used standalone as a generic linter.
fix
Use the CLI command (i18n-lint) for CI or non-webpack projects.
affects: all
deprecatedHusky v4 configuration format shown in README is deprecated; newer versions use .husky directory.
fix
Use husky v4 or follow updated documentation for husky v5+.
affects: >=5.0.0 of husky
gotchaThe glob 'src/**/*.{js,vue}' may not catch all file types unless lintSuffix includes them.
fix
Ensure lintSuffix includes all relevant extensions (e.g., 'ts' for TypeScript).
affects: all
breakingtest regex /[\u4e00-\u9fa5]+/ only matches Chinese characters; not suitable for other languages.
fix
Customize the test regex or function for your specific i18n needs.
affects: all
gotchaignoreComment and ignoreConsole options may not work perfectly with all comment types or console.log variations.
fix
Manually verify false positives; consider custom test functions.
affects: all
Errors
Common errors & fixes
Cannot find module 'i18n-lint-plugin'
Package not installed or not in node_modules
fix
Run 'npm install i18n-lint-plugin --save-dev'
TypeError: I18nLintPlugin is not a constructor
Using incorrect import method (e.g., ESM import instead of require)
fix
Use const I18nLintPlugin = require('i18n-lint-plugin');
Configuration file .i18nlintrc.js not found
File missing or not in project root directory
fix
Create .i18nlintrc.js in the same directory as your package.json
No rules matching the provided glob pattern
Glob pattern in .i18nlintrc.js does not match any files
fix
Verify glob patterns; use correct path relative to project root
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
webpackrequiredPlugin requires webpack to be installed as it hooks into webpack's compilation process
huskyoptionalRecommended for git hooks integration, but not strictly required for plugin operation
Agent activity
4 hits · last 30 days
node
4
Resources
i18n-lint-plugin — npm install i18n-lint-plugin · libregistry