Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't flag whitespace around <br/> tags #2989

Merged
merged 1 commit into from May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -13,13 +13,15 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
* [`jsx-handler-names`]: properly substitute value into message ([#2975][] @G-Rath)
* [`jsx-uses-vars`]: ignore namespaces ([#2985][] @remcohaszing)
* [`jsx-no-undef`]: ignore namespaces ([#2986][] @remcohaszing)
* [`jsx-child-element-spacing`]: Don't flag whitespace around `<br/>` tags ([#2989][] @pascalpp)

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

[#2989]: https://github.com/yannickcr/eslint-plugin-react/pull/2989
[#2986]: https://github.com/yannickcr/eslint-plugin-react/pull/2986
[#2985]: https://github.com/yannickcr/eslint-plugin-react/pull/2985
[#2982]: https://github.com/yannickcr/eslint-plugin-react/pull/2982
Expand Down Expand Up @@ -3362,4 +3364,4 @@ If you're still not using React 15 you can keep the old behavior by setting the
[`function-component-definition`]: docs/rules/function-component-definition.md
[`jsx-newline`]: docs/rules/jsx-newline.md
[`jsx-no-constructed-context-values`]: docs/rules/jsx-no-constructed-context-values.md
[`no-unstable-nested-components`]: docs/rules/no-unstable-nested-components.md
[`no-unstable-nested-components`]: docs/rules/no-unstable-nested-components.md
3 changes: 2 additions & 1 deletion lib/rules/jsx-child-element-spacing.js
Expand Up @@ -3,14 +3,15 @@
const docsUrl = require('../util/docsUrl');

// This list is taken from https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements

// Note: 'br' is not included because whitespace around br tags is inconsequential to the rendered output
const INLINE_ELEMENTS = new Set([
'a',
'abbr',
'acronym',
'b',
'bdo',
'big',
'br',
'button',
'cite',
'code',
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/jsx-child-element-spacing.js
Expand Up @@ -139,6 +139,31 @@ ruleTester.run('jsx-child-element-spacing', rule, {
B
</App>
`
}, {
code: `
<App>
A
<br/>
B
</App>
`
}, {
code: `
<App>
A<br/>
B
</App>
`
}, {
code: `
<App>
A<br/>B
</App>
`
}, {
code: `
<App>A<br/>B</App>
`
}],

invalid: [{
Expand Down