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-statementsVerified import paths — ran on the pinned version, not inferred.
Shows minimal ESLint configuration to enable the plugin and its recommended rules, including the environment to avoid no-undef errors for control components.
Set rule: "react/jsx-no-undef": [2, { "allowGlobals": true }]Set "no-undef": 0 and enable "jsx-control-statements/jsx-jcs-no-undef": 1
If using alternative config, verify the env is no longer needed manually.
Ensure you follow the new JSON configuration with plugins array.
Run npm install eslint-plugin-jsx-control-statements and add "plugins": ["jsx-control-statements"]
Enable the environment: "env": { "jsx-control-statements/jsx-control-statements": true } OR set "react/jsx-no-undef": [2, { "allowGlobals": true }]Add "parserOptions": { "ecmaFeatures": { "jsx": true } } or use babel-eslint parser.