From: Charles Lowell Date: Thu, 5 Feb 2015 21:50:03 +0000 (-0600) Subject: do auto semicolon insert on function exports X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/28853c91a2a15d0414da5cdb05f755fa658317f7 do auto semicolon insert on function exports --- diff --git a/js2-mode.el b/js2-mode.el index 2fd063019..4045c94f0 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 b4f2d8fe2..8c44028fc 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';")