[clang] Add `.cjs` extension handling for JavaScript Language. (PR #118188)

Jim B via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 30 18:12:57 PST 2024


https://github.com/d3x0r created https://github.com/llvm/llvm-project/pull/118188

None

>From 8ce527dc2cc7ac285f782648838664491abffc30 Mon Sep 17 00:00:00 2001
From: d3x0r <d3x0r at no-reply.github.com>
Date: Sat, 30 Nov 2024 02:32:40 -0800
Subject: [PATCH] Add *.cjs handling for JavaScript Language.

---
 clang/lib/Format/Format.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ee52972ce66f4a..dcaac4b0d42cc5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3950,6 +3950,7 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
     return FormatStyle::LK_Java;
   if (FileName.ends_with_insensitive(".js") ||
       FileName.ends_with_insensitive(".mjs") ||
+      FileName.ends_with_insensitive(".cjs") ||
       FileName.ends_with_insensitive(".ts")) {
     return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
   }



More information about the cfe-commits mailing list