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