From aefc559f43700f69e37592fb9898bfab1bc9f4bc Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Sun, 13 Oct 2024 02:35:46 -0400 Subject: [PATCH] Improve auto-detection via shebang of TypeScript, JavaScript and Shell Script (#19114) --- crates/languages/src/bash/config.toml | 2 +- crates/languages/src/javascript/config.toml | 3 ++- crates/languages/src/typescript/config.toml | 1 + typos.toml | 1 - 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/bash/config.toml b/crates/languages/src/bash/config.toml index 1deb800219..0a1deb3e69 100644 --- a/crates/languages/src/bash/config.toml +++ b/crates/languages/src/bash/config.toml @@ -3,7 +3,7 @@ code_fence_block_name = "bash" grammar = "bash" path_suffixes = ["sh", "bash", "bashrc", "bash_profile", "bash_aliases", "bash_logout", "profile", "zsh", "zshrc", "zshenv", "zsh_profile", "zsh_aliases", "zsh_histfile", "zlogin", "zprofile", ".env", "PKGBUILD"] line_comments = ["# "] -first_line_pattern = "^#!.*\\b(?:ba|z)?sh\\b" +first_line_pattern = '^#!.*\b(?:ash|bash|dash|sh|zsh)\b' brackets = [ { start = "[", end = "]", close = true, newline = false }, { start = "(", end = ")", close = true, newline = false }, diff --git a/crates/languages/src/javascript/config.toml b/crates/languages/src/javascript/config.toml index 460ee0e0fd..b770a28071 100644 --- a/crates/languages/src/javascript/config.toml +++ b/crates/languages/src/javascript/config.toml @@ -1,7 +1,8 @@ name = "JavaScript" grammar = "tsx" path_suffixes = ["js", "jsx", "mjs", "cjs"] -first_line_pattern = '^#!.*\bnode\b' +# [/ ] is so we match "env node" or "/node" but not "ts-node" +first_line_pattern = '^#!.*\b(?:[/ ]node|deno run.*--ext[= ]js)\b' line_comments = ["// "] autoclose_before = ";:.,=}])>" brackets = [ diff --git a/crates/languages/src/typescript/config.toml b/crates/languages/src/typescript/config.toml index ca115622c6..a34704b830 100644 --- a/crates/languages/src/typescript/config.toml +++ b/crates/languages/src/typescript/config.toml @@ -1,6 +1,7 @@ name = "TypeScript" grammar = "typescript" path_suffixes = ["ts", "cts", "d.cts", "d.mts", "mts"] +first_line_pattern = '^#!.*\b(?:deno run|ts-node|bun|tsx)\b' line_comments = ["// "] autoclose_before = ";:.,=}])>" brackets = [ diff --git a/typos.toml b/typos.toml index 113fb728d1..2760af0b7d 100644 --- a/typos.toml +++ b/typos.toml @@ -48,7 +48,6 @@ extend-ignore-re = [ 'cl\[ist]', '\[lan\]guage', '"ba"', - ":ba\\|z", # :/ crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql "COLUMN enviroment", # Typo in ClickHouse column name.