From 6109274d457dcdd3a0aee021d854c543d2f5e52a Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 23 Aug 2019 04:46:01 +0000 Subject: [PATCH] [clang-format] Recognize ECMAScript module .mjs as JavaScript PR43085. Recognize .mjs files as JavaScript. .mjs is the extension for ECMAScript modules. A specific extension (and associated content type javascript/esm) is introduced to differentiate it from CommonJS modules and solve some interoperability problems. Differential Revision: https://reviews.llvm.org/D66584 Patch by Fergal Daly git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369732 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 4fbaee470f..175807edfb 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -2411,8 +2411,9 @@ const char *StyleOptionHelpDescription = static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { if (FileName.endswith(".java")) return FormatStyle::LK_Java; - if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts")) - return FormatStyle::LK_JavaScript; // JavaScript or TypeScript. + if (FileName.endswith_lower(".js") || FileName.endswith_lower(".mjs") || + FileName.endswith_lower(".ts")) + return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript. if (FileName.endswith(".m") || FileName.endswith(".mm")) return FormatStyle::LK_ObjC; if (FileName.endswith_lower(".proto") || -- 2.40.0