Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ markdown = "1.0.0-alpha.21"
memchr = "2.7.4"
miette = { package = "oxc-miette", version = "1.0.2", features = ["fancy-no-syscall"] }
mimalloc = "0.1.43"
mime_guess = "2.0.5"
nonmax = "0.5.5"
num-bigint = "0.4.6"
num-traits = "0.2.19"
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ json-strip-comments = { workspace = true }
language-tags = { workspace = true }
lazy_static = { workspace = true }
memchr = { workspace = true }
mime_guess = { workspace = true }
nonmax = { workspace = true }
phf = { workspace = true, features = ["macros"] }
rayon = { workspace = true }
Expand Down
19 changes: 13 additions & 6 deletions crates/oxc_linter/src/config/oxlintrc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::path::{Path, PathBuf};
use std::{
ffi::OsStr,
path::{Path, PathBuf},
};

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -109,14 +112,14 @@ impl Oxlintrc {
})?;

let json = serde_json::from_str::<serde_json::Value>(&string).map_err(|err| {
let guess = mime_guess::from_path(path);
let err = match guess.first() {
let ext = path.extension().and_then(OsStr::to_str);
let err = match ext {
// syntax error
Some(mime) if mime.subtype() == "json" => err.to_string(),
Some(_) => "Only json configuration is supported".to_string(),
Some(ext) if is_json_ext(ext) => err.to_string(),
Some(_) => "Only JSON configuration files are supported".to_string(),
None => {
format!(
"{err}, if the configuration is not a json file, please use json instead."
"{err}, if the configuration is not a JSON file, please use JSON instead."
)
}
};
Expand All @@ -133,6 +136,10 @@ impl Oxlintrc {
}
}

fn is_json_ext(ext: &str) -> bool {
ext == "json" || ext == "jsonc"
}

#[cfg(test)]
mod test {
use serde_json::json;
Expand Down
Loading