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