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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ rest_pat_in_fully_bound_structs = "warn"
unnecessary_safety_comment = "warn"
undocumented_unsafe_blocks = "warn"
infinite_loop = "warn"
map_with_unused_argument_over_ranges = "warn"
unused_result_ok = "warn"
pathbuf_init_then_push = "warn"
# I want to write the best Rust code so pedantic is enabled.
# We should only disable rules globally if they are either false positives, chaotic, or does not make sense.
pedantic = { level = "warn", priority = -1 }
# Allowed rules
# pedantic
# This rule is too pedantic, I don't want to force this because naming things are hard.
module_name_repetitions = "allow"
# All triggers are mostly ignored in our codebase, so this is ignored globally.
struct_excessive_bools = "allow"
too_many_lines = "allow"
Expand Down
18 changes: 3 additions & 15 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,7 @@ impl Runner for LintRunner {
}

// Append cwd to all paths
paths = paths
.into_iter()
.map(|x| {
let mut path_with_cwd = self.cwd.clone();
path_with_cwd.push(x);
path_with_cwd
})
.collect();
paths = paths.into_iter().map(|x| self.cwd.join(x)).collect();

if paths.is_empty() {
// If explicit paths were provided, but all have been
Expand Down Expand Up @@ -268,9 +261,7 @@ impl LintRunner {
// when no file is found, the default configuration is returned
fn find_oxlint_config(cwd: &Path, config: Option<&PathBuf>) -> Result<Oxlintrc, CliRunResult> {
if let Some(config_path) = config {
let mut full_path = cwd.to_path_buf();
full_path.push(config_path);

let full_path = cwd.join(config_path);
return match Oxlintrc::from_file(&full_path) {
Ok(config) => Ok(config),
Err(diagnostic) => {
Expand All @@ -283,13 +274,10 @@ impl LintRunner {
}
};
}

// no config argument is provided,
// auto detect default config file from current work directory
// or return the default configuration, when no valid file is found
let mut config_path = cwd.to_path_buf();
config_path.push(Self::DEFAULT_OXLINTRC);

let config_path = cwd.join(Self::DEFAULT_OXLINTRC);
Oxlintrc::from_file(&config_path).or_else(|_| Ok(Oxlintrc::default()))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,17 +889,24 @@ impl<'a, 'b> PeepholeSubstituteAlternateSyntax {
// new Array(2) -> `[,,]`
// this does not work with IE8 and below
// learned from https://github.com/babel/minify/pull/45
#[expect(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
if n.value.fract() == 0.0 {
let n_int = n.value as i64;
let n_int = n.value as usize;
if (1..=6).contains(&n_int) {
return Some(ctx.ast.expression_array(
span,
ctx.ast.vec_from_iter((0..n_int).map(|_| {
ArrayExpressionElement::Elision(Elision { span: SPAN })
})),
None,
));
return Some(
ctx.ast.expression_array(
span,
ctx.ast.vec_from_iter(
std::iter::from_fn(|| {
Some(ArrayExpressionElement::Elision(
ctx.ast.elision(SPAN),
))
})
.take(n_int),
),
None,
),
);
}
}

Expand Down
Loading