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

Fix tabs for ´jsx-one-expression-per-line´ rule #2198

Merged
merged 1 commit into from Mar 17, 2019
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: 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