Skip to content

Commit cd23e3f

Browse files
committed
[Fix] no-unknown-property: add align on all the tags that support it
Fixes #3425
1 parent 8e07874 commit cd23e3f

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1212
* [`no-multi-comp`]: do not detect a function property returning only null as a component ([#3412][] @ljharb)
1313
* [`no-unknown-property`]: allow `abbr` on `<th>` and `<td>` ([#3419][] @OleksiiKachan)
1414
* [`no-unknown-property`]: add `viewBox` for `pattern`, `symbol`, `view` ([#3424][] @MNBuyskih)
15+
* [`no-unknown-property`]: add `align` on all the tags that support it ([#3425][] @ljharb)
1516

1617
### Changed
1718

1819
* [meta] npmignore markdownlint config ([#3413][] @jorrit)
1920

21+
[#3425]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3425
2022
[#3424]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3424
2123
[#3419]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3419
2224
[#3416]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3416

lib/rules/no-unknown-property.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const ATTRIBUTE_TAGS_MAP = {
6565
property: ['meta'],
6666
viewBox: ['marker', 'pattern', 'svg', 'symbol', 'view'],
6767
as: ['link'],
68+
align: ['applet', 'caption', 'col', 'colgroup', 'hr', 'iframe', 'img', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr'], // deprecated, but known
6869
valign: ['tr', 'td', 'th', 'thead', 'tbody', 'tfoot', 'colgroup', 'col'], // deprecated, but known
6970
noModule: ['script'],
7071
// Media events allowed only on audio and video tags, see https://github.com/facebook/react/blob/256aefbea1449869620fb26f6ec695536ab453f5/CHANGELOG.md#notable-enhancements

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

+14-11
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ ruleTester.run('no-unknown-property', rule, {
4646
{ code: '<div onMouseDown={this._onMouseDown}></div>;' },
4747
{ code: '<a href="someLink" download="foo">Read more</a>' },
4848
{ code: '<area download="foo" />' },
49-
{ code: '<img src="cat_keyboard.jpeg" alt="A cat sleeping on a keyboard" />' },
49+
{ 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" />' },
5252
{ code: '<div children="anything" />' },
53-
{ code: '<iframe scrolling="?" onLoad={a} onError={b} />' },
53+
{ code: '<iframe scrolling="?" onLoad={a} onError={b} align="top" />' },
5454
{ code: '<input key="bar" type="radio" />' },
5555
{ code: '<button disabled>You cannot click me</button>;' },
5656
{ code: '<svg key="lock" viewBox="box" fill={10} d="d" stroke={1} strokeWidth={2} strokeLinecap={3} strokeLinejoin={4} transform="something" clipRule="else" x1={5} x2="6" y1="7" y2="8"></svg>' },
@@ -126,20 +126,23 @@ ruleTester.run('no-unknown-property', rule, {
126126
{ code: '<pattern id="pattern" viewBox="0,0,10,10" width="10%" height="10%" />' },
127127
{ code: '<symbol id="myDot" width="10" height="10" viewBox="0 0 2 2" />' },
128128
{ code: '<view id="one" viewBox="0 0 100 100" />' },
129+
{ code: '<hr align="top" />' },
130+
{ code: '<applet align="top" />' },
129131
{
130132
code: `
131-
<table>
132-
<colgroup valign="top">
133-
<col valign="top" />
133+
<table align="top">
134+
<caption align="top">Table Caption</caption>
135+
<colgroup valign="top" align="top">
136+
<col valign="top" align="top"/>
134137
</colgroup>
135-
<thead valign="top">
136-
<tr valign="top">
137-
<th valign="top">Header</th>
138-
<td valign="top">Cell</td>
138+
<thead valign="top" align="top">
139+
<tr valign="top" align="top">
140+
<th valign="top" align="top">Header</th>
141+
<td valign="top" align="top">Cell</td>
139142
</tr>
140143
</thead>
141-
<tbody valign="top" />
142-
<tfoot valign="top" />
144+
<tbody valign="top" align="top" />
145+
<tfoot valign="top" align="top" />
143146
</table>
144147
`,
145148
},

0 commit comments

Comments
 (0)