Skip to content

Commit

Permalink
[Fix] no-unknown-property: add noModule on script
Browse files Browse the repository at this point in the history
Fixes #3414
  • Loading branch information
ljharb committed Sep 6, 2022
1 parent 0dc8c9d commit 73350de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,12 +7,14 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

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

### Changed

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

[#3416]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3416
[#3414]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3414
[#3413]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3413

## [7.31.7] - 2022.09.05
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/no-unknown-property.js
Expand Up @@ -21,9 +21,10 @@ const DEFAULTS = {
const DOM_ATTRIBUTE_NAMES = {
'accept-charset': 'acceptCharset',
class: 'className',
for: 'htmlFor',
'http-equiv': 'httpEquiv',
crossorigin: 'crossOrigin',
for: 'htmlFor',
nomodule: 'noModule',
};

const ATTRIBUTE_TAGS_MAP = {
Expand Down Expand Up @@ -64,6 +65,7 @@ const ATTRIBUTE_TAGS_MAP = {
viewBox: ['svg', 'marker'],
as: ['link'],
valign: ['tr', 'td', 'th', 'thead', 'tbody', 'tfoot', 'colgroup', 'col'], // deprecated, but known
noModule: ['script'],
// Media events allowed only on audio and video tags, see https://github.com/facebook/react/blob/256aefbea1449869620fb26f6ec695536ab453f5/CHANGELOG.md#notable-enhancements
onAbort: ['audio', 'video'],
onCanPlay: ['audio', 'video'],
Expand Down
13 changes: 10 additions & 3 deletions tests/lib/rules/no-unknown-property.js
Expand Up @@ -110,7 +110,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<button aria-haspopup="true">Click me to open pop up</button>;' },
{ code: '<button aria-label="Close" onClick={someThing.close} />;' },
// Attributes on allowed elements should work
{ code: '<script crossOrigin />' },
{ code: '<script crossOrigin noModule />' },
{ code: '<audio crossOrigin />' },
{ code: '<svg focusable><image crossOrigin /></svg>' },
{ code: '<details onToggle={this.onToggle}>Some details</details>' },
Expand Down Expand Up @@ -332,7 +332,7 @@ ruleTester.run('no-unknown-property', rule, {
],
},
{
code: '<script crossorigin />',
code: '<script crossorigin nomodule />',
errors: [
{
messageId: 'unknownPropWithStandardName',
Expand All @@ -341,8 +341,15 @@ ruleTester.run('no-unknown-property', rule, {
standardName: 'crossOrigin',
},
},
{
messageId: 'unknownPropWithStandardName',
data: {
name: 'nomodule',
standardName: 'noModule',
},
},
],
output: '<script crossOrigin />',
output: '<script crossOrigin noModule />',
},
{
code: '<div crossorigin />',
Expand Down

0 comments on commit 73350de

Please sign in to comment.