-
Notifications
You must be signed in to change notification settings - Fork 1
/
alternate_styles.js
117 lines (92 loc) · 2.48 KB
/
alternate_styles.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//This file describes the js-lazy-commas, js-lazy-operators, and
// js-lazy-dots config options.
//It is recommended that if you use js-lazy-commas or js-lazy-operators,
// then you should use both, due to the funky indentation it causes otherwise
/*
// To turn on all 3, add the following to your .emacs file:
(custom-set-variables
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(js-lazy-commas t)
'(js-lazy-operators t)
'(js-lazy-dots t)
'(js-expr-indent-offset 2)
'(js-paren-indent-offset 2)
'(js-square-indent-offset 2)
'(js-curly-indent-offset 2))
*/
/*
* js-lazy-commas
*/
//By default, js-mode supports the following comma-first style:
var obj1 = { prop1: { prop1: "val1"
, prop2: "val2"
}
, prop2: "val3"
}
//By turning on js-lazy-commas with the recommended settings, you can use
// the following style:
var obj2 = {
prop1: {
prop1: "val1"
, prop2: "val2"
}
, prop2: "val3"
}
//Turn this on by putting the following in your .emacs file:
/*
(custom-set-variables
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(js-lazy-commas t)
'(js-expr-indent-offset 2)
'(js-paren-indent-offset 2)
'(js-square-indent-offset 2)
'(js-curly-indent-offset 2))
*/
/*
* js-lazy-operators
*/
//By default, js-mode supports the following operator-first style:
var result1 = ( 5
+ 7
/ 2
* 5
)
//By turning on js-lazy-operators with the recommended settings, you can use
// the following style:
var result2 = (
5
+ 7
/ 2
* 5
)
//Turn this on by putting the following in your .emacs file:
/*
(custom-set-variables
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(js-lazy-operators t)
'(js-expr-indent-offset 2)
'(js-paren-indent-offset 2)
'(js-square-indent-offset 2)
'(js-curly-indent-offset 2))
*/
/*
* js-lazy-dots
*/
//By default, js-mode supports the following dot-first style:
//(indent to the previous dot)
foo.bar()
.baz()
//By turning on js-lazy-dots, you can use the following style:
//(indent once)
foo.bar()
.baz()
//Turn this on by putting the following in your .emacs file:
/*
(custom-set-variables
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(js-lazy-dots t)
*/