Skip to content

Commit 26ab87a

Browse files
mysticateamichalsnik
authored andcommitted
Fix: indent bug about shorthand properties
1 parent 39de540 commit 26ab87a

File tree

8 files changed

+66
-33
lines changed

8 files changed

+66
-33
lines changed

Diff for: lib/utils/indent-common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti
12701270
const leftParenToken = tokenStore.getTokenAfter(lastKeyToken)
12711271

12721272
setOffset(leftParenToken, 1, lastKeyToken)
1273-
} else {
1273+
} else if (!node.shorthand) {
12741274
const colonToken = tokenStore.getTokenAfter(lastKeyToken)
12751275
const valueToken = tokenStore.getTokenAfter(colonToken)
12761276

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
x: {
5+
y
6+
}
7+
}
8+
</script>

Diff for: tests/fixtures/script-indent/property-01.vue

-32
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,5 @@
44
aaa
55
:
66
1
7-
,
8-
bbb
9-
(
10-
a
11-
,
12-
b
13-
)
14-
{
15-
;
16-
}
17-
,
18-
get
19-
ccc
20-
(
21-
)
22-
{
23-
;
24-
},
25-
[
26-
d
27-
]
28-
:
29-
1,
30-
get
31-
[
32-
e
33-
]
34-
(
35-
)
36-
{
37-
;
38-
}
397
}
408
</script>

Diff for: tests/fixtures/script-indent/property-02.vue

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
bbb
5+
(
6+
a
7+
,
8+
b
9+
)
10+
{
11+
;
12+
}
13+
}
14+
</script>

Diff for: tests/fixtures/script-indent/property-03.vue

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
get
5+
ccc
6+
(
7+
)
8+
{
9+
;
10+
}
11+
}
12+
</script>

Diff for: tests/fixtures/script-indent/property-04.vue

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
[
5+
d
6+
]
7+
:
8+
1
9+
}
10+
</script>

Diff for: tests/fixtures/script-indent/property-05.vue

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
get
5+
[
6+
e
7+
]
8+
(
9+
)
10+
{
11+
;
12+
}
13+
}
14+
</script>

Diff for: tests/fixtures/script-indent/property-06.vue

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--{}-->
2+
<script>
3+
!{
4+
x,
5+
y
6+
}
7+
</script>

0 commit comments

Comments
 (0)