Skip to content

Commit 98f3082

Browse files
committed
tree-indenter: Applied fix introduced in sane-indentation for atom 1.40
- Four days of work to get those damn test to run again, just for a two character change to fix the tests. - Now also added all other, minor changes to sane-indendation over the last five years since the PR for this change was opened.
1 parent 0dd75df commit 98f3082

11 files changed

+604
-7
lines changed

spec/fixtures/indentation/classes.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class MyClass extends OtherComponent {
2+
3+
state = {
4+
test: 1
5+
}
6+
7+
constructor() {
8+
test();
9+
}
10+
11+
otherfunction = (a, b = {
12+
default: false
13+
}) => {
14+
more();
15+
}
16+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* multi-line expressions */
2+
req
3+
.shouldBeOne();
4+
too.
5+
more.
6+
shouldBeOneToo;
7+
8+
const a =
9+
long_expression;
10+
11+
b =
12+
long;
13+
14+
b =
15+
3 + 5;
16+
17+
b =
18+
3
19+
+ 5;
20+
21+
b =
22+
3
23+
+ 5
24+
+ 7
25+
+ 8
26+
* 8
27+
* 9
28+
/ 17
29+
* 8
30+
/ 20
31+
- 34
32+
+ 3 *
33+
9
34+
- 8;
35+
36+
ifthis
37+
&& thendo()
38+
|| otherwise
39+
&& dothis
40+
41+
/**
42+
A comment, should be at 1
43+
*/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
foo({
2+
sd,
3+
sdf
4+
},
5+
4
6+
);
7+
8+
foo( 2, {
9+
sd,
10+
sdf
11+
},
12+
4
13+
);
14+
15+
foo( 2,
16+
{
17+
sd,
18+
sdf
19+
});
20+
21+
foo( 2, {
22+
sd,
23+
sdf
24+
});
25+
26+
foo(2,
27+
4);
28+
29+
foo({
30+
symetric_opening_and_closing_scopes: 'indent me at 1'
31+
});
32+
33+
foo(myWrapper(mysecondWrapper({
34+
a: 1 // should be at 1
35+
})));
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
/** if-then-else loops */
3+
if (true)
4+
foo();
5+
else
6+
bar();
7+
8+
if (true) {
9+
foo();
10+
bar();
11+
} else {
12+
foo();
13+
}
14+
15+
// https://github.com/atom/atom/issues/6691
16+
if (true)
17+
{
18+
foo();
19+
bar();
20+
}
21+
else
22+
{
23+
foo();
24+
}
25+
26+
if (true) {
27+
if (yes)
28+
doit(); // 2
29+
bar();
30+
} else if (more()) {
31+
foo(); // 1
32+
}
33+
34+
if (true)
35+
foo();
36+
else
37+
if (more()) { // 1
38+
foo(); // 1
39+
}
40+
41+
if (true)
42+
foo();
43+
else
44+
if (more()) // 1
45+
foo(); // 2
46+
47+
if (we
48+
()) {
49+
go();
50+
}
51+
52+
if (true) {
53+
foo();
54+
bar();
55+
} else if (false) {
56+
more();
57+
} else {
58+
foo();
59+
}

spec/fixtures/indentation/jsx.jsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/** JSX */
2+
const jsx = (
3+
<div
4+
title='start'
5+
>
6+
good
7+
<a>
8+
link
9+
</a>
10+
<i>
11+
sdfg
12+
</i>
13+
<div>
14+
sdf
15+
</div>
16+
</div>
17+
);
18+
19+
const two = (
20+
<div>
21+
<b>
22+
test
23+
</b>
24+
<b>
25+
test
26+
</b>
27+
</div>
28+
);
29+
30+
const a = (
31+
<img
32+
src='/img.jpg'
33+
/>
34+
);
35+
36+
const b = (
37+
<img
38+
src='/img.jpg' />
39+
);
40+
41+
const two = (
42+
<div>
43+
{
44+
test && 'test'
45+
}
46+
</div>
47+
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var x = [
2+
3,
3+
4
4+
];
5+
6+
const y = [
7+
1
8+
];
9+
10+
const j = [{
11+
a: 1
12+
}];
13+
14+
let h = {
15+
a: [ 1,
16+
2 ],
17+
b: { j: [
18+
{ l: 1 }]
19+
},
20+
c:
21+
{ j: [
22+
{ l: 1 }]
23+
},
24+
};
25+
26+
const a =
27+
{
28+
b: 1
29+
};
30+
31+
const x = {
32+
g: {
33+
a: 1,
34+
b: 2
35+
},
36+
h: {
37+
c: 3
38+
}
39+
}

spec/fixtures/indentation/switch.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
switch (e) {
3+
case 5:
4+
something();
5+
more();
6+
case 6:
7+
somethingElse();
8+
case 7:
9+
default:
10+
done();
11+
}

spec/fixtures/indentation/while.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/** While loops */
2+
while (condition)
3+
inLoop();
4+
5+
while (condition)
6+
inLoop();
7+
after();
8+
9+
while (mycondition) {
10+
sdfsdfg();
11+
}
12+
13+
while (mycondition)
14+
{
15+
sdfsdfg();
16+
}
17+
18+
while (mycond)
19+
if (more)
20+
doit;
21+
after();
22+
23+
while (mycond) if (more)
24+
doit;
25+
after();
26+
27+
while (mycondition) {
28+
sdfsdfg();
29+
if (test) {
30+
more()
31+
}}
32+
33+
while (mycondition)
34+
if (test) {
35+
more()
36+
}

0 commit comments

Comments
 (0)