js-beautify 1.7.1 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,49 @@
1
1
  # Changelog
2
+ ## v1.7.5
3
+
4
+ ### Description
5
+
6
+
7
+ ### Closed Issues
8
+ * Strict mode: js_source_text is not defined [CSS] ([#1286](https://github.com/beautify-web/js-beautify/issues/1286))
9
+ * Made brace_style option more inclusive ([#1277](https://github.com/beautify-web/js-beautify/pull/1277))
10
+ * White space before"!important" tag missing in CSS beautify ([#1273](https://github.com/beautify-web/js-beautify/issues/1273))
11
+
12
+
13
+ ## v1.7.4
14
+
15
+ ### Description
16
+ Thanks @cejast for contributing!
17
+
18
+ ### Closed Issues
19
+ * Whitespace after ES7 `async` keyword for arrow functions ([#896](https://github.com/beautify-web/js-beautify/issues/896))
20
+
21
+
22
+ ## v1.7.3
23
+
24
+ ### Description
25
+ * Fixed broken installs
26
+
27
+ Lessons learned:
28
+ * Don't publish and go to bed.
29
+ * I thought I had sufficient test coverage and I did not. Tests will be implemented to protect against this before the next release (#1254).
30
+ * Also, this break highlights the need to create a beta channel for releases and a way to request feedback on beta releases (#1255).
31
+ * The project has been maintained by mostly one person over the past year or so, with some additions by other individuals. This break also highlights the need for this project to have a few more people who have the ability address issues/emergencies (#1256).
32
+ * Many projects do not not lock or even limit their version dependencies. Those that do often use `^x.x.x` instead of `~x.x.x`. Consider switching to making major version updates under more circumstances to limit risk to dependent projects. (#1257)
33
+
34
+
35
+ ### Closed Issues
36
+ * Version 1.7.0 fail to install through pip ([#1250](https://github.com/beautify-web/js-beautify/issues/1250))
37
+ * Installing js-beautify fails ([#1247](https://github.com/beautify-web/js-beautify/issues/1247))
38
+
39
+
2
40
  ## v1.7.0
3
41
 
4
42
  ### Description
5
43
 
6
44
 
7
45
  ### Closed Issues
46
+ * undindent-chained-methods option. Resolves #482 ([#1240](https://github.com/beautify-web/js-beautify/pull/1240))
8
47
  * Add test and tools folder to npmignore ([#1239](https://github.com/beautify-web/js-beautify/issues/1239))
9
48
  * incorrect new-line insertion after "yield" ([#1206](https://github.com/beautify-web/js-beautify/issues/1206))
10
49
  * Do not modify built-in objects ([#1205](https://github.com/beautify-web/js-beautify/issues/1205))
@@ -0,0 +1,138 @@
1
+ # Contributing
2
+
3
+
4
+ ## Report Issues and Request Changes
5
+ If you find a bug, please report it, including environment and examples of current behavior and what you believe to be the correct behavior. The clearer your description and information, the more likely it is someone will be able to make progress on it. The default issue template will help guide you through this.
6
+
7
+ ## How to Make Changes (Implement Fixes and New Features)
8
+ Fixes and enhancements are totally welcome. We prefer if you file an issue before filing a PR, as this gives us chance to discuss design details, but fee free to dive right in.
9
+
10
+ ### 1. Build and Test Locally
11
+ While developing, you may build and test locally in JavaScript or Python implementation. The HTML beautifier is only implemented in JavaScript.
12
+
13
+ * Familiarize yourself with the folder structure and code style before you dive in.
14
+ * Make changes to the implementation of your choice
15
+ * Add tests to `/test/data/*/test.js`.
16
+ * Run `./build jstest` or `./build pytest` to run style checks, and to generate and run tests.
17
+ * Include all changed files in your commit - The generated test files are checked in along with changes to the test data files.
18
+
19
+ ### 2. Ensure Feature Parity
20
+ You must port changes to the other implementation. **This is required**. Every time we make an exception to this requirement the project becomes harder to maintain. If you find yourself making changes and find you cannot port them to the other implementation due to implementations being out of sync, you will begin to understand why this is required. We made this a requirement several years ago and there are still a open issues for changes that people at the time promised to port "in the next week or two". The entire HTML beautifier is an example of this. :(
21
+
22
+ The implementations are already very similar and neither Python nor JavaScript are that hard to understand. Take the plunge, it is easier than you think. If you get stuck, move on to filing a Pull Request and we can discuss how to move forward.
23
+
24
+ * Run `./build` (with no parameters) to run style checks, and to generate and run tests on both implementations.
25
+ * Include all changed files in your commit - The generated test files are checked in along with changes to the test data files.
26
+
27
+ ### 3. Update Documentation and Tools
28
+ Update documentation as needed. This such as the README.md, internal command-line help, and file comments.
29
+ Also, check your change needs any tooling updates. For example, the CDN URLs required added scripting to update automatically for new releases.
30
+
31
+ ### 4. Submit a Pull Request
32
+
33
+ * Run `./build full` locally after commit but before creation of Pull Request. You may start a Pull Request if this does not succeed, but the PR will not be accepted without additional changes.
34
+ * Include description of changes. Include examples of input and expected output if possible.
35
+ * Pull requests must pass build checks on all platforms before being accepted. We use Travis CI and AppVeyor to run tests on Linux and Windows, across multiple versions of Node.js and Python.
36
+
37
+ # Folders
38
+
39
+ ## Root
40
+ Some files related to specific implementations or platforms are found in the root folder, but most are cross-project tools and configuration.
41
+
42
+ ## `js`
43
+ Files related to the JavaScript implementations of the beautifiers.
44
+
45
+ ## `python`
46
+ Files related to the Python implementations of the beautifiers.
47
+
48
+
49
+ ## `web`
50
+ Files related to http://jsbeautifier.org/.
51
+
52
+ ## `test`
53
+ Test data files and support files used to generate implementation-specific test files from them.
54
+
55
+
56
+ # Branches
57
+ We use the `master` branch as the primary development branch.
58
+
59
+ ## Releases
60
+ Each platform has a branch that tracks to the latest release of that platform.
61
+
62
+ * `python-stable`
63
+ * `node-stable`
64
+ * `gh-pages`
65
+
66
+ ## Functional Parity
67
+ Keeping the platforms in some semblance of functional parity is one of the key features of this project. As such, there branches for the last time synchronization occurred and when it stabilized.
68
+
69
+ * `sync`
70
+ * `sync-stable`
71
+
72
+ ## Attic
73
+ This project has been around for a while. While some parts have improved significantly over time, others fell
74
+ into disrepair and were mothballed.
75
+
76
+ ### PHP
77
+ There is an out-of-date version of the beautifier available on branch `attic-php`. If you're interested
78
+ in using it feel free. If you plan to enhance it, please consider joining this project, and updating this
79
+ version to match current functionality.
80
+
81
+ ### Other Languages
82
+ Versions of the beautifier adapted to other languages are at least two years out-of-date and are
83
+ available on branch `attic-other`. Take a look and feel free to resurrect them, but know it's pretty
84
+ dusty back there.
85
+
86
+ ### Generic Eval Unpacker
87
+ The `attic-genericeval` branch includes an unpacker that call `eval` on whatever source is passed to it.
88
+ Useful when working with source that unpacks itself when eval is called on it, but also unsafe. We keep
89
+ it on this separate branch to keep it from hurting the other children.
90
+
91
+ # Publishing a Release
92
+ Each platform has it's own release process.
93
+
94
+ NOTE: Before you do any of these make sure the latest changes have passed the Travis CI build!
95
+
96
+ ## Web
97
+ Merge changes from `master` to `gh-pages` branch. This is very low cost and can be done whenever is convenient.
98
+
99
+ ## Python
100
+ NOTE: For now, we'd like to keep Python and Node version numbers synchronized,
101
+ so if you publish a Python release, you should publish a Node release as well.
102
+
103
+ To perform these steps you will need:
104
+ 1. A PyPI user account from https://pypi.python.org/pypi?%3Aaction=register_form.
105
+ 2. Permissions to the jsbeautifier package. File an issue here on GitHub and the appropriate person will help you.
106
+
107
+ We basically follow the simplest release path found at http://docs.python.org/2/distutils/packageindex.html:
108
+ ```bash
109
+ git clean -xfd
110
+ # replace 0.0.1 with the actual version number you want to use
111
+ NEW_VERSION=0.0.1
112
+ echo "__version__ = '$NEW_VERSION'" > python/jsbeautifier/__version__.py
113
+ git commit -am "Python $NEW_VERSION"
114
+ cd python
115
+ python setup.py register
116
+ python setup.py sdist bdist_wininst upload
117
+ git push
118
+ ```
119
+
120
+ ## Node
121
+ NOTE: For now, we'd like to keep Python and Node version numbers synchronized,
122
+ so if you plan to publish a Node release, you should publish a Python release *first*,
123
+ then perform the steps below.
124
+
125
+ To perform these steps you will need:
126
+ 1. An npmjs.org user account from https://npmjs.org/signup.
127
+ 2. Permissions to the js-beautify module on npmjs.org. File an issue here on GitHub and the appropriate person will help you.
128
+
129
+ Npm makes this process even simpler than Python's and creates a tag for the release as well.
130
+
131
+ ```bash
132
+ git clean -xfd
133
+ # replace 0.0.1 with the actual version number you want to use
134
+ NEW_VERSION=0.0.1
135
+ npm version $NEW_VERSION
136
+ npm publish .
137
+ git push --tags
138
+ ```
package/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # JS Beautifier
2
- [![Build Status](https://img.shields.io/travis/beautify-web/js-beautify/master.svg)](http://travis-ci.org/beautify-web/js-beautify)
2
+ [![Build Status](https://api.travis-ci.org/beautify-web/js-beautify.svg?branch=master)](http://travis-ci.org/beautify-web/js-beautify)
3
3
  [![Build status](https://ci.appveyor.com/api/projects/status/5bxmpvew5n3e58te/branch/master?svg=true)](https://ci.appveyor.com/project/beautify-web/js-beautify/branch/master)
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/jsbeautifier.svg)](https://pypi.python.org/pypi/jsbeautifier)
4
6
  [![CDNJS version](https://img.shields.io/cdnjs/v/js-beautify.svg)](https://cdnjs.com/libraries/js-beautify)
5
7
  [![NPM version](https://img.shields.io/npm/v/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
6
8
  [![Download stats](https://img.shields.io/npm/dm/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
9
+
7
10
  [![Join the chat at https://gitter.im/beautify-web/js-beautify](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/beautify-web/js-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
11
+ [![Twitter Follow](https://img.shields.io/twitter/follow/js_beautifier.svg?style=social&label=Follow)](https://twitter.com/intent/user?screen_name=js_beautifier)
8
12
 
9
13
  [![NPM stats](https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true)](https://www.npmjs.org/package/js-beautify)
10
14
 
@@ -21,17 +25,17 @@ JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries
21
25
 
22
26
  To pull from one of these services include one set of the script tags below in your document:
23
27
  ```html
24
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify.js"></script>
25
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify-css.js"></script>
26
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify-html.js"></script>
28
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify.js"></script>
29
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify-css.js"></script>
30
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify-html.js"></script>
27
31
 
28
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify.min.js"></script>
29
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify-css.min.js"></script>
30
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.0/beautify-html.min.js"></script>
32
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify.min.js"></script>
33
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify-css.min.js"></script>
34
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify-html.min.js"></script>
31
35
 
32
- <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.0/js/lib/beautify.js"></script>
33
- <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.0/js/lib/beautify-css.js"></script>
34
- <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.0/js/lib/beautify-html.js"></script>
36
+ <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.5/js/lib/beautify.js"></script>
37
+ <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.5/js/lib/beautify-css.js"></script>
38
+ <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.5/js/lib/beautify-html.js"></script>
35
39
  ```
36
40
  Disclaimer: These are free services, so there are [no uptime or support guarantees](https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#i-need-guaranteed-100-uptime-should-i-use-cdnrawgitcom).
37
41
 
@@ -274,7 +278,7 @@ HTML Beautifier Options:
274
278
  -A, --wrap-attributes Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] ["auto"]
275
279
  -i, --wrap-attributes-indent-size Indent wrapped attributes to after N characters [indent-size] (ignored if wrap-attributes is "force-aligned")
276
280
  -U, --unformatted List of tags (defaults to inline) that should not be reformatted
277
- -T, --content_unformatted List of tags (defaults to pre) that its content should not be reformatted
281
+ -T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted
278
282
  -E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline before them.
279
283
  --editorconfig Use EditorConfig to set up the options
280
284
  ```
@@ -318,4 +322,4 @@ Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D
318
322
  Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
319
323
  Mathias Bynens, Vittorio Gambaletta and others.
320
324
 
321
- (README.md: js-beautify@1.7.0)
325
+ (README.md: js-beautify@1.7.5)
@@ -335,7 +335,7 @@ function Beautifier(source_text, options) {
335
335
  preindent_index += 1;
336
336
  }
337
337
  baseIndentString = source_text.substring(0, preindent_index);
338
- js_source_text = source_text.substring(preindent_index);
338
+ source_text = source_text.substring(preindent_index);
339
339
  }
340
340
 
341
341
 
@@ -584,7 +584,9 @@ function Beautifier(source_text, options) {
584
584
  if (whiteRe.test(ch)) {
585
585
  ch = '';
586
586
  }
587
-
587
+ } else if (ch === '!') { // !important
588
+ print_string(' ');
589
+ print_string(ch);
588
590
  } else {
589
591
  preserveSingleSpace(isAfterSpace);
590
592
  print_string(ch);
@@ -48,7 +48,7 @@
48
48
  brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
49
49
  put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
50
50
  unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
51
- content_unformatted (defaults to pre tag) - list of tags, that its content shouldn't be reformatted
51
+ content_unformatted (defaults to pre tag) - list of tags, whose content shouldn't be reformatted
52
52
  indent_scripts (default normal) - "keep"|"separate"|"normal"
53
53
  preserve_newlines (default true) - whether existing line breaks before elements should be preserved
54
54
  Only works before elements, not inside tags or for text.
@@ -425,15 +425,22 @@ function Beautifier(js_source_text, options) {
425
425
  options.brace_style = "collapse,preserve-inline";
426
426
  } else if (options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
427
427
  options.brace_style = options.braces_on_own_line ? "expand" : "collapse";
428
- } else if (!options.brace_style) //Nothing exists to set it
429
- {
428
+ } else if (!options.brace_style) { //Nothing exists to set it
430
429
  options.brace_style = "collapse";
431
430
  }
432
431
 
433
-
432
+ //preserve-inline in delimited string will trigger brace_preserve_inline, everything
433
+ //else is considered a brace_style and the last one only will have an effect
434
434
  var brace_style_split = options.brace_style.split(/[^a-zA-Z0-9_\-]+/);
435
- opt.brace_style = brace_style_split[0];
436
- opt.brace_preserve_inline = brace_style_split[1] ? brace_style_split[1] : false;
435
+ opt.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
436
+ opt.brace_style = "collapse";
437
+ for (var bs = 0; bs < brace_style_split.length; bs++) {
438
+ if (brace_style_split[bs] === "preserve-inline") {
439
+ opt.brace_preserve_inline = true;
440
+ } else {
441
+ opt.brace_style = brace_style_split[bs];
442
+ }
443
+ }
437
444
 
438
445
  opt.indent_size = options.indent_size ? parseInt(options.indent_size, 10) : 4;
439
446
  opt.indent_char = options.indent_char ? options.indent_char : ' ';
@@ -878,8 +885,8 @@ function Beautifier(js_source_text, options) {
878
885
  }
879
886
  }
880
887
 
881
- // Should be a space between await and an IIFE
882
- if (current_token.text === '(' && last_type === 'TK_RESERVED' && flags.last_word === 'await') {
888
+ // Should be a space between await and an IIFE, or async and an arrow function
889
+ if (current_token.text === '(' && last_type === 'TK_RESERVED' && in_array(flags.last_word, ['await', 'async'])) {
883
890
  output.space_before_token = true;
884
891
  }
885
892
 
package/js/lib/cli.js CHANGED
@@ -41,20 +41,23 @@ var fs = require('fs'),
41
41
  beautify = require('../index'),
42
42
  mkdirp = require('mkdirp'),
43
43
  nopt = require('nopt');
44
+ nopt.invalidHandler = function(key, val, types) {
45
+ throw new Error(key + " was invalid with value \"" + val + "\"");
46
+ }
44
47
  nopt.typeDefs.brace_style = {
45
48
  type: "brace_style",
46
49
  validate: function(data, key, val) {
47
50
  data[key] = val;
48
51
  // TODO: expand-strict is obsolete, now identical to expand. Remove in future version
49
52
  // TODO: collapse-preserve-inline is obselete, now identical to collapse,preserve-inline = true. Remove in future version
50
- var validVals = ["collapse", "collapse-preserve-inline", "expand", "end-expand", "expand-strict", "none"];
51
- var valSplit = val.split(/[^a-zA-Z0-9_\-]+/);
52
- for (var i = 0; i < validVals.length; i++) {
53
- if (validVals[i] === val || validVals[i] === valSplit[0] && valSplit[1] === "preserve-inline") {
54
- return true;
53
+ var validVals = ["collapse", "collapse-preserve-inline", "expand", "end-expand", "expand-strict", "none", "preserve-inline"];
54
+ var valSplit = val.split(/[^a-zA-Z0-9_\-]+/); //Split will always return at least one parameter
55
+ for (var i = 0; i < valSplit.length; i++) {
56
+ if (validVals.indexOf(valSplit[i]) === -1) {
57
+ return false;
55
58
  }
56
59
  }
57
- return false;
60
+ return true;
58
61
  }
59
62
  };
60
63
  var path = require('path'),
@@ -235,7 +238,16 @@ function set_file_editorconfig_opts(file, config) {
235
238
 
236
239
  // var cli = require('js-beautify/cli'); cli.interpret();
237
240
  var interpret = exports.interpret = function(argv, slice) {
238
- var parsed = nopt(knownOpts, shortHands, argv, slice);
241
+ var parsed;
242
+ try {
243
+ parsed = nopt(knownOpts, shortHands, argv, slice);
244
+ } catch (ex) {
245
+ usage(ex);
246
+ // console.error(ex);
247
+ // console.error('Run `' + getScriptName() + ' -h` for help.');
248
+ process.exit(1);
249
+ }
250
+
239
251
 
240
252
  if (parsed.version) {
241
253
  console.log(require('../../package.json').version);
@@ -359,7 +371,7 @@ function usage(err) {
359
371
  msg.push(' -p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)');
360
372
  msg.push(' -m, --max-preserve-newlines Number of line-breaks to be preserved in one chunk [10]');
361
373
  msg.push(' -U, --unformatted List of tags (defaults to inline) that should not be reformatted');
362
- msg.push(' -T, --content_unformatted List of tags (defaults to pre) that its content should not be reformatted');
374
+ msg.push(' -T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted');
363
375
  msg.push(' -E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline');
364
376
  break;
365
377
  case "css":
@@ -196,7 +196,7 @@ function Beautifier(source_text, options) {
196
196
  preindent_index += 1;
197
197
  }
198
198
  baseIndentString = source_text.substring(0, preindent_index);
199
- js_source_text = source_text.substring(preindent_index);
199
+ source_text = source_text.substring(preindent_index);
200
200
  }
201
201
 
202
202
 
@@ -445,7 +445,9 @@ function Beautifier(source_text, options) {
445
445
  if (whiteRe.test(ch)) {
446
446
  ch = '';
447
447
  }
448
-
448
+ } else if (ch === '!') { // !important
449
+ print_string(' ');
450
+ print_string(ch);
449
451
  } else {
450
452
  preserveSingleSpace(isAfterSpace);
451
453
  print_string(ch);
@@ -193,15 +193,22 @@ function Beautifier(js_source_text, options) {
193
193
  options.brace_style = "collapse,preserve-inline";
194
194
  } else if (options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
195
195
  options.brace_style = options.braces_on_own_line ? "expand" : "collapse";
196
- } else if (!options.brace_style) //Nothing exists to set it
197
- {
196
+ } else if (!options.brace_style) { //Nothing exists to set it
198
197
  options.brace_style = "collapse";
199
198
  }
200
199
 
201
-
200
+ //preserve-inline in delimited string will trigger brace_preserve_inline, everything
201
+ //else is considered a brace_style and the last one only will have an effect
202
202
  var brace_style_split = options.brace_style.split(/[^a-zA-Z0-9_\-]+/);
203
- opt.brace_style = brace_style_split[0];
204
- opt.brace_preserve_inline = brace_style_split[1] ? brace_style_split[1] : false;
203
+ opt.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
204
+ opt.brace_style = "collapse";
205
+ for (var bs = 0; bs < brace_style_split.length; bs++) {
206
+ if (brace_style_split[bs] === "preserve-inline") {
207
+ opt.brace_preserve_inline = true;
208
+ } else {
209
+ opt.brace_style = brace_style_split[bs];
210
+ }
211
+ }
205
212
 
206
213
  opt.indent_size = options.indent_size ? parseInt(options.indent_size, 10) : 4;
207
214
  opt.indent_char = options.indent_char ? options.indent_char : ' ';
@@ -646,8 +653,8 @@ function Beautifier(js_source_text, options) {
646
653
  }
647
654
  }
648
655
 
649
- // Should be a space between await and an IIFE
650
- if (current_token.text === '(' && last_type === 'TK_RESERVED' && flags.last_word === 'await') {
656
+ // Should be a space between await and an IIFE, or async and an arrow function
657
+ if (current_token.text === '(' && last_type === 'TK_RESERVED' && in_array(flags.last_word, ['await', 'async'])) {
651
658
  output.space_before_token = true;
652
659
  }
653
660
 
@@ -569,6 +569,10 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea
569
569
  '.div {}\n' +
570
570
  '\n' +
571
571
  '.span {}');
572
+ t(
573
+ 'html {}\n' +
574
+ '\n' +
575
+ '/*this is a comment*/');
572
576
  t(
573
577
  '.div {\n' +
574
578
  '\ta: 1;\n' +
@@ -1251,6 +1255,31 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea
1251
1255
  '}');
1252
1256
 
1253
1257
 
1258
+ //============================================================
1259
+ // Important
1260
+ reset_options();
1261
+ t(
1262
+ 'a {\n' +
1263
+ '\tcolor: blue !important;\n' +
1264
+ '}',
1265
+ // -- output --
1266
+ 'a {\n' +
1267
+ '\tcolor: blue !important;\n' +
1268
+ '}');
1269
+ t(
1270
+ 'a {\n' +
1271
+ '\tcolor: blue!important;\n' +
1272
+ '}',
1273
+ // -- output --
1274
+ 'a {\n' +
1275
+ '\tcolor: blue !important;\n' +
1276
+ '}');
1277
+ t(
1278
+ 'a {\n' +
1279
+ '\tcolor: blue !important;\n' +
1280
+ '}');
1281
+
1282
+
1254
1283
  //============================================================
1255
1284
  //
1256
1285
  reset_options();
@@ -1725,6 +1725,44 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
1725
1725
 
1726
1726
  // ensure that this doesn't break anyone with the async library
1727
1727
  bt('async.map(function(t) {})');
1728
+
1729
+ // async on arrow function. should have a space after async
1730
+ bt(
1731
+ 'async() => {}',
1732
+ // -- output --
1733
+ 'async () => {}');
1734
+
1735
+ // async on arrow function. should have a space after async
1736
+ bt(
1737
+ 'async() => {\n' +
1738
+ ' return 5;\n' +
1739
+ '}',
1740
+ // -- output --
1741
+ 'async () => {\n' +
1742
+ ' return 5;\n' +
1743
+ '}');
1744
+
1745
+ // async on arrow function returning expression. should have a space after async
1746
+ bt(
1747
+ 'async() => 5;',
1748
+ // -- output --
1749
+ 'async () => 5;');
1750
+
1751
+ // async on arrow function returning object literal. should have a space after async
1752
+ bt(
1753
+ 'async(x) => ({\n' +
1754
+ ' foo: "5"\n' +
1755
+ '})',
1756
+ // -- output --
1757
+ 'async (x) => ({\n' +
1758
+ ' foo: "5"\n' +
1759
+ '})');
1760
+ bt(
1761
+ 'async (x) => {\n' +
1762
+ ' return x * 2;\n' +
1763
+ '}');
1764
+ bt('async () => 5;');
1765
+ bt('async x => x * 2;');
1728
1766
 
1729
1767
 
1730
1768
  //============================================================
@@ -55,7 +55,6 @@ test_cli_common()
55
55
  echo "[$CLI_SCRIPT_NAME $MISSING_FILE] Stdout should have no text."
56
56
  exit 1
57
57
  fi
58
-
59
58
  }
60
59
 
61
60
  setup_temp()
@@ -341,6 +340,20 @@ test_cli_js_beautify()
341
340
  cleanup 1
342
341
  }
343
342
 
343
+ #meta-parameter brace_style
344
+ $CLI_SCRIPT -b 'invalid' $TEST_TEMP/example1-default.js > /dev/null && {
345
+ echo "[$CLI_SCRIPT_NAME -b 'invalid' $TEST_TEMP/example1-default.js] Return code for invalid brace_style meta-parameter should be error."
346
+ cleanup 1
347
+ }
348
+ $CLI_SCRIPT -b 'expand,preserve-inline,invalid' $TEST_TEMP/example1-default.js > /dev/null && {
349
+ echo "[$CLI_SCRIPT_NAME -b 'expand,preserve-inline,invalid' $TEST_TEMP/example1-default.js] Return code for invalid brace_style meta-parameter should be error."
350
+ cleanup 1
351
+ }
352
+ $CLI_SCRIPT -b 'preserve-inline' $TEST_TEMP/example1-default.js > /dev/null || {
353
+ echo "[$CLI_SCRIPT_NAME -b 'preserve-inline' $TEST_TEMP/example1-default.js] Return code for only one part of valid brace_style meta-parameter should be success (uses default where it can)."
354
+ cleanup 1
355
+ }
356
+
344
357
  cleanup
345
358
  }
346
359
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-beautify",
3
- "version": "1.7.1",
3
+ "version": "1.7.5",
4
4
  "description": "jsbeautifier.org for node",
5
5
  "main": "js/index.js",
6
6
  "bin": {