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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ homepage = "https://oxc.rs"
keywords = ["JavaScript", "TypeScript", "linter", "minifier", "parser"]
license = "MIT"
repository = "https://github.com/oxc-project/oxc"
rust-version = "1.81.0" # Support last 4 minor versions.
rust-version = "1.82.0" # Support last 4 minor versions. (NOTE: bump to `edition = "2024"` when 1.85.0.
description = "A collection of JavaScript tools written in Rust."

# <https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html>
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a> IsolatedDeclarations<'a> {
let mut type_annotations = None;
let mut value = None;

if property.accessibility.map_or(true, |a| !a.is_private()) {
if property.accessibility.is_none_or(|a| !a.is_private()) {
if property.type_annotation.is_some() {
type_annotations = property.type_annotation.clone_in(self.ast.allocator);
} else if let Some(expr) = property.value.as_ref() {
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'a> IsConstant<'a, '_> for CallExpression<'a> {
.arguments
.iter()
.next()
.map_or(true, |first| first.is_constant(true, semantic))
.is_none_or(|first| first.is_constant(true, semantic))
{
return semantic.is_reference_to_global_variable(ident);
}
Expand Down Expand Up @@ -545,7 +545,7 @@ pub fn could_be_error(ctx: &LintContext, expr: &Expression) -> bool {
expr.operator,
AssignmentOperator::LogicalOr | AssignmentOperator::LogicalNullish
) {
return expr.left.get_expression().map_or(true, |expr| could_be_error(ctx, expr))
return expr.left.get_expression().is_none_or(|expr| could_be_error(ctx, expr))
|| could_be_error(ctx, &expr.right);
}

Expand Down Expand Up @@ -673,7 +673,7 @@ pub fn is_default_this_binding<'a>(
AstKind::Function(_) | AstKind::ArrowFunctionExpression(_)
)
});
if upper_func.map_or(true, |node| !is_callee(node, semantic)) {
if upper_func.is_none_or(|node| !is_callee(node, semantic)) {
return true;
}
current_node = parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl NoConstantBinaryExpression {
.arguments
.iter()
.next()
.map_or(true, |first| first.is_constant(true, ctx));
.is_none_or(|first| first.is_constant(true, ctx));
}
}
false
Expand Down
5 changes: 1 addition & 4 deletions crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ impl Rule for NoDupeElseIf {
break;
};

if !stmt
.alternate
.as_ref()
.is_some_and(|stmt| stmt.span() == current_node.kind().span())
if stmt.alternate.as_ref().is_none_or(|stmt| stmt.span() != current_node.kind().span())
{
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Rule for GoogleFontPreconnect {
};

let preconnect_missing =
has_jsx_prop_ignore_case(jsx_opening_element, "rel").map_or(true, |rel_prop| {
has_jsx_prop_ignore_case(jsx_opening_element, "rel").is_none_or(|rel_prop| {
let rel_prop_value = get_string_literal_prop_value(rel_prop);
rel_prop_value != Some("preconnect")
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn check_reduce_usage<'a>(
// Skip non-parameter or non-first-parameter declarations.
let first_param_symbol_id =
params.items.first().and_then(|item| get_identifier_symbol_id(&item.pattern.kind));
if !first_param_symbol_id.is_some_and(|id| id == referenced_symbol_id) {
if first_param_symbol_id.is_none_or(|id| id != referenced_symbol_id) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Rule for NoCallbackInPromise {
let is_not_callback = call_expr
.callee
.get_identifier_reference()
.map_or(true, |id| self.callbacks.binary_search(&id.name.as_str().into()).is_err());
.is_none_or(|id| self.callbacks.binary_search(&id.name.as_str().into()).is_err());

if is_not_callback {
if Self::has_promise_callback(call_expr) {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/react/no_is_mounted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Rule for NoIsMounted {
};

if !matches!(member_expr.object(), Expression::ThisExpression(_))
|| !member_expr.static_property_name().is_some_and(|str| str == "isMounted")
|| member_expr.static_property_name().is_none_or(|str| str != "isMounted")
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/react/no_set_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Rule for NoSetState {
};

if !matches!(member_expr.object(), Expression::ThisExpression(_))
|| !member_expr.static_property_name().is_some_and(|str| str == "setState")
|| member_expr.static_property_name().is_none_or(|str| str != "setState")
|| get_parent_component(node, ctx).is_none()
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ declare_oxc_lint!(

impl Rule for SwitchCaseBraces {
fn from_configuration(value: serde_json::Value) -> Self {
let always = value.get(0).map_or(true, |v| v.as_str() != Some("avoid"));
let always = value.get(0).is_none_or(|v| v.as_str() != Some("avoid"));

Self { always_braces: always }
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/utils/react.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn parse_jsx_value(value: &JSXAttributeValue) -> Result<f64, ()> {
/// Hook names must start with use followed by a capital letter,
/// like useState (built-in) or useOnlineStatus (custom).
pub fn is_react_hook_name(name: &str) -> bool {
name.starts_with("use") && name.chars().nth(3).map_or(true, char::is_uppercase)
name.starts_with("use") && name.chars().nth(3).is_none_or(char::is_uppercase)
// uncomment this check if react decided to drop the idea of `use` hook.
// <https://react.dev/reference/react/use> It is currently in `Canary` builds.
// name.starts_with("use") && name.chars().nth(3).is_some_and(char::is_uppercase)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/utils/unicorn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn is_prototype_property(
property: &str,
object: Option<&str>,
) -> bool {
if !member_expr.static_property_name().is_some_and(|name| name == property)
if member_expr.static_property_name().is_none_or(|name| name != property)
|| member_expr.optional()
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl<'a> Format<'a> for VariableDeclaration<'a> {
}
}

if !parent_for_loop_span.is_some_and(|span| span != self.span) {
if parent_for_loop_span.is_none_or(|span| span == self.span) {
if let Some(semi) = p.semi() {
parts.push(semi);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Parser {
if let Some(cp) = self.parse_character_escape_sequence() {
return Ok(Some(cp));
}
if self.peek() == Some('0') && self.peek2().map_or(true, |ch| !ch.is_ascii_digit()) {
if self.peek() == Some('0') && self.peek2().is_none_or(|ch| !ch.is_ascii_digit()) {
self.advance();
return Ok(Some(0x00));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/checker/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub fn check_class<'a>(class: &Class<'a>, ctx: &SemanticBuilder<'a>) {
if !a.r#type.is_abstract()
&& !a.optional
&& a.value.r#type == FunctionType::TSEmptyBodyFunctionExpression
&& b.map_or(true, |b| match b {
&& b.is_none_or(|b| match b {
ClassElement::StaticBlock(_)
| ClassElement::PropertyDefinition(_)
| ClassElement::AccessorProperty(_)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/jsx/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ fn is_componentish_name(name: &str) -> bool {
}

fn is_use_hook_name(name: &str) -> bool {
name.starts_with("use") && name.as_bytes().get(3).map_or(true, u8::is_ascii_uppercase)
name.starts_with("use") && name.as_bytes().get(3).is_none_or(u8::is_ascii_uppercase)
}

#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/typescript/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> Traverse<'a> for TypeScriptNamespace<'a, '_> {
continue;
}
Statement::ExportNamedDeclaration(export_decl) => {
if export_decl.declaration.as_ref().map_or(true, |decl| {
if export_decl.declaration.as_ref().is_none_or(|decl| {
decl.declare() || !matches!(decl, Declaration::TSModuleDeclaration(_))
}) {
new_stmts.push(Statement::ExportNamedDeclaration(export_decl));
Expand Down
Loading