Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: indent rule with JSX spread props (#12581)
  • Loading branch information
nwoltman authored and btmills committed Nov 22, 2019
1 parent 97c745d commit b336fbe
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/rules/indent.js
Expand Up @@ -1492,6 +1492,17 @@ module.exports = {
);
},

JSXSpreadAttribute(node) {
const openingCurly = sourceCode.getFirstToken(node);
const closingCurly = sourceCode.getLastToken(node);

offsets.setDesiredOffsets(
[openingCurly.range[1], closingCurly.range[0]],
openingCurly,
1
);
},

"*"(node) {
const firstToken = sourceCode.getFirstToken(node);

Expand Down
42 changes: 42 additions & 0 deletions tests/lib/rules/indent.js
Expand Up @@ -4889,6 +4889,18 @@ ruleTester.run("indent", rule, {
<a>baz qux</a>.
</small>
`,
unIndent`
<div
{...props}
/>
`,
unIndent`
<div
{
...props
}
/>
`,
{
code: unIndent`
a(b
Expand Down Expand Up @@ -9754,6 +9766,36 @@ ruleTester.run("indent", rule, {
`,
errors: expectedErrors([3, 8, 6, "Block"])
},
{
code: unIndent`
<div
{...props}
/>
`,
output: unIndent`
<div
{...props}
/>
`,
errors: expectedErrors([2, 4, 0, "Punctuator"])
},
{
code: unIndent`
<div
{
...props
}
/>
`,
output: unIndent`
<div
{
...props
}
/>
`,
errors: expectedErrors([3, 8, 6, "Punctuator"])
},
{
code: unIndent`
<div>foo
Expand Down

0 comments on commit b336fbe

Please sign in to comment.