Content-Length: 397733 | pFad | http://github.com/jsx-eslint/eslint-plugin-react/commit/14b0175ea209494d9af37baf5895bc963d3e4f63

9A [Fix] checked-requires-onchange-or-readonly: correct options that wer… · jsx-eslint/eslint-plugin-react@14b0175 · GitHub
Skip to content

Commit 14b0175

Browse files
committed
[Fix] checked-requires-onchange-or-readonly: correct options that were behaving opposite
1 parent da1013c commit 14b0175

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

lib/rules/checked-requires-onchange-or-readonly.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const messages = {
1919
const targetPropSet = new Set(['checked', 'onChange', 'readOnly', 'defaultChecked']);
2020

2121
const defaultOptions = {
22-
ignoreMissingProperties: true,
23-
ignoreExclusiveCheckedAttribute: true,
22+
ignoreMissingProperties: false,
23+
ignoreExclusiveCheckedAttribute: false,
2424
};
2525

2626
/**
@@ -93,12 +93,12 @@ module.exports = {
9393
return;
9494
}
9595

96-
if (options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) {
96+
if (!options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) {
9797
reportExclusiveCheckedAttribute(node);
9898
}
9999

100100
if (
101-
options.ignoreMissingProperties
101+
!options.ignoreMissingProperties
102102
&& !(propSet.has('onChange') || propSet.has('readOnly'))
103103
) {
104104
reportMissingProperty(node);

tests/lib/rules/checked-requires-onchange-or-readonly.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,23 @@ ruleTester.run('checked-requires-onchange-or-readonly', rule, {
4040
"React.createElement('input', { checked: foo, onChange: noop, readOnly: true })",
4141
{
4242
code: '<input type="checkbox" checked />',
43-
options: [{ ignoreMissingProperties: false }],
43+
options: [{ ignoreMissingProperties: true }],
4444
},
4545
{
4646
code: '<input type="checkbox" checked={true} />',
47-
options: [{ ignoreMissingProperties: false }],
47+
options: [{ ignoreMissingProperties: true }],
4848
},
4949
{
5050
code: '<input type="checkbox" onChange={noop} checked defaultChecked />',
51-
options: [{ ignoreExclusiveCheckedAttribute: false }],
51+
options: [{ ignoreExclusiveCheckedAttribute: true }],
5252
},
5353
{
5454
code: '<input type="checkbox" onChange={noop} checked={true} defaultChecked />',
55-
options: [{ ignoreExclusiveCheckedAttribute: false }],
55+
options: [{ ignoreExclusiveCheckedAttribute: true }],
56+
},
57+
{
58+
code: '<input type="checkbox" onChange={noop} checked defaultChecked />',
59+
options: [{ ignoreMissingProperties: true, ignoreExclusiveCheckedAttribute: true }],
5660
},
5761
'<span/>',
5862
"React.createElement('span')",
@@ -99,13 +103,21 @@ ruleTester.run('checked-requires-onchange-or-readonly', rule, {
99103
},
100104
{
101105
code: '<input type="checkbox" checked defaultChecked />',
102-
options: [{ ignoreMissingProperties: false }],
106+
options: [{ ignoreMissingProperties: true }],
103107
errors: [{ messageId: 'exclusiveCheckedAttribute' }],
104108
},
105109
{
106110
code: '<input type="checkbox" checked defaultChecked />',
107-
options: [{ ignoreExclusiveCheckedAttribute: false }],
111+
options: [{ ignoreExclusiveCheckedAttribute: true }],
108112
errors: [{ messageId: 'missingProperty' }],
109113
},
114+
{
115+
code: '<input type="checkbox" checked defaultChecked />',
116+
options: [{ ignoreMissingProperties: false, ignoreExclusiveCheckedAttribute: false }],
117+
errors: [
118+
{ messageId: 'exclusiveCheckedAttribute' },
119+
{ messageId: 'missingProperty' },
120+
],
121+
},
110122
]),
111123
});

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jsx-eslint/eslint-plugin-react/commit/14b0175ea209494d9af37baf5895bc963d3e4f63

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy