1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix: don't include extensionless files in file collection for lint & fmt by default (#25721)

When using the `ext` flag, it will still attempt formatting them with
the provided extension
This commit is contained in:
Leo Kettmeir 2024-09-19 02:25:48 -07:00 committed by GitHub
parent 68065351df
commit bb45446fa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 8 deletions

View file

@ -221,10 +221,8 @@ fn collect_fmt_files(
files: FilePatterns,
) -> Result<Vec<PathBuf>, AnyError> {
FileCollector::new(|e| {
cli_options.ext_flag().as_ref().is_some_and(|ext| {
is_supported_ext_fmt(Path::new(&format!("placeholder.{ext}")))
}) || is_supported_ext_fmt(e.path)
|| e.path.extension().is_none()
is_supported_ext_fmt(e.path)
|| (e.path.extension().is_none() && cli_options.ext_flag().is_some())
})
.ignore_git_folder()
.ignore_node_modules()

View file

@ -430,10 +430,8 @@ fn collect_lint_files(
files: FilePatterns,
) -> Result<Vec<PathBuf>, AnyError> {
FileCollector::new(|e| {
cli_options.ext_flag().as_ref().is_some_and(|ext| {
is_script_ext(Path::new(&format!("placeholder.{ext}")))
}) || is_script_ext(e.path)
|| e.path.extension().is_none()
is_script_ext(e.path)
|| (e.path.extension().is_none() && cli_options.ext_flag().is_some())
})
.ignore_git_folder()
.ignore_node_modules()

View file

@ -12,6 +12,11 @@
},
"extensionless": {
"args": "fmt extensionless",
"output": "error: No target files found.\n",
"exitCode": 1
},
"extensionless_with_flag": {
"args": "fmt --ext=ts extensionless",
"output": "Checked 1 file\n"
}
}

View file

@ -12,6 +12,11 @@
},
"extensionless": {
"args": "lint extensionless",
"output": "error: No target files found.\n",
"exitCode": 1
},
"extensionless_with_flag": {
"args": "lint --ext=ts extensionless",
"output": "Checked 1 file\n"
}
}