summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
blob: 146ee76574e6cb1627af42a6113352ebe942c82a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Code:
  (lambda ()
    (setq indent-tabs-mode nil)
    (setq typescript-ts-mode-indent-offset 2)
    (typescript-ts-mode)
    (indent-region (point-min) (point-max)))

Point-Char: |

Name: Basic indentation

=-=
const foo = () => {
  console.log("bar");
  if (x) {
    return y;
  } else if (y) {
    return u;
  }
  return baz.x()
    ? true
    : false;
}
=-=-=

Code:
  (lambda ()
    (setq indent-tabs-mode nil)
    (setq tsx-ts-mode-indent-offset 2)
    (tsx-ts-mode)
    (indent-region (point-min) (point-max)))

Name: JSX indentation

=-=
const foo = (props) => {
  return (
    <div>
      <div>
        <div>
          <div>
            {
              props.foo
                ? Hello, foo!
                : Hello, World!;
            }
          </div>
        </div>
      </div>
    </div>
  );
}
=-=-=

Name: JSX indentation with attributes

=-=
const foo = (props) => {
  return (
    <div
      className={foo}
      onClick={() => {
        alert('???');
        return () => {
          return 5+5;
        };
      }}
    >
      <p>Some text</p>
    </div>
  );
}
=-=-=