eslint-plugin-jsx
raw JSON → 0.1.0 verified Sat Apr 25 auth: no javascript
eslint-plugin-jsx v0.1.0 provides JSX-specific linting rules for ESLint, designed specifically for the JSX-to-JS transpiler (not standard JSX like React). It includes rules such as jsx/uses-factory, jsx/factory-in-scope, jsx/mark-used-vars, and jsx/no-undef. This plugin is intended for non-standard JSX syntax and is not compatible with typical React JSX. It is based on eslint-plugin-react but targets a different semantics. The project appears to be a niche solution for a specific transpiler, with no recent updates, suggesting it is in maintenance or deprecated state.
Common errors
error ESLint: Failed to load plugin 'jsx': Cannot find module 'eslint-plugin-jsx' ↓
cause Plugin not installed or installed in wrong scope (global vs local).
fix
Ensure eslint-plugin-jsx is installed in the same location (global or local) as ESLint.
error Definition for rule 'jsx/uses-factory' was not found ↓
cause Plugin not listed in plugins array or misconfigured.
fix
Add "jsx" to the plugins array in .eslintrc.
error Parsing error: Unexpected token < ↓
cause ESLint parser does not support JSX by default.
fix
Use a parser that supports JSX (e.g., babel-eslint) or disable JSX parsing if not needed. Note that this plugin expects JSX-to-JS transpiler syntax.
Warnings
breaking This plugin is designed for JSX-to-JS transpiler, not standard React JSX; rules may not work as expected with React. ↓
fix Use eslint-plugin-react instead for React JSX.
gotcha Plugin must be installed in the same location as ESLint (global or local). Mismatch can cause plugin not found errors. ↓
fix Install both ESLint and this plugin in the same scope (both global or both local).
deprecated The package is based on an old version of eslint-plugin-react and may not be maintained. No recent updates. ↓
fix Consider migrating to eslint-plugin-react for active development.
Install
npm install eslint-plugin-jsx yarn add eslint-plugin-jsx pnpm add eslint-plugin-jsx Imports
- plugin (via eslint config) wrong
import plugin from 'eslint-plugin-jsx' (not a regular import)correct// In .eslintrc: { "plugins": ["jsx"] } - jsx/uses-factory wrong
Using require('eslint-plugin-jsx').rules['uses-factory'] (should be configured in ESLint config)correct// In .eslintrc: { "rules": { "jsx/uses-factory": [1, {"pragma": "JSX"}] } } - jsx/factory-in-scope wrong
Directly calling the rule function (ESLint handles registration)correct// In .eslintrc: { "rules": { "jsx/factory-in-scope": [1, {"pragma": "JSX"}] } }
Quickstart
// Install globally or locally alongside ESLint
// .eslintrc.json
{
"plugins": ["jsx"],
"rules": {
"jsx/uses-factory": [1, {"pragma": "JSX"}],
"jsx/factory-in-scope": [1, {"pragma": "JSX"}],
"jsx/mark-used-vars": 1,
"jsx/no-undef": 1
}
}
// Example JSX file (for JSX-to-JS transpiler)
// Note: This is not standard React JSX
var el = <div id="foo">text</div>;