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