Allows you to enforce a consistent naming pattern for props which expect a boolean value.
The following patterns are considered warnings:
var Hello = createReactClass({
propTypes: {
enabled: PropTypes.bool
},
render: function() { return <div />; };
});
The following patterns are not considered warnings:
var Hello = createReactClass({
propTypes: {
isEnabled: PropTypes.bool
},
render: function() { return <div />; };
});
...
"react/boolean-prop-naming": [<enabled>, { "propTypeNames": Array<string>, "rule": <string> }]
...
The list of prop type names that are considered to be booleans. By default this is set to ['bool']
but you can include other custom types like so:
"react/boolean-prop-naming": ["error", { "propTypeNames": ["bool", "mutuallyExclusiveTrueProps"] }]
The RegExp pattern to use when validating the name of the prop. The default value for this option is set to: "^(is|has)[A-Z]([A-Za-z0-9]?)+"
to enforce is
and has
prefixes.
For supporting "is" and "has" naming (default):
- isEnabled
- isAFK
- hasCondition
- hasLOL
"react/boolean-prop-naming": ["error", { "rule": "^(is|has)[A-Z]([A-Za-z0-9]?)+" }]
For supporting "is" naming:
- isEnabled
- isAFK
"react/boolean-prop-naming": ["error", { "rule": "^is[A-Z]([A-Za-z0-9]?)+" }]