diff --git a/lib/rules/checked-requires-onchange-or-readonly.js b/lib/rules/checked-requires-onchange-or-readonly.js
index 4c1cc15dd1..420611fee5 100644
--- a/lib/rules/checked-requires-onchange-or-readonly.js
+++ b/lib/rules/checked-requires-onchange-or-readonly.js
@@ -19,8 +19,8 @@ const messages = {
const targetPropSet = new Set(['checked', 'onChange', 'readOnly', 'defaultChecked']);
const defaultOptions = {
- ignoreMissingProperties: true,
- ignoreExclusiveCheckedAttribute: true,
+ ignoreMissingProperties: false,
+ ignoreExclusiveCheckedAttribute: false,
};
/**
@@ -93,12 +93,12 @@ module.exports = {
return;
}
- if (options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) {
+ if (!options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) {
reportExclusiveCheckedAttribute(node);
}
if (
- options.ignoreMissingProperties
+ !options.ignoreMissingProperties
&& !(propSet.has('onChange') || propSet.has('readOnly'))
) {
reportMissingProperty(node);
diff --git a/tests/lib/rules/checked-requires-onchange-or-readonly.js b/tests/lib/rules/checked-requires-onchange-or-readonly.js
index 7f9a14cac4..93e08ef60e 100644
--- a/tests/lib/rules/checked-requires-onchange-or-readonly.js
+++ b/tests/lib/rules/checked-requires-onchange-or-readonly.js
@@ -40,19 +40,23 @@ ruleTester.run('checked-requires-onchange-or-readonly', rule, {
"React.createElement('input', { checked: foo, onChange: noop, readOnly: true })",
{
code: '',
- options: [{ ignoreMissingProperties: false }],
+ options: [{ ignoreMissingProperties: true }],
},
{
code: '',
- options: [{ ignoreMissingProperties: false }],
+ options: [{ ignoreMissingProperties: true }],
},
{
code: '',
- options: [{ ignoreExclusiveCheckedAttribute: false }],
+ options: [{ ignoreExclusiveCheckedAttribute: true }],
},
{
code: '',
- options: [{ ignoreExclusiveCheckedAttribute: false }],
+ options: [{ ignoreExclusiveCheckedAttribute: true }],
+ },
+ {
+ code: '',
+ options: [{ ignoreMissingProperties: true, ignoreExclusiveCheckedAttribute: true }],
},
'',
"React.createElement('span')",
@@ -99,13 +103,21 @@ ruleTester.run('checked-requires-onchange-or-readonly', rule, {
},
{
code: '',
- options: [{ ignoreMissingProperties: false }],
+ options: [{ ignoreMissingProperties: true }],
errors: [{ messageId: 'exclusiveCheckedAttribute' }],
},
{
code: '',
- options: [{ ignoreExclusiveCheckedAttribute: false }],
+ options: [{ ignoreExclusiveCheckedAttribute: true }],
errors: [{ messageId: 'missingProperty' }],
},
+ {
+ code: '',
+ options: [{ ignoreMissingProperties: false, ignoreExclusiveCheckedAttribute: false }],
+ errors: [
+ { messageId: 'exclusiveCheckedAttribute' },
+ { messageId: 'missingProperty' },
+ ],
+ },
]),
});