Skip to content

Commit be4e93c

Browse files
sjarvaljharb
authored andcommitted
[Fix] no-unknown-property: add defaultChecked property
1 parent ae23d7c commit be4e93c

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77

88
### Fixed
99
* [`no-unknown-property`]: add properties `onToggle`, `fill`, `as`, and pointer events ([#3385][] @sjarva)
10+
* [`no-unknown-property`]: add `defaultChecked` property ([#3385][] @sjarva)
1011

1112
[#3385]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3385
1213

lib/rules/no-unknown-property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
226226
'autoCorrect', // https://stackoverflow.com/questions/47985384/html-autocorrect-for-text-input-is-not-working
227227
'autoSave', // https://stackoverflow.com/questions/25456396/what-is-autosave-attribute-supposed-to-do-how-do-i-use-it
228228
// React specific attributes https://reactjs.org/docs/dom-elements.html#differences-in-attributes
229-
'className', 'dangerouslySetInnerHTML', 'defaultValue', 'htmlFor', 'onChange', 'suppressContentEditableWarning', 'suppressHydrationWarning',
229+
'className', 'dangerouslySetInnerHTML', 'defaultValue', 'defaultChecked', 'htmlFor', 'onChange', 'suppressContentEditableWarning', 'suppressHydrationWarning',
230230
];
231231

232232
const DOM_PROPERTIES_IGNORE_CASE = ['charset'];

tests/lib/rules/no-unknown-property.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ ruleTester.run('no-unknown-property', rule, {
5656
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
5757
// React related attributes
5858
{ code: '<div onPointerDown={this.onDown} onPointerUp={this.onUp} />' },
59+
{ code: '<input type="checkbox" defaultChecked={this.state.checkbox} />' },
5960
// Case ignored attributes, for `charset` discussion see https://github.com/jsx-eslint/eslint-plugin-react/pull/1863
6061
{ code: '<meta charset="utf-8" />;' },
6162
{ code: '<meta charSet="utf-8" />;' },

0 commit comments

Comments
 (0)