[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format
Fergal Daly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 22 05:34:47 PDT 2019
fergald created this revision.
fergald added a reviewer: MaskRay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
PR43085.
This causes .mjs files to be treated as javascript. .mjs is the extension for module-javascript. Module javascript is not compatible with non-module java script as it uses the "export" and "import" keywords which are only legal in module-javascript. As such it uses a different file extension.
Repository:
rC Clang
https://reviews.llvm.org/D66584
Files:
lib/Format/Format.cpp
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2411,8 +2411,9 @@
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(".ts") ||
+ FileName.endswith_lower(".mjs"))
+ return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
if (FileName.endswith(".m") || FileName.endswith(".mm"))
return FormatStyle::LK_ObjC;
if (FileName.endswith_lower(".proto") ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66584.216588.patch
Type: text/x-patch
Size: 791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190822/5d554b0d/attachment.bin>
More information about the cfe-commits
mailing list