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

fix: do not panic linting files with UTF-8 BOM (#24136)

Closes #24122
This commit is contained in:
David Sherret 2024-06-07 13:02:47 -04:00 committed by Nathan Whitaker
parent 5a7241694d
commit d2a8619162
No known key found for this signature in database
6 changed files with 26 additions and 5 deletions

4
Cargo.lock generated
View file

@ -1175,9 +1175,9 @@ dependencies = [
[[package]]
name = "deno_ast"
version = "0.39.0"
version = "0.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32edef567e3090862e865c75628f4d35ace80ca90e0fc5263a7d10fa307ae899"
checksum = "042645e6a505a359b288723ded5c8b30fdc4f70514a3bcd7a49221cc89c1ba90"
dependencies = [
"anyhow",
"base64 0.21.7",

View file

@ -43,7 +43,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"
[workspace.dependencies]
deno_ast = { version = "=0.39.0", features = ["transpiling"] }
deno_ast = { version = "=0.39.1", features = ["transpiling"] }
deno_core = { version = "0.284.0" }
deno_bench_util = { version = "0.149.0", path = "./bench_util" }

View file

@ -230,7 +230,7 @@ async fn lint_files(
deno_core::unsync::spawn(async move {
run_parallelized(paths, {
move |file_path| {
let file_text = fs::read_to_string(&file_path)?;
let file_text = deno_ast::strip_bom(fs::read_to_string(&file_path)?);
// don't bother rechecking this file if it didn't have any diagnostics before
if incremental_cache.is_file_same(&file_path, &file_text) {
@ -510,7 +510,7 @@ fn lint_stdin(
linter
.lint_file(LintFileOptions {
specifier: specifier_from_file_path(file_path)?,
source_code: source_code.clone(),
source_code: deno_ast::strip_bom(source_code),
media_type: MediaType::TypeScript,
config,
})

View file

@ -0,0 +1,5 @@
{
"args": "lint mod.ts",
"exitCode": 1,
"output": "mod.out"
}

View file

@ -0,0 +1,12 @@
error[no-unused-vars]: `t` is never used
--> [WILDLINE]
|
4 | const t = 5;
| ^
= hint: If this is intentional, prefix it with an underscore like `_t`
docs: https://lint.deno.land/rules/no-unused-vars
Found 1 problem
Checked 1 file

View file

@ -0,0 +1,4 @@
// this file is saved as UTF8 with BOM
console.log("Hello, world!");
const t = 5;