]> code.delx.au - gnu-emacs-elpa/blob - NEWS.md
Add a NEWS entry for d4d9c54
[gnu-emacs-elpa] / NEWS.md
1 # History of user-visible changes
2
3 ## Next
4
5 * `js2-pretty-multiline-declarations` can take the value `dynamic` now.
6
7 ## 20150202
8
9 Support for:
10
11 * [ES6 modules](http://www.2ality.com/2014/09/es6-modules-final.html).
12 * [Short-hand object literals](http://ariya.ofilabs.com/2013/02/es6-and-object-literal-property-value-shorthand.html).
13 * [Method definitions](http://ariya.ofilabs.com/2013/03/es6-and-method-definitions.html).
14 * ['u' and 'y' RegExp flags](https://mathiasbynens.be/notes/es6-unicode-regex).
15 * [Computed property names](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer).
16 * [Class statements and expressions](https://github.com/lukehoban/es6features#classes).
17 * [Template strings](http://tc39wiki.calculist.org/es6/template-strings/), including tagged ones.
18
19 The variable `js2-allow-keywords-as-property-names` has been
20 removed. Instead we check if `js2-language-version` is 180 or highter.
21
22 ## 20141115
23
24 Support for:
25
26 * Unicode characters in identifiers (improved).
27 * [Delegating yield](http://wiki.ecmascript.org/doku.php?id=harmony:generators#delegating_yield).
28 * [ES6 numeric literals](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-numeric-literals) (octal, binary).
29 * Harmony [array and generator comprehensions](http://wingolog.org/archives/2014/03/07/es6-generator-and-array-comprehensions-in-spidermonkey).
30
31 ## 20131106
32
33 Support for:
34
35 * [Arrow functions](http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax)
36 * [Generators](http://wiki.ecmascript.org/doku.php?id=harmony:generators)
37 * [Spread operator](http://wiki.ecmascript.org/doku.php?id=harmony:spread)
38
39 ## 20130510
40
41 ### Support for JSLint global declaration
42
43 See the docstring for `js2-include-jslint-globals`.
44
45 ## 20130216
46
47 ### We don't rebind `RET` anymore
48
49 Because well-behaving major modes aren't supposed to do that.
50
51 So pressing it won't continue a block comment, or turn a string into a concatenation.
52 Pressing `M-j`, however, will.
53
54 The options `js2-indent-on-enter-key` and `js2-enter-indents-newline` were also removed.
55
56 To bring back the previous behavior, put this in your init file:
57
58 ```js
59 (eval-after-load 'js2-mode
60 '(define-key js2-mode-map (kbd "RET") 'js2-line-break))
61 ```
62
63 ## 20120617
64
65 ### Support for [default](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/default_parameters) and [rest](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/rest_parameters) parameters
66
67 ## 20120614
68
69 ### Support for [for..of loops](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)
70
71 ## Older changes
72
73 ### Popular indentation style
74
75 ```js
76 [foo, bar, baz].forEach(function (v) {
77 if (validate(v))
78 process(v);
79 });
80
81 [a, b, c].some(function (v) {
82 return validate(v);
83 });
84 ```
85
86 ### Pretty multiline variable declaration
87
88 In the original mode,
89
90 ```js
91 var foo = 10,
92 bar = 20,
93 baz = 30;
94 ```
95
96 In this mode when the value of `js2-pretty-multiline-declarations` is non-nil,
97
98 ```js
99 var foo = 10,
100 bar = 20,
101 baz = 30;
102 ```
103
104 ### Abbreviated destructuring assignments
105
106 ```js
107 let {a, b} = {a: 10, b: 20}; // Abbreviated (Not supported in the original mode)
108 let {a: a, b: b} = {a: 10, b: 20}; // Same as above (Supported in the original mode)
109
110 (function ({responseText}) { /* */ })(xhr); // As the argument of function
111
112 for (let [k, { name, age }] in Iterator(obj)) // nested
113 print(k, name, age);
114 ```
115
116 ### Expression closure in property value
117
118 ```js
119 let worker = {
120 get age() 20,
121 get sex() "male",
122 fire: function () _fire()
123 };
124 ```
125
126 ### Fix for odd indentation of "else if" with no braces
127
128 In the original mode,
129
130 ```js
131 if (foo)
132 return foo;
133 else if (bar)
134 return bar; // here
135 ```
136
137 In this mode,
138
139 ```js
140 if (foo)
141 return foo;
142 else if (bar)
143 return bar; // fixed
144 ```
145
146 ### Imenu support for function nesting
147
148 Supports function nesting and anonymous wrappers:
149
150 ```js
151 (function() {
152 var foo = function() {
153 function bar() { // shown as foo.bar.<definition-1>
154 function baz() {} // foo.bar.baz
155 var qux = function() {}; // foo.bar.quux
156 }
157 };
158 });
159 ```
160
161 Examples of output:
162
163 * [jQuery 1.5](https://gist.github.com/845449)
164 * [Underscore.js](https://gist.github.com/824262)
165 * [Backbone.js](https://gist.github.com/824260)
166
167 For library-specific extension methods like `$.extend` and `dojo.declare`, see [js2-imenu-extras](/mooz/js2-mode/blob/master/js2-imenu-extras.el).
168
169 ### Undeclared/external variables highlighting
170
171 Original mode highlights them only on the left side of assignments:
172
173 ```js
174 var house;
175 hose = new House(); // highlights "hose"
176 ```
177
178 Here they are highlighted in all expressions:
179
180 ```js
181 function feed(fishes, food) {
182 for each (var fish in fshes) { // highlights "fshes"
183 food.feed(fsh); // highlights "fsh"
184 }
185 hood.discard(); // highlights "hood"
186 }
187 ```
188
189 Destructuring assignments and array comprehensions (JS 1.7) are supported:
190
191 ```js
192 let three, [one, two] = [1, 2];
193 thee = one + two; // highlights "thee"
194
195 function revenue(goods) {
196 // highlights "coast"
197 return [price - coast for each ({price, cost} in goods)].reduce(add);
198 }
199 ```