]> code.delx.au - gnu-emacs-elpa/commitdiff
do auto semicolon insert on function exports
authorCharles Lowell <cowboyd@frontside.io>
Thu, 5 Feb 2015 21:50:03 +0000 (15:50 -0600)
committerCharles Lowell <cowboyd@frontside.io>
Thu, 5 Feb 2015 21:50:03 +0000 (15:50 -0600)
js2-mode.el
tests/parser.el

index 2fd0630192c3fc12746970924ad889d651ecc117..4045c94f0477fb31559769508a4883de8ff7e92e 100644 (file)
@@ -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)
index b4f2d8fe23e7a6166d855643dd184a854145db67..8c44028fc0dd610e2ca2c94442dd39e0c365431b 100644 (file)
@@ -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';")