summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--cli/tools/lint/mod.rs4
-rw-r--r--tests/specs/lint/bom/__test__.jsonc5
-rw-r--r--tests/specs/lint/bom/mod.out12
-rw-r--r--tests/specs/lint/bom/mod.ts4
6 files changed, 26 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 142788eb3..0f29b9995 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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",
diff --git a/Cargo.toml b/Cargo.toml
index cfb00598c..26f242036 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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" }
diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs
index 151d0f11d..712b95e34 100644
--- a/cli/tools/lint/mod.rs
+++ b/cli/tools/lint/mod.rs
@@ -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,
})
diff --git a/tests/specs/lint/bom/__test__.jsonc b/tests/specs/lint/bom/__test__.jsonc
new file mode 100644
index 000000000..f2ea579c4
--- /dev/null
+++ b/tests/specs/lint/bom/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "lint mod.ts",
+ "exitCode": 1,
+ "output": "mod.out"
+}
diff --git a/tests/specs/lint/bom/mod.out b/tests/specs/lint/bom/mod.out
new file mode 100644
index 000000000..eea1e531d
--- /dev/null
+++ b/tests/specs/lint/bom/mod.out
@@ -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
diff --git a/tests/specs/lint/bom/mod.ts b/tests/specs/lint/bom/mod.ts
new file mode 100644
index 000000000..c2374d45d
--- /dev/null
+++ b/tests/specs/lint/bom/mod.ts
@@ -0,0 +1,4 @@
+// this file is saved as UTF8 with BOM
+console.log("Hello, world!");
+
+const t = 5;