Permalink
Browse files

Merge remote-tracking branch 'origin/master' into gh-pages

  • Loading branch information...
2 parents 9f54d68 + 5656c0e commit 5d7fc67fb3a014999640a94940b65e1d22bd0795 @bitwiseman bitwiseman committed Oct 9, 2017
View
@@ -1,4 +1,13 @@
# Changelog
+## v1.7.4
+
+### Description
+Thanks @cejast for contributing!
+
+### Closed Issues
+* Whitespace after ES7 `async` keyword for arrow functions ([#896](https://github.com/beautify-web/js-beautify/issues/896))
+
+
## v1.7.3
### Description
View
@@ -93,10 +93,10 @@ Each platform has it's own release process.
NOTE: Before you do any of these make sure the latest changes have passed the travis-ci build!
-##Web
+## Web
Merge changes from `master` to `gh-pages` branch. This is very low cost and can be done whenever is convenient.
-##Python
+## Python
NOTE: For now, we'd like to keep python and node version numbers synchronized,
so if you publish a python release, you should publish a node release as well.
@@ -118,7 +118,7 @@ python setup.py sdist bdist_wininst upload
git push
```
-##Node
+## Node
NOTE: For now, we'd like to keep python and node version numbers synchronized,
so if you plan to publish a node release, you should publish a python release *first*,
then perform the steps below.
View
@@ -1,9 +1,12 @@
# JS Beautifier
-[![Build Status](https://img.shields.io/travis/beautify-web/js-beautify/master.svg)](http://travis-ci.org/beautify-web/js-beautify)
+[![Build Status](https://api.travis-ci.org/beautify-web/js-beautify.svg?branch=master)](http://travis-ci.org/beautify-web/js-beautify)
[![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)
+
+[![PyPI version](https://img.shields.io/pypi/v/jsbeautifier.svg)](https://pypi.python.org/pypi/jsbeautifier)
[![CDNJS version](https://img.shields.io/cdnjs/v/js-beautify.svg)](https://cdnjs.com/libraries/js-beautify)
[![NPM version](https://img.shields.io/npm/v/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
[![Download stats](https://img.shields.io/npm/dm/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
+
[![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)
[![NPM stats](https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true)](https://www.npmjs.org/package/js-beautify)
@@ -21,17 +24,17 @@ JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries
To pull from one of these services include one set of the script tags below in your document:
```html
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify-css.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify-html.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify-css.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify-html.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify.min.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify-css.min.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.3/beautify-html.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify-css.min.js"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.4/beautify-html.min.js"></script>
-<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.3/js/lib/beautify.js"></script>
-<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.3/js/lib/beautify-css.js"></script>
-<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.3/js/lib/beautify-html.js"></script>
+<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.4/js/lib/beautify.js"></script>
+<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.4/js/lib/beautify-css.js"></script>
+<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.7.4/js/lib/beautify-html.js"></script>
```
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).
@@ -274,7 +277,7 @@ HTML Beautifier Options:
-A, --wrap-attributes Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] ["auto"]
-i, --wrap-attributes-indent-size Indent wrapped attributes to after N characters [indent-size] (ignored if wrap-attributes is "force-aligned")
-U, --unformatted List of tags (defaults to inline) that should not be reformatted
- -T, --content_unformatted List of tags (defaults to pre) that its content should not be reformatted
+ -T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted
-E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline before them.
--editorconfig Use EditorConfig to set up the options
```
@@ -318,4 +321,4 @@ Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D
Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
Mathias Bynens, Vittorio Gambaletta and others.
-(README.md: js-beautify@1.7.3)
+(README.md: js-beautify@1.7.4)
View
@@ -48,7 +48,7 @@
brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
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.
unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
- content_unformatted (defaults to pre tag) - list of tags, that its content shouldn't be reformatted
+ content_unformatted (defaults to pre tag) - list of tags, whose content shouldn't be reformatted
indent_scripts (default normal) - "keep"|"separate"|"normal"
preserve_newlines (default true) - whether existing line breaks before elements should be preserved
Only works before elements, not inside tags or for text.
View
@@ -878,8 +878,8 @@ function Beautifier(js_source_text, options) {
}
}
- // Should be a space between await and an IIFE
- if (current_token.text === '(' && last_type === 'TK_RESERVED' && flags.last_word === 'await') {
+ // Should be a space between await and an IIFE, or async and an arrow function
+ if (current_token.text === '(' && last_type === 'TK_RESERVED' && in_array(flags.last_word, ['await', 'async'])) {
output.space_before_token = true;
}
View
@@ -359,7 +359,7 @@ function usage(err) {
msg.push(' -p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)');
msg.push(' -m, --max-preserve-newlines Number of line-breaks to be preserved in one chunk [10]');
msg.push(' -U, --unformatted List of tags (defaults to inline) that should not be reformatted');
- msg.push(' -T, --content_unformatted List of tags (defaults to pre) that its content should not be reformatted');
+ msg.push(' -T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted');
msg.push(' -E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline');
break;
case "css":
@@ -646,8 +646,8 @@ function Beautifier(js_source_text, options) {
}
}
- // Should be a space between await and an IIFE
- if (current_token.text === '(' && last_type === 'TK_RESERVED' && flags.last_word === 'await') {
+ // Should be a space between await and an IIFE, or async and an arrow function
+ if (current_token.text === '(' && last_type === 'TK_RESERVED' && in_array(flags.last_word, ['await', 'async'])) {
output.space_before_token = true;
}
@@ -1725,6 +1725,44 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
// ensure that this doesn't break anyone with the async library
bt('async.map(function(t) {})');
+
+ // async on arrow function. should have a space after async
+ bt(
+ 'async() => {}',
+ // -- output --
+ 'async () => {}');
+
+ // async on arrow function. should have a space after async
+ bt(
+ 'async() => {\n' +
+ ' return 5;\n' +
+ '}',
+ // -- output --
+ 'async () => {\n' +
+ ' return 5;\n' +
+ '}');
+
+ // async on arrow function returning expression. should have a space after async
+ bt(
+ 'async() => 5;',
+ // -- output --
+ 'async () => 5;');
+
+ // async on arrow function returning object literal. should have a space after async
+ bt(
+ 'async(x) => ({\n' +
+ ' foo: "5"\n' +
+ '})',
+ // -- output --
+ 'async (x) => ({\n' +
+ ' foo: "5"\n' +
+ '})');
+ bt(
+ 'async (x) => {\n' +
+ ' return x * 2;\n' +
+ '}');
+ bt('async () => 5;');
+ bt('async x => x * 2;');
//============================================================
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "js-beautify",
- "version": "1.7.3",
+ "version": "1.7.4",
"description": "jsbeautifier.org for node",
"main": "js/index.js",
"bin": {
@@ -1 +1 @@
-__version__ = '1.7.3'
+__version__ = '1.7.4'
@@ -480,7 +480,7 @@ def handle_start_expr(self, current_token):
# TODO: option space_before_conditional
self.output.space_before_token = True
- elif current_token.text == '(' and self.last_type == 'TK_RESERVED' and self.flags.last_word == 'await':
+ elif current_token.text == '(' and self.last_type == 'TK_RESERVED' and self.flags.last_word in ['await', 'async']:
self.output.space_before_token = True
@@ -1553,6 +1553,44 @@ def unicode_char(value):
# ensure that this doesn't break anyone with the async library
bt('async.map(function(t) {})')
+
+ # async on arrow function. should have a space after async
+ bt(
+ 'async() => {}',
+ # -- output --
+ 'async () => {}')
+
+ # async on arrow function. should have a space after async
+ bt(
+ 'async() => {\n' +
+ ' return 5;\n' +
+ '}',
+ # -- output --
+ 'async () => {\n' +
+ ' return 5;\n' +
+ '}')
+
+ # async on arrow function returning expression. should have a space after async
+ bt(
+ 'async() => 5;',
+ # -- output --
+ 'async () => 5;')
+
+ # async on arrow function returning object literal. should have a space after async
+ bt(
+ 'async(x) => ({\n' +
+ ' foo: "5"\n' +
+ '})',
+ # -- output --
+ 'async (x) => ({\n' +
+ ' foo: "5"\n' +
+ '})')
+ bt(
+ 'async (x) => {\n' +
+ ' return x * 2;\n' +
+ '}')
+ bt('async () => 5;')
+ bt('async x => x * 2;')
#============================================================
@@ -793,6 +793,35 @@ exports.test_data = {
{
comment: "ensure that this doesn't break anyone with the async library",
unchanged: "async.map(function(t) {})"
+ },
+ {
+ comment: "async on arrow function. should have a space after async",
+ input_: "async() => {}",
+ output: "async () => {}"
+ },
+ {
+ comment: "async on arrow function. should have a space after async",
+ input_: "async() => {\n return 5;\n}",
+ output: "async () => {\n return 5;\n}"
+ },
+ {
+ comment: "async on arrow function returning expression. should have a space after async",
+ input_: "async() => 5;",
+ output: "async () => 5;"
+ },
+ {
+ comment: "async on arrow function returning object literal. should have a space after async",
+ input_: "async(x) => ({\n foo: \"5\"\n})",
+ output: "async (x) => ({\n foo: \"5\"\n})"
+ },
+ {
+ unchanged: "async (x) => {\n return x * 2;\n}"
+ },
+ {
+ unchanged: "async () => 5;"
+ },
+ {
+ unchanged: "async x => x * 2;"
}
]
}, {
@@ -48,7 +48,7 @@
brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
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.
unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
- content_unformatted (defaults to pre tag) - list of tags, that its content shouldn't be reformatted
+ content_unformatted (defaults to pre tag) - list of tags, whose content shouldn't be reformatted
indent_scripts (default normal) - "keep"|"separate"|"normal"
preserve_newlines (default true) - whether existing line breaks before elements should be preserved
Only works before elements, not inside tags or for text.

0 comments on commit 5d7fc67

Please sign in to comment.