Skip to content

Commit 0b63c45

Browse files
committed
[Fix] no-unknown-property: allow webkitDirectory on input, case-insensitive
Fixes #3454
1 parent 028457c commit 0b63c45

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1212
* [`jsx-no-constructed-context-values`]: fix false positive for usage in non-components ([#3448][] @golopot)
1313
* [`static-property-placement`]: warn on nonstatic expected-statics ([#2581][] @ljharb)
1414
* [`no-unknown-property`]: properly tag-restrict case-insensitive attributes (@ljharb)
15+
* [`no-unknown-property`]: allow `webkitDirectory` on `input`, case-insensitive ([#3454][] @ljharb)
1516

1617
### Changed
1718
* [Docs] [`no-unknown-property`]: fix typo in link ([#3445][] @denkristoffer)
1819
* [Perf] component detection: improve performance by optimizing getId ([#3451][] @golopot)
1920
* [Docs] [`no-unstable-nested-components`]: Warn about memoized, nested components ([#3444][] @eps1lon)
2021

22+
[#3454]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3454
2123
[#3451]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3451
2224
[#3448]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3448
2325
[#3445]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3445

lib/rules/no-unknown-property.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const ATTRIBUTE_TAGS_MAP = {
111111
preload: ['audio', 'video'],
112112
scrolling: ['iframe'],
113113
returnValue: ['dialog'],
114+
webkitDirectory: ['input'],
114115
};
115116

116117
const SVGDOM_ATTRIBUTE_NAMES = {
@@ -310,7 +311,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
310311
'autoPictureInPicture', 'controlsList', 'disablePictureInPicture', 'disableRemotePlayback',
311312
];
312313

313-
const DOM_PROPERTIES_IGNORE_CASE = ['charset', 'allowFullScreen', 'webkitAllowFullScreen', 'mozAllowFullScreen'];
314+
const DOM_PROPERTIES_IGNORE_CASE = ['charset', 'allowFullScreen', 'webkitAllowFullScreen', 'mozAllowFullScreen', 'webkitDirectory'];
314315

315316
const ARIA_PROPERTIES = [
316317
// See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes

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

+28
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ ruleTester.run('no-unknown-property', rule, {
4949
{ code: '<img src="cat_keyboard.jpeg" alt="A cat sleeping on a keyboard" align="top" />' },
5050
{ code: '<input type="password" required />' },
5151
{ code: '<input ref={this.input} type="radio" />' },
52+
{ code: '<input type="file" webkitdirectory="" />' },
53+
{ code: '<input type="file" webkitDirectory="" />' },
5254
{ code: '<div children="anything" />' },
5355
{ code: '<iframe scrolling="?" onLoad={a} onError={b} align="top" />' },
5456
{ code: '<input key="bar" type="radio" />' },
@@ -579,5 +581,31 @@ ruleTester.run('no-unknown-property', rule, {
579581
},
580582
],
581583
},
584+
{
585+
code: '<div webkitDirectory="" />',
586+
errors: [
587+
{
588+
messageId: 'invalidPropOnTag',
589+
data: {
590+
name: 'webkitDirectory',
591+
tagName: 'div',
592+
allowedTags: 'input',
593+
},
594+
},
595+
],
596+
},
597+
{
598+
code: '<div webkitdirectory="" />',
599+
errors: [
600+
{
601+
messageId: 'invalidPropOnTag',
602+
data: {
603+
name: 'webkitdirectory',
604+
tagName: 'div',
605+
allowedTags: 'input',
606+
},
607+
},
608+
],
609+
},
582610
]),
583611
});

0 commit comments

Comments
 (0)