Skip to content

Commit

Permalink
[Fix] jsx-one-expression-per-line: fix when using tabs
Browse files Browse the repository at this point in the history
Fixes #2152.
  • Loading branch information
Pavel Lysenko authored and ljharb committed Mar 13, 2019
1 parent d3dc4c8 commit 2c091dd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-one-expression-per-line.js
Expand Up @@ -94,8 +94,8 @@ module.exports = {
return;
}

countNewLinesBeforeContent = (child.raw.match(/^ *\n/g) || []).length;
countNewLinesAfterContent = (child.raw.match(/\n *$/g) || []).length;
countNewLinesBeforeContent = (child.raw.match(/^\s*\n/g) || []).length;
countNewLinesAfterContent = (child.raw.match(/\n\s*$/g) || []).length;
}

const startLine = child.loc.start.line + countNewLinesBeforeContent;
Expand Down
36 changes: 36 additions & 0 deletions tests/lib/rules/jsx-one-expression-per-line.js
Expand Up @@ -28,6 +28,42 @@ const ruleTester = new RuleTester({parserOptions});
ruleTester.run('jsx-one-expression-per-line', rule, {
valid: [{
code: '<App />'
}, {
code: `
\t\t<AllTabs>
\t\t\tFail
\t\t</AllTabs>
`
}, {
code: `
\t\t<TagsWithTabs>
Fail
\t\t</TagsWithTabs>
`
}, {
code: `
<ClosedTagWithTabs>
Fail
\t\t</ClosedTagWithTabs>
`
}, {
code: `
\t\t<OpenTagWithTabs>
OK
</OpenTagWithTabs>
`
}, {
code: `
<TextWithTabs>
\t\t\tOK
</TextWithTabs>
`
}, {
code: `
<AllSpaces>
OK
</AllSpaces>
`
}, {
code: '<App></App>'
}, {
Expand Down

0 comments on commit 2c091dd

Please sign in to comment.