From 8798c8de9a8a4abf597cd370da57ebefaa4d951d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 23 Aug 2019 04:46:01 +0000 Subject: [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 llvm-svn: 369732 --- clang/lib/Format/Format.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 4fbaee470fa..175807edfb4 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/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") || -- cgit v1.2.3