Skip to content

Commit 9a140a5

Browse files
pascalppljharb
authored andcommitted
[Fix] jsx-child-element-spacing: Don't flag whitespace around <br/> tags
Fixes #2988.
1 parent 9aa539d commit 9a140a5

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1313
* [`jsx-handler-names`]: properly substitute value into message ([#2975][] @G-Rath)
1414
* [`jsx-uses-vars`]: ignore namespaces ([#2985][] @remcohaszing)
1515
* [`jsx-no-undef`]: ignore namespaces ([#2986][] @remcohaszing)
16+
* [`jsx-child-element-spacing`]: Don't flag whitespace around `<br/>` tags ([#2989][] @pascalpp)
1617

1718
### Changed
1819
* [Docs] [`jsx-newline`]: Fix minor spelling error on rule name ([#2974][] @DennisSkoko)
1920
* [Refactor] [`void-dom-elements-no-children`]: improve performance
2021
* [readme] fix missing trailing commas ([#2980][] @sugardon)
2122
* [readme] fix broken anchor link ([#2982][] @vzvu3k6k)
2223

24+
[#2989]: https://github.com/yannickcr/eslint-plugin-react/pull/2989
2325
[#2986]: https://github.com/yannickcr/eslint-plugin-react/pull/2986
2426
[#2985]: https://github.com/yannickcr/eslint-plugin-react/pull/2985
2527
[#2982]: https://github.com/yannickcr/eslint-plugin-react/pull/2982
@@ -3362,4 +3364,4 @@ If you're still not using React 15 you can keep the old behavior by setting the
33623364
[`function-component-definition`]: docs/rules/function-component-definition.md
33633365
[`jsx-newline`]: docs/rules/jsx-newline.md
33643366
[`jsx-no-constructed-context-values`]: docs/rules/jsx-no-constructed-context-values.md
3365-
[`no-unstable-nested-components`]: docs/rules/no-unstable-nested-components.md
3367+
[`no-unstable-nested-components`]: docs/rules/no-unstable-nested-components.md

lib/rules/jsx-child-element-spacing.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
const docsUrl = require('../util/docsUrl');
44

55
// This list is taken from https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
6+
7+
// Note: 'br' is not included because whitespace around br tags is inconsequential to the rendered output
68
const INLINE_ELEMENTS = new Set([
79
'a',
810
'abbr',
911
'acronym',
1012
'b',
1113
'bdo',
1214
'big',
13-
'br',
1415
'button',
1516
'cite',
1617
'code',

tests/lib/rules/jsx-child-element-spacing.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,31 @@ ruleTester.run('jsx-child-element-spacing', rule, {
139139
B
140140
</App>
141141
`
142+
}, {
143+
code: `
144+
<App>
145+
A
146+
<br/>
147+
B
148+
</App>
149+
`
150+
}, {
151+
code: `
152+
<App>
153+
A<br/>
154+
B
155+
</App>
156+
`
157+
}, {
158+
code: `
159+
<App>
160+
A<br/>B
161+
</App>
162+
`
163+
}, {
164+
code: `
165+
<App>A<br/>B</App>
166+
`
142167
}],
143168

144169
invalid: [{

0 commit comments

Comments
 (0)