From 38aa66bec00d8d4703da97d8a59ac4c669417545 Mon Sep 17 00:00:00 2001 From: Carl Lei Date: Mon, 9 Nov 2015 10:28:35 +0800 Subject: [PATCH] Do not print trailing semicolon for export function and class --- js2-mode.el | 4 +++- tests/parser.el | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js2-mode.el b/js2-mode.el index bf7219afd..2e5b21014 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -2551,7 +2551,9 @@ so many of its properties will be nil. (js2-print-from-clause from)) (exports-list (js2-print-named-imports exports-list))) - (unless (and default (not (js2-assign-node-p default))) + (unless (or (and default (not (js2-assign-node-p default))) + (and declaration (or (js2-function-node-p declaration) + (js2-class-node-p declaration)))) (insert ";\n")))) (cl-defstruct (js2-while-node diff --git a/tests/parser.el b/tests/parser.el index 79481c89d..198e5780c 100644 --- a/tests/parser.el +++ b/tests/parser.el @@ -799,6 +799,12 @@ the test." (js2-deftest-parse parse-export-generator-declaration "export default function* one() {\n}") (js2-deftest-parse parse-export-assignment-expression "export default a = b;") +(js2-deftest-parse parse-export-function-declaration-no-semi + "export function f() {\n}") + +(js2-deftest-parse parse-export-class-declaration-no-semi + "export class C {\n}") + ;;; Strings (js2-deftest-parse string-literal -- 2.39.2