@zohodesk/eslint-plugin-restrict-extra-props
v0.0.1
Published
This ESLint plugin prevents passing props to specific JSX components. It is useful when certain components need to remain controlled or decoupled.
Maintainers
Keywords
Readme
eslint-plugin-restrict-extra-props
This ESLint plugin prevents passing props to specific JSX components. It is useful when certain components need to remain controlled or decoupled.
Installation
Install ESLint:
npm i eslint --save-devInstall this plugin:
npm install eslint-plugin-restrict-extra-props --save-devIf ESLint is installed globally, install the plugin globally as well.
Usage
Add the plugin to your .eslintrc file:
{
"plugins": ["restrict-extra-props"]
}
Configure the rule:
{
"rules": {
"restrict-extra-props/restrict-extra-props": ["error", {
"restrictedComponents": ["TicketProperties"],
"allowKeyAndRef": true
}]
}
}restrictedComponents must be an array of component names where props should not be allowed. allowKeyAndRef allows using only key and ref. Set it to false to block those as well.
Cases where the rule reports errors: <TicketProperties {...props} />
Cases where the rule does not report errors:
This plugin ensures restricted components cannot receive props, preventing accidental usage and enforcing strict component control.
