
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
eslint-plugin-react-x
Advanced tools
Core rules (renderer-agnostic, compatible with x-platform).
[!NOTE] This plugin is already included in
@eslint-react/eslint-plugin
. You don't need to install it separately if you are using@eslint-react/eslint-plugin
.
# npm
npm install --save-dev eslint-plugin-react-x
Add the plugin to your eslint.config.js
:
// @ts-check
import js from "@eslint/js";
import reactx from "eslint-plugin-react-x";
export default [
js.configs.recommended,
{
files: ["**/*.{ts,tsx}"],
plugins: [
"react-x": reactx,
rules: {
// react-x recommended rules
"react-x/ensure-forward-ref-using-ref": "warn",
"react-x/no-access-state-in-setstate": "error",
"react-x/no-array-index-key": "warn",
"react-x/no-children-count": "warn",
"react-x/no-children-for-each": "warn",
"react-x/no-children-map": "warn",
"react-x/no-children-only": "warn",
"react-x/no-children-to-array": "warn",
"react-x/no-clone-element": "warn",
"react-x/no-comment-textnodes": "warn",
"react-x/no-component-will-mount": "error",
"react-x/no-component-will-receive-props": "error",
"react-x/no-component-will-update": "error",
"react-x/no-create-ref": "error",
"react-x/no-default-props": "error",
"react-x/no-direct-mutation-state": "error",
"react-x/no-duplicate-key": "error",
"react-x/no-implicit-key": "warn",
"react-x/no-missing-key": "error",
"react-x/no-nested-components": "warn",
"react-x/no-prop-types": "error",
"react-x/no-redundant-should-component-update": "error",
"react-x/no-set-state-in-component-did-mount": "warn",
"react-x/no-set-state-in-component-did-update": "warn",
"react-x/no-set-state-in-component-will-update": "warn",
"react-x/no-string-refs": "error",
"react-x/no-unsafe-component-will-mount": "warn",
"react-x/no-unsafe-component-will-receive-props": "warn",
"react-x/no-unsafe-component-will-update": "warn",
"react-x/no-unstable-context-value": "error",
"react-x/no-unstable-default-props": "error",
"react-x/no-unused-class-component-members": "warn",
"react-x/no-unused-state": "warn",
}
],
},
];
Rule | Description | πΌ | π | |
---|---|---|---|---|
avoid-shorthand-boolean | Enforces using shorthand syntax for boolean attributes. | π¨ | ||
avoid-shorthand-fragment | Enforces using shorthand syntax for fragments. | π¨ | ||
ensure-forward-ref-using-ref | Requires that components wrapped with forwardRef must have a ref parameter. | βοΈ | ||
no-access-state-in-setstate | Prevents accessing this.state inside setState calls. | βοΈ | ||
no-array-index-key | Prevents using array index as key . | π§ | ||
no-children-count | Prevents using Children.count . | β | ||
no-children-for-each | Prevents using Children.forEach . | β | ||
no-children-map | Prevents using Children.map . | β | ||
no-children-only | Prevents using Children.only . | β | ||
no-children-prop | Prevents using children as a prop. | β | ||
no-children-to-array | Prevents using Children.toArray . | β | ||
no-class-component | Prevents using class component. | β | ||
no-clone-element | Prevents using cloneElement . | β | ||
no-comment-textnodes | Prevents comments from being inserted as text nodes. | π§ | ||
no-complex-conditional-rendering | Prevents complex conditional rendering in JSX. | π€― | ||
no-component-will-mount | Prevents using componentWillMount . | β | ||
no-component-will-receive-props | Prevents using componentWillReceiveProps . | β | ||
no-component-will-update | Prevents using componentWillUpdate . | β | ||
no-create-ref | Prevents using createRef . | β | ||
no-default-props | Prevents using defaultProps property in favor of ES6 default parameters. | βοΈ | ||
no-direct-mutation-state | Prevents direct mutation of this.state . | βοΈ | ||
no-duplicate-key | Prevents duplicate key on elements in the same array or a list of children . | βοΈ | ||
no-implicit-key | Prevents key from not being explicitly specified (e.g. spreading key from objects). | π§ | ||
no-leaked-conditional-rendering | Prevents problematic leaked values from being rendered. | π§ | π | |
no-missing-component-display-name | Enforces that all components have a displayName which can be used in devtools. | π | ||
no-missing-key | Prevents missing key on items in list rendering. | βοΈ | ||
no-nested-components | Prevents nesting component definitions inside other components. | βοΈ | ||
no-props-types | Prevents using propTypes in favor of TypeScript or another type-checking solution. | β | ||
no-redundant-should-component-update | Prevents using shouldComponentUpdate when extending React.PureComponent . | βοΈ | ||
no-set-state-in-component-did-mount | Prevents calling this.setState in componentDidMount outside of functions, such as callbacks. | π§ | ||
no-set-state-in-component-did-update | Prevents calling this.setState in componentDidUpdate outside of functions, such as callbacks. | π§ | ||
no-set-state-in-component-will-update | Prevents calling this.setState in componentWillUpdate outside of functions, such as callbacks. | π§ | ||
no-string-refs | Prevents using deprecated string refs . | β | ||
no-unsafe-component-will-mount | Warns the usage of UNSAFE_componentWillMount in class components. | π§ | ||
no-unsafe-component-will-receive-props | Warns the usage of UNSAFE_componentWillReceiveProps in class components. | π§ | ||
no-unsafe-component-will-update | Warns the usage of UNSAFE_componentWillUpdate in class components. | π§ | ||
no-unstable-context-value | Prevents non-stable values (i.e. object literals) from being used as a value for Context.Provider . | π | ||
no-unstable-default-props | Prevents using referential-type values as default props in object destructuring. | π | ||
no-unused-class-component-members | Warns unused class component methods and properties. | βοΈ | ||
no-unused-state | Warns unused class component state. | βοΈ | ||
no-useless-fragment | Prevents using useless fragment components or <> syntax. | βοΈ | ||
prefer-destructuring-assignment | Enforces using destructuring assignment over property assignment. | π¨ | ||
prefer-read-only-props | Enforce read-only props in components. | βοΈ | π | |
prefer-shorthand-boolean | Enforces using shorthand syntax for boolean attributes. | π¨ | ||
prefer-shorthand-fragment | Enforces using shorthand syntax for fragments. | π¨ |
FAQs
A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.
The npm package eslint-plugin-react-x receives a total of 228,161 weekly downloads. As such, eslint-plugin-react-x popularity was classified as popular.
We found that eslint-plugin-react-x demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnamβs Telegram ban.