diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-09-18 12:15:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-18 21:15:13 +0200 |
commit | a1d0a427e807959666a6b23ae015e4e04659abf5 (patch) | |
tree | c588767979d1f7ded1830d042f737774b23addf6 /cli/tools/lint/linter.rs | |
parent | 7a41a939972b701e96cb70cbf0516595fefcae02 (diff) |
feat: default to TS for file extension and support ext flag in more scenarios (#25472)
Closes #11220
Currently does lint, fmt, and repl
Diffstat (limited to 'cli/tools/lint/linter.rs')
-rw-r--r-- | cli/tools/lint/linter.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/tools/lint/linter.rs b/cli/tools/lint/linter.rs index 777fe4d09..2c2bc43ac 100644 --- a/cli/tools/lint/linter.rs +++ b/cli/tools/lint/linter.rs @@ -94,9 +94,16 @@ impl CliLinter { &self, file_path: &Path, source_code: String, + ext: Option<&str>, ) -> Result<(ParsedSource, Vec<LintDiagnostic>), AnyError> { let specifier = specifier_from_file_path(file_path)?; - let media_type = MediaType::from_specifier(&specifier); + let media_type = if let Some(ext) = ext { + MediaType::from_str(&format!("placeholder.{ext}")) + } else if file_path.extension().is_none() { + MediaType::TypeScript + } else { + MediaType::from_specifier(&specifier) + }; if self.fix { self.lint_file_and_fix(&specifier, media_type, source_code, file_path) |