Skip to content

Commit 73350de

Browse files
committed
[Fix] no-unknown-property: add noModule on script
Fixes #3414
1 parent 0dc8c9d commit 73350de

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77

88
### Fixed
99
* [`no-unknown-property`]: add `viewBox` on `marker` ([#3416][] @ljharb)
10+
* [`no-unknown-property`]: add `noModule` on `script` ([#3414][] @ljharb)
1011

1112
### Changed
1213

1314
* [Meta] npmignore markdownlint config ([#3413][] @jorrit)
1415

1516
[#3416]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3416
17+
[#3414]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3414
1618
[#3413]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3413
1719

1820
## [7.31.7] - 2022.09.05

lib/rules/no-unknown-property.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const DEFAULTS = {
2121
const DOM_ATTRIBUTE_NAMES = {
2222
'accept-charset': 'acceptCharset',
2323
class: 'className',
24-
for: 'htmlFor',
2524
'http-equiv': 'httpEquiv',
2625
crossorigin: 'crossOrigin',
26+
for: 'htmlFor',
27+
nomodule: 'noModule',
2728
};
2829

2930
const ATTRIBUTE_TAGS_MAP = {
@@ -64,6 +65,7 @@ const ATTRIBUTE_TAGS_MAP = {
6465
viewBox: ['svg', 'marker'],
6566
as: ['link'],
6667
valign: ['tr', 'td', 'th', 'thead', 'tbody', 'tfoot', 'colgroup', 'col'], // deprecated, but known
68+
noModule: ['script'],
6769
// Media events allowed only on audio and video tags, see https://github.com/facebook/react/blob/256aefbea1449869620fb26f6ec695536ab453f5/CHANGELOG.md#notable-enhancements
6870
onAbort: ['audio', 'video'],
6971
onCanPlay: ['audio', 'video'],

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ruleTester.run('no-unknown-property', rule, {
110110
{ code: '<button aria-haspopup="true">Click me to open pop up</button>;' },
111111
{ code: '<button aria-label="Close" onClick={someThing.close} />;' },
112112
// Attributes on allowed elements should work
113-
{ code: '<script crossOrigin />' },
113+
{ code: '<script crossOrigin noModule />' },
114114
{ code: '<audio crossOrigin />' },
115115
{ code: '<svg focusable><image crossOrigin /></svg>' },
116116
{ code: '<details onToggle={this.onToggle}>Some details</details>' },
@@ -332,7 +332,7 @@ ruleTester.run('no-unknown-property', rule, {
332332
],
333333
},
334334
{
335-
code: '<script crossorigin />',
335+
code: '<script crossorigin nomodule />',
336336
errors: [
337337
{
338338
messageId: 'unknownPropWithStandardName',
@@ -341,8 +341,15 @@ ruleTester.run('no-unknown-property', rule, {
341341
standardName: 'crossOrigin',
342342
},
343343
},
344+
{
345+
messageId: 'unknownPropWithStandardName',
346+
data: {
347+
name: 'nomodule',
348+
standardName: 'noModule',
349+
},
350+
},
344351
],
345-
output: '<script crossOrigin />',
352+
output: '<script crossOrigin noModule />',
346353
},
347354
{
348355
code: '<div crossorigin />',

0 commit comments

Comments
 (0)