emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 28853c9 03/22: do auto semicolon insert on function export


From: Dmitry Gutov
Subject: [elpa] master 28853c9 03/22: do auto semicolon insert on function exports
Date: Fri, 24 Apr 2015 02:57:08 +0000

branch: master
commit 28853c91a2a15d0414da5cdb05f755fa658317f7
Author: Charles Lowell <address@hidden>
Commit: Charles Lowell <address@hidden>

    do auto semicolon insert on function exports
---
 js2-mode.el     |   11 ++++++++---
 tests/parser.el |   10 ++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index 2fd0630..4045c94 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8094,7 +8094,8 @@ node are given relative start positions and correct 
lengths."
         js2-ERROR
         js2-SEMI
         js2-CLASS
-        js2-FUNCTION)
+        js2-FUNCTION
+        js2-EXPORT)
   "List of tokens that don't do automatic semicolon insertion.")
 
 (defconst js2-autoinsert-semi-and-warn
@@ -8529,9 +8530,13 @@ invalid export statements."
     (when from-clause
       (push from-clause children))
     (when declaration
-      (push declaration children))
+      (push declaration children)
+      (when (not (js2-function-node-p declaration))
+        (js2-auto-insert-semicolon declaration)))
     (when default
-      (push default children))
+      (push default children)
+      (when (not (js2-function-node-p default))
+        (js2-auto-insert-semicolon default)))
     (let ((node (make-js2-export-node
                   :pos beg
                   :len (- (js2-current-token-end) beg)
diff --git a/tests/parser.el b/tests/parser.el
index b4f2d8f..8c44028 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -608,6 +608,16 @@ the test."
     (should export-node)
     (should (js2-export-node-default export-node))))
 
+(js2-deftest export-function-no-semicolon "export default function foo() {}"
+  (js2-mode)
+  (should (equal nil js2-parsed-warnings)))
+(js2-deftest export-default-function-no-semicolon "export function foo() {}"
+  (js2-mode)
+  (should (equal nil js2-parsed-warnings)))
+(js2-deftest export-anything-else-does-require-a-semicolon "export var obj = 
{}"
+  (js2-mode)
+  (should (not (equal nil js2-parsed-warnings))))
+
 (js2-deftest-parse parse-export-rexport "export * from 'other/lib';")
 (js2-deftest-parse parse-export-export-named-list "export {foo, bar as bang};")
 (js2-deftest-parse parse-re-export-named-list "export {foo, bar as bang} from 
'other/lib';")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]