Registry / testing / eslint-plugin-jsx-control-statements

eslint-plugin-jsx-control-statements

JSON →
library3.0.0jsnpmunverified

ESLint plugin providing linting rules for JSX control statement components like <If>, <Choose>, <For>, <When>, <Otherwise>, and <With>. Current stable version is 3.0.0. Designed for use with eslint-plugin-react, it helps enforce best practices when using conditional and loop JSX syntax. The plugin comes with a set of rules to catch common mistakes such as missing required attributes, incorrect nesting, and it also provides an environment to declare these components as globals. Use the recommended config or manually enable rules along with the jsx-control-statements environment. Requires ESLint >=6.0.0.

npm install eslint-plugin-jsx-control-statements
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JSX-
E
eslint-plugin-jsx-control-statements
testingjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

plugin
// In .eslintrc: { "plugins": ["jsx-control-statements"] }
// Do not import the plugin directly in code; it's an ESLint plugin loaded via config.
The plugin is not imported in source files; it's configured in ESLint's config file.
recommended config
// .eslintrc: { "extends": ["plugin:jsx-control-statements/recommended"] }
// Wrong: using "extends": ["eslint:recommended", "plugin:jsx-control-statements/recommended"] is fine, but forgetting the plugin entry breaks.
The recommended config requires both 'plugins' and 'extends' entries.
env
// .eslintrc: { "env": { "jsx-control-statements/jsx-control-statements": true } }
// Wrong: using env: { "jsx-control-statements": true } without the full path.
The environment is namespaced under the plugin name.

Shows minimal ESLint configuration to enable the plugin and its recommended rules, including the environment to avoid no-undef errors for control components.

// Install: // npm install eslint eslint-plugin-react eslint-plugin-jsx-control-statements --save-dev // .eslintrc.json: { "plugins": ["react", "jsx-control-statements"], "extends": ["plugin:react/recommended", "plugin:jsx-control-statements/recommended"], "rules": { "react/jsx-no-undef": [2, { "allowGlobals": true }] }, "env": { "jsx-control-statements/jsx-control-statements": true } } // Now lint a file with <If condition={true}><span>Hello</span></If>
Debug
Known issues
gotchaAfter eslint-plugin-react v7.0.0, the rule react/jsx-no-undef does not check globals by default. You must enable it with allowGlobals: true.
fix
Set rule: "react/jsx-no-undef": [2, { "allowGlobals": true }]
affects: >=7.0.0
gotchaThe no-undef ESLint built-in rule conflicts with jsx-jcs-no-undef. You must disable no-undef if using jsx-jcs-no-undef.
fix
Set "no-undef": 0 and enable "jsx-control-statements/jsx-jcs-no-undef": 1
affects: >=1.0.0
breakingVersion 3.0.0 changed how the recommended config works. It now sets the environment automatically.
fix
If using alternative config, verify the env is no longer needed manually.
affects: >=3.0.0
deprecatedThe deprecated eslintConfig format from previous major versions no longer works. Use the plugin format.
fix
Ensure you follow the new JSON configuration with plugins array.
affects: >=3.0.0
Errors
Common errors & fixes
Definition for rule 'jsx-control-statements/jsx-if-require-condition' was not found.
The plugin is not installed or not listed in the plugins array.
fix
Run npm install eslint-plugin-jsx-control-statements and add "plugins": ["jsx-control-statements"]
'If' is not defined no-undef
The no-undef rule is enabled but globals are not declared.
fix
Enable the environment: "env": { "jsx-control-statements/jsx-control-statements": true } OR set "react/jsx-no-undef": [2, { "allowGlobals": true }]
Parsing error: Unexpected token <
ESLint is not configured for JSX parsing.
fix
Add "parserOptions": { "ecmaFeatures": { "jsx": true } } or use babel-eslint parser.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency: plugin requires ESLint >=6.0.0
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-jsx-control-statements — npm install eslint-plugin-jsx-control-statements · libregistry