Skip to content

Commit

Permalink
Show harmony suggestion when using for-of loops
Browse files Browse the repository at this point in the history
  • Loading branch information
lautis committed Dec 9, 2017
1 parent dd46f20 commit 6ecb277
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## next

- show harmony suggestion when using for-of loops

## 4.0.1 (3 December 2017)

- update UglifyJS to 3.2.1
Expand Down
2 changes: 1 addition & 1 deletion lib/uglifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def harmony?

def error_message(result)
result['error']['message'] +
if result['error']['message'].start_with?("Unexpected token:") && !harmony?
if result['error']['message'].start_with?("Unexpected token") && !harmony?
". To use ES6 syntax, harmony mode must be enabled with " \
"Uglifier.new(:harmony => true)."
else
Expand Down
2 changes: 1 addition & 1 deletion spec/uglifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

it "raises an error when minifying JS with Harmony without harmony option" do
source = "const foo = () => bar();"
source = "for (var value of array) { doSomething(value) }"
expect { Uglifier.new(:compress => false).compile(source) }
.to raise_error(Uglifier::Error, /harmony/)
end
Expand Down

0 comments on commit 6ecb277

Please sign in to comment.