Skip to content

Commit c8b3f16

Browse files
committed
Add more invalid tests for boolean-prop-naming
1 parent 56db72e commit c8b3f16

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/lib/rules/boolean-prop-naming.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,5 +578,41 @@ ruleTester.run('boolean-prop-naming', rule, {
578578
errors: [{
579579
message: 'Prop name (showScore) doesn\'t match rule (^(is|has)[A-Z]([A-Za-z0-9]?)+)'
580580
}]
581+
}, {
582+
code: `
583+
function Card(props) {
584+
return <div>{props.showScore ? 'yeh' : 'no'}</div>;
585+
}
586+
Card.propTypes = forbidExtraProps({
587+
showScore: PropTypes.bool
588+
});`,
589+
settings: {
590+
propWrapperFunctions: ['forbidExtraProps']
591+
},
592+
options: [{
593+
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+'
594+
}],
595+
errors: [{
596+
message: 'Prop name (showScore) doesn\'t match rule (^(is|has)[A-Z]([A-Za-z0-9]?)+)'
597+
}]
598+
}, {
599+
code: `
600+
class Card extends React.Component {
601+
render() {
602+
return <div>{props.showScore ? 'yeh' : 'no'}</div>;
603+
}
604+
}
605+
Card.propTypes = forbidExtraProps({
606+
showScore: PropTypes.bool
607+
});`,
608+
settings: {
609+
propWrapperFunctions: ['forbidExtraProps']
610+
},
611+
options: [{
612+
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+'
613+
}],
614+
errors: [{
615+
message: 'Prop name (showScore) doesn\'t match rule (^(is|has)[A-Z]([A-Za-z0-9]?)+)'
616+
}]
581617
}]
582618
});

0 commit comments

Comments
 (0)