diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 095e9bc437896..8677a62d52c1c 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1497,7 +1497,7 @@ impl ExportNamedDeclaration<'_> { #[allow(missing_docs)] pub fn is_typescript_syntax(&self) -> bool { self.export_kind == ImportOrExportKind::Type - || self.declaration.as_ref().map_or(false, Declaration::is_typescript_syntax) + || self.declaration.as_ref().is_some_and(Declaration::is_typescript_syntax) } } diff --git a/crates/oxc_diagnostics/src/service.rs b/crates/oxc_diagnostics/src/service.rs index e314d2f0a5092..89d222cc51e77 100644 --- a/crates/oxc_diagnostics/src/service.rs +++ b/crates/oxc_diagnostics/src/service.rs @@ -175,7 +175,7 @@ impl DiagnosticService { /// Check if the max warning threshold, as set by /// [`with_max_warnings`](DiagnosticService::with_max_warnings), has been exceeded. pub fn max_warnings_exceeded(&self) -> bool { - self.max_warnings.map_or(false, |max_warnings| self.warnings_count.get() > max_warnings) + self.max_warnings.is_some_and(|max_warnings| self.warnings_count.get() > max_warnings) } /// Wrap [diagnostics] with the source code and path, converting them into [Error]s. diff --git a/crates/oxc_ecmascript/src/side_effects/check_for_state_change.rs b/crates/oxc_ecmascript/src/side_effects/check_for_state_change.rs index 5a24c95ef7563..331d1f46b9731 100644 --- a/crates/oxc_ecmascript/src/side_effects/check_for_state_change.rs +++ b/crates/oxc_ecmascript/src/side_effects/check_for_state_change.rs @@ -182,7 +182,7 @@ impl<'a> CheckForStateChange<'a, '_> for VariableDeclarator<'a> { || self .init .as_ref() - .map_or(false, |init| init.check_for_state_change(check_for_new_objects)) + .is_some_and(|init| init.check_for_state_change(check_for_new_objects)) } } @@ -294,7 +294,7 @@ impl CheckForStateChange<'_, '_> for AssignmentTargetProperty<'_> { ) => assignment_target_property_identifier .init .as_ref() - .map_or(false, |init| init.check_for_state_change(check_for_new_objects)), + .is_some_and(|init| init.check_for_state_change(check_for_new_objects)), AssignmentTargetProperty::AssignmentTargetPropertyProperty( assignment_target_property_property, ) => { diff --git a/crates/oxc_ecmascript/src/string_to_number.rs b/crates/oxc_ecmascript/src/string_to_number.rs index da9da38a23791..2293a7aac4f03 100644 --- a/crates/oxc_ecmascript/src/string_to_number.rs +++ b/crates/oxc_ecmascript/src/string_to_number.rs @@ -19,9 +19,9 @@ impl StringToNumber for &str { let mut bytes = s.trim_start_matches(['-', '+']).bytes(); if bytes .next() - .filter(|c| c.to_ascii_lowercase() == b'i') - .and_then(|_| bytes.next().filter(|c| c.to_ascii_lowercase() == b'n')) - .and_then(|_| bytes.next().filter(|c| c.to_ascii_lowercase() == b'f')) + .filter(|c| c.eq_ignore_ascii_case(&b'i')) + .and_then(|_| bytes.next().filter(|c| c.eq_ignore_ascii_case(&b'n'))) + .and_then(|_| bytes.next().filter(|c| c.eq_ignore_ascii_case(&b'f'))) .is_some() { return f64::NAN; diff --git a/crates/oxc_isolated_declarations/src/lib.rs b/crates/oxc_isolated_declarations/src/lib.rs index 780f733067a8a..ed76c03d74fa7 100644 --- a/crates/oxc_isolated_declarations/src/lib.rs +++ b/crates/oxc_isolated_declarations/src/lib.rs @@ -632,7 +632,7 @@ impl<'a> IsolatedDeclarations<'a> { if can_expando_function_names.contains(&ident.name) && !assignable_properties_for_namespace .get(&ident.name.as_str()) - .map_or(false, |properties| { + .is_some_and(|properties| { properties.contains(&static_member_expr.property.name) }) { diff --git a/crates/oxc_language_server/src/linter/isolated_lint_handler.rs b/crates/oxc_language_server/src/linter/isolated_lint_handler.rs index fec99c4e32ee8..3c2bb5ad1823d 100644 --- a/crates/oxc_language_server/src/linter/isolated_lint_handler.rs +++ b/crates/oxc_language_server/src/linter/isolated_lint_handler.rs @@ -186,7 +186,7 @@ impl IsolatedLintHandler { path.extension() .and_then(std::ffi::OsStr::to_str) - .map_or(false, |ext| wanted_exts.contains(ext)) + .is_some_and(|ext| wanted_exts.contains(ext)) } fn wrap_diagnostics( diff --git a/crates/oxc_linter/src/ast_util.rs b/crates/oxc_linter/src/ast_util.rs index 76828fb33d850..6751ef4606453 100644 --- a/crates/oxc_linter/src/ast_util.rs +++ b/crates/oxc_linter/src/ast_util.rs @@ -75,7 +75,7 @@ impl<'a> IsConstant<'a, '_> for Expression<'a> { Self::TemplateLiteral(template) => { let test_quasis = in_boolean_position && template.quasis.iter().any(|quasi| { - quasi.value.cooked.as_ref().map_or(false, |cooked| !cooked.is_empty()) + quasi.value.cooked.as_ref().is_some_and(|cooked| !cooked.is_empty()) }); let test_expressions = template.expressions.iter().all(|expr| expr.is_constant(false, semantic)); @@ -125,7 +125,7 @@ impl<'a> IsConstant<'a, '_> for Expression<'a> { .expressions .iter() .last() - .map_or(false, |last| last.is_constant(in_boolean_position, semantic)), + .is_some_and(|last| last.is_constant(in_boolean_position, semantic)), Self::CallExpression(call_expr) => call_expr.is_constant(in_boolean_position, semantic), Self::ParenthesizedExpression(paren_expr) => { paren_expr.expression.is_constant(in_boolean_position, semantic) diff --git a/crates/oxc_linter/src/options/allow_warn_deny.rs b/crates/oxc_linter/src/options/allow_warn_deny.rs index 4f8093fc577da..2f4127fa79dcc 100644 --- a/crates/oxc_linter/src/options/allow_warn_deny.rs +++ b/crates/oxc_linter/src/options/allow_warn_deny.rs @@ -73,7 +73,7 @@ impl TryFrom<&Value> for AllowWarnDeny { fn invalid_int_severity(value: D) -> OxcDiagnostic { OxcDiagnostic::error(format!( - r#"Failed to parse rule severity, expected one of `0`, `1` or `2`, but got {value}"# + r"Failed to parse rule severity, expected one of `0`, `1` or `2`, but got {value}" )) } diff --git a/crates/oxc_linter/src/rules/eslint/func_names.rs b/crates/oxc_linter/src/rules/eslint/func_names.rs index 5cf5f5d75b197..3bee0d0f5cac3 100644 --- a/crates/oxc_linter/src/rules/eslint/func_names.rs +++ b/crates/oxc_linter/src/rules/eslint/func_names.rs @@ -450,8 +450,7 @@ impl Rule for FuncNames { |name| { // if this name shadows a variable in the outer scope **and** that name is referenced // inside the function body, it is unsafe to add a name to this function - if ctx.scopes().find_binding(func.scope_id(), &name).map_or( - false, + if ctx.scopes().find_binding(func.scope_id(), &name).is_some_and( |shadowed_var| { ctx.semantic().symbol_references(shadowed_var).any( |reference| { diff --git a/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs b/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs index 5ff70787dc521..d9ec2370ad237 100644 --- a/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs +++ b/crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs @@ -188,7 +188,7 @@ impl NoConstantBinaryExpression { .expressions .iter() .last() - .map_or(false, |last| Self::has_constant_nullishness(last, non_nullish, ctx)), + .is_some_and(|last| Self::has_constant_nullishness(last, non_nullish, ctx)), Expression::Identifier(_) => expr.evaluate_to_undefined(), _ => false, } @@ -255,7 +255,7 @@ impl NoConstantBinaryExpression { .expressions .iter() .last() - .map_or(false, |last| Self::has_constant_loose_boolean_comparison(last, ctx)), + .is_some_and(|last| Self::has_constant_loose_boolean_comparison(last, ctx)), Expression::ParenthesizedExpression(paren_expr) => { Self::has_constant_loose_boolean_comparison(&paren_expr.expression, ctx) } @@ -321,7 +321,7 @@ impl NoConstantBinaryExpression { .expressions .iter() .last() - .map_or(false, |last| Self::has_constant_strict_boolean_comparison(last, ctx)), + .is_some_and(|last| Self::has_constant_strict_boolean_comparison(last, ctx)), Expression::ParenthesizedExpression(paren_expr) => { Self::has_constant_strict_boolean_comparison(&paren_expr.expression, ctx) } @@ -350,7 +350,7 @@ impl NoConstantBinaryExpression { .expressions .iter() .last() - .map_or(false, |last| Self::is_always_new(last, ctx)), + .is_some_and(|last| Self::is_always_new(last, ctx)), Expression::AssignmentExpression(assignment_expr) if assignment_expr.operator == AssignmentOperator::Assign => { diff --git a/crates/oxc_linter/src/rules/eslint/no_eval.rs b/crates/oxc_linter/src/rules/eslint/no_eval.rs index 5e35196ef4d9d..dcfcd606b5b7e 100644 --- a/crates/oxc_linter/src/rules/eslint/no_eval.rs +++ b/crates/oxc_linter/src/rules/eslint/no_eval.rs @@ -50,7 +50,7 @@ declare_oxc_lint!( impl Rule for NoEval { fn from_configuration(value: serde_json::Value) -> Self { - let allow_indirect = value.get(0).map_or(false, |config| { + let allow_indirect = value.get(0).is_some_and(|config| { config.get("allowIndirect").and_then(serde_json::Value::as_bool).unwrap_or(false) }); diff --git a/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs b/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs index e51b4dbb9e1f4..2196472e7a968 100644 --- a/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs +++ b/crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs @@ -136,14 +136,14 @@ fn is_bool_fn_or_constructor_call(node: &AstNode) -> bool { fn is_first_arg(node: &AstNode, parent: &AstNode) -> bool { match parent.kind() { - AstKind::CallExpression(expr) => expr.arguments.first().map_or(false, |arg| { + AstKind::CallExpression(expr) => expr.arguments.first().is_some_and(|arg| { if let Some(expr) = arg.as_expression() { expr.without_parentheses().span() == node.kind().span() } else { false } }), - AstKind::NewExpression(expr) => expr.arguments.first().map_or(false, |arg| { + AstKind::NewExpression(expr) => expr.arguments.first().is_some_and(|arg| { if let Some(expr) = arg.as_expression() { expr.without_parentheses().span() == node.kind().span() } else { @@ -155,7 +155,7 @@ fn is_first_arg(node: &AstNode, parent: &AstNode) -> bool { } fn is_inside_test_condition(node: &AstNode, ctx: &LintContext) -> bool { - get_real_parent(node, ctx).map_or(false, |parent| match parent.kind() { + get_real_parent(node, ctx).is_some_and(|parent| match parent.kind() { AstKind::IfStatement(stmt) => { let expr_span = stmt.test.get_inner_expression().without_parentheses().span(); expr_span == node.kind().span() @@ -172,7 +172,7 @@ fn is_inside_test_condition(node: &AstNode, ctx: &LintContext) -> bool { let expr_span = stmt.test.get_inner_expression().without_parentheses().span(); expr_span == node.kind().span() } - AstKind::ForStatement(stmt) => stmt.test.as_ref().map_or(false, |expr| { + AstKind::ForStatement(stmt) => stmt.test.as_ref().is_some_and(|expr| { let expr_span = expr.get_inner_expression().without_parentheses().span(); expr_span == node.kind().span() }), diff --git a/crates/oxc_linter/src/rules/eslint/no_undef.rs b/crates/oxc_linter/src/rules/eslint/no_undef.rs index 592e2a5966442..e902353fa75bf 100644 --- a/crates/oxc_linter/src/rules/eslint/no_undef.rs +++ b/crates/oxc_linter/src/rules/eslint/no_undef.rs @@ -78,7 +78,7 @@ impl Rule for NoUndef { } fn has_typeof_operator(node: &AstNode<'_>, ctx: &LintContext<'_>) -> bool { - ctx.nodes().parent_node(node.id()).map_or(false, |parent| match parent.kind() { + ctx.nodes().parent_node(node.id()).is_some_and(|parent| match parent.kind() { AstKind::UnaryExpression(expr) => expr.operator == UnaryOperator::Typeof, AstKind::ParenthesizedExpression(_) => has_typeof_operator(parent, ctx), _ => false, diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs index 41ae489468c08..887e7bb619f96 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs @@ -57,7 +57,7 @@ impl<'a> HasAnyUsedBinding<'a> for ObjectPattern<'a> { return true; } self.properties.iter().any(|p| p.value.has_any_used_binding(ctx)) - || self.rest.as_ref().map_or(false, |rest| rest.argument.has_any_used_binding(ctx)) + || self.rest.as_ref().is_some_and(|rest| rest.argument.has_any_used_binding(ctx)) } } impl<'a> HasAnyUsedBinding<'a> for ArrayPattern<'a> { @@ -66,6 +66,6 @@ impl<'a> HasAnyUsedBinding<'a> for ArrayPattern<'a> { // if the destructured element is ignored, it is considered used el.get_identifier().is_some_and(|name| ctx.options.is_ignored_array_destructured(&name)) || el.has_any_used_binding(ctx) - }) || self.rest.as_ref().map_or(false, |rest| rest.argument.has_any_used_binding(ctx)) + }) || self.rest.as_ref().is_some_and(|rest| rest.argument.has_any_used_binding(ctx)) } } diff --git a/crates/oxc_linter/src/rules/eslint/valid_typeof.rs b/crates/oxc_linter/src/rules/eslint/valid_typeof.rs index 2f2532945b298..400ba350bdfa5 100644 --- a/crates/oxc_linter/src/rules/eslint/valid_typeof.rs +++ b/crates/oxc_linter/src/rules/eslint/valid_typeof.rs @@ -125,7 +125,7 @@ impl Rule for ValidTypeof { } fn from_configuration(value: serde_json::Value) -> Self { - let require_string_literals = value.get(0).map_or(false, |config| { + let require_string_literals = value.get(0).is_some_and(|config| { config .get("requireStringLiterals") .and_then(serde_json::Value::as_bool) diff --git a/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs b/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs index 76df0c34ce47b..b3bb632f973fa 100644 --- a/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs +++ b/crates/oxc_linter/src/rules/jest/no_large_snapshots.rs @@ -162,8 +162,8 @@ impl Rule for NoLargeSnapshots { } fn run_once(&self, ctx: &LintContext) { - let is_snap = ctx.file_path().to_str().map_or(false, |p| { - Path::new(p).extension().map_or(false, |ext| ext.eq_ignore_ascii_case("snap")) + let is_snap = ctx.file_path().to_str().is_some_and(|p| { + Path::new(p).extension().is_some_and(|ext| ext.eq_ignore_ascii_case("snap")) }); if is_snap { diff --git a/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs b/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs index 545d4f89af7c7..31bb51c18be44 100644 --- a/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs +++ b/crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs @@ -143,9 +143,7 @@ impl NoRestrictedMatchers { fn check_restriction(chain_call: &str, restriction: &str) -> bool { if MODIFIER_NAME.contains(restriction) - || Path::new(restriction) - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("not")) + || Path::new(restriction).extension().is_some_and(|ext| ext.eq_ignore_ascii_case("not")) { return chain_call.starts_with(restriction); } diff --git a/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs b/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs index c0452fe845b29..3e806ef2cf149 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs @@ -132,7 +132,7 @@ impl PreferJestMocked { fn can_fix<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> bool { outermost_paren_parent(node, ctx) - .map_or(false, |parent| !matches!(parent.kind(), AstKind::SimpleAssignmentTarget(_))) + .is_some_and(|parent| !matches!(parent.kind(), AstKind::SimpleAssignmentTarget(_))) } #[test] diff --git a/crates/oxc_linter/src/rules/jest/valid_title.rs b/crates/oxc_linter/src/rules/jest/valid_title.rs index 076839242bef6..6e93e0ce095af 100644 --- a/crates/oxc_linter/src/rules/jest/valid_title.rs +++ b/crates/oxc_linter/src/rules/jest/valid_title.rs @@ -293,7 +293,7 @@ fn validate_title( if !valid_title.disallowed_words.is_empty() { let Ok(disallowed_words_reg) = regex::Regex::new(&format!( - r#"(?iu)\b(?:{})\b"#, + r"(?iu)\b(?:{})\b", valid_title.disallowed_words.join("|").cow_replace('.', r"\.") )) else { return; diff --git a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs index a483cfecdf238..e7e9f04be4ae3 100644 --- a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs +++ b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs @@ -208,7 +208,7 @@ impl Rule for CheckTagNames { let config = &self.0; let user_defined_tags = settings.list_user_defined_tag_names(); - let is_dts = ctx.file_path().to_str().map_or(false, |p| p.ends_with(".d.ts")); + let is_dts = ctx.file_path().to_str().is_some_and(|p| p.ends_with(".d.ts")); // NOTE: The original rule seems to check `declare` context by visiting AST nodes. // https://github.com/gajus/eslint-plugin-jsdoc/blob/e343ab5b1efaa59b07c600138aee070b4083857e/src/rules/checkTagNames.js#L121 // But... diff --git a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs index 6313919386119..e3b48f437b676 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs @@ -205,8 +205,8 @@ impl Rule for AltText { // if let Some(custom_tags) = &self.input_type_image { let has_input_with_type_image = name.eq_ignore_ascii_case("input") - && has_jsx_prop_ignore_case(jsx_el, "type").map_or(false, |v| { - get_string_literal_prop_value(v).map_or(false, |v| v == "image") + && has_jsx_prop_ignore_case(jsx_el, "type").is_some_and(|v| { + get_string_literal_prop_value(v).is_some_and(|v| v == "image") }); if has_input_with_type_image || custom_tags.iter().any(|i| i == name) { input_type_image_rule(jsx_el, ctx); @@ -231,7 +231,7 @@ fn is_valid_alt_prop(item: &JSXAttributeItem<'_>) -> bool { fn is_presentation_role<'a>(item: &'a JSXAttributeItem<'a>) -> bool { get_string_literal_prop_value(item) - .map_or(false, |value| value == "presentation" || value == "none") + .is_some_and(|value| value == "presentation" || value == "none") } fn aria_label_has_value<'a>(item: &'a JSXAttributeItem<'a>) -> bool { @@ -253,7 +253,7 @@ fn img_rule<'a>(node: &'a JSXOpeningElement<'a>, ctx: &LintContext<'a>) { return; } - if has_jsx_prop_ignore_case(node, "role").map_or(false, is_presentation_role) { + if has_jsx_prop_ignore_case(node, "role").is_some_and(is_presentation_role) { ctx.diagnostic(prefer_alt(node.span)); return; } @@ -281,13 +281,13 @@ fn object_rule<'a>( ctx: &LintContext<'a>, ) { let has_aria_label = - has_jsx_prop_ignore_case(node, "aria-label").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-label").is_some_and(aria_label_has_value); let has_aria_labelledby = - has_jsx_prop_ignore_case(node, "aria-labelledby").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-labelledby").is_some_and(aria_label_has_value); let has_label = has_aria_label || has_aria_labelledby; let has_title_attr = has_jsx_prop_ignore_case(node, "title") .and_then(get_string_literal_prop_value) - .map_or(false, |v| !v.is_empty()); + .is_some_and(|v| !v.is_empty()); if has_label || has_title_attr || object_has_accessible_child(ctx, parent) { return; @@ -297,9 +297,9 @@ fn object_rule<'a>( fn area_rule<'a>(node: &'a JSXOpeningElement<'a>, ctx: &LintContext<'a>) { let has_aria_label = - has_jsx_prop_ignore_case(node, "aria-label").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-label").is_some_and(aria_label_has_value); let has_aria_labelledby = - has_jsx_prop_ignore_case(node, "aria-labelledby").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-labelledby").is_some_and(aria_label_has_value); let has_label = has_aria_label || has_aria_labelledby; if has_label { return; @@ -318,9 +318,9 @@ fn area_rule<'a>(node: &'a JSXOpeningElement<'a>, ctx: &LintContext<'a>) { fn input_type_image_rule<'a>(node: &'a JSXOpeningElement<'a>, ctx: &LintContext<'a>) { let has_aria_label = - has_jsx_prop_ignore_case(node, "aria-label").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-label").is_some_and(aria_label_has_value); let has_aria_labelledby = - has_jsx_prop_ignore_case(node, "aria-labelledby").map_or(false, aria_label_has_value); + has_jsx_prop_ignore_case(node, "aria-labelledby").is_some_and(aria_label_has_value); let has_label = has_aria_label || has_aria_labelledby; if has_label { return; diff --git a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs index e310e57158596..82d5d0260768f 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/aria_activedescendant_has_tabindex.rs @@ -94,7 +94,7 @@ fn is_valid_tab_index_attr(attr: &JSXAttribute) -> bool { attr.value .as_ref() .and_then(|value| parse_jsx_value(value).ok()) - .map_or(false, |parsed_value| parsed_value < -1.0) + .is_some_and(|parsed_value| parsed_value < -1.0) } #[test] diff --git a/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs b/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs index d97f9ff7cdea9..61c96dec9dc36 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs @@ -157,7 +157,7 @@ fn is_valid_autocomplete_value(value: &str) -> bool { 1 => VALID_AUTOCOMPLETE_VALUES.contains(parts[0]), 2 => VALID_AUTOCOMPLETE_COMBINATIONS .get(parts[0]) - .map_or(false, |valid_suffixes| valid_suffixes.contains(parts[1])), + .is_some_and(|valid_suffixes| valid_suffixes.contains(parts[1])), _ => false, } } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/no_aria_hidden_on_focusable.rs b/crates/oxc_linter/src/rules/jsx_a11y/no_aria_hidden_on_focusable.rs index 672e509504405..16e4b2d5a9cb6 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/no_aria_hidden_on_focusable.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/no_aria_hidden_on_focusable.rs @@ -97,7 +97,7 @@ fn is_focusable<'a>(ctx: &LintContext<'a>, element: &JSXOpeningElement<'a>) -> b if let Some(JSXAttributeItem::Attribute(attr)) = has_jsx_prop_ignore_case(element, "tabIndex") { if let Some(attr_value) = &attr.value { - return parse_jsx_value(attr_value).map_or(false, |num| num >= 0.0); + return parse_jsx_value(attr_value).is_ok_and(|num| num >= 0.0); } } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/no_redundant_roles.rs b/crates/oxc_linter/src/rules/jsx_a11y/no_redundant_roles.rs index f13b7fef88cac..d07e1829c86ed 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/no_redundant_roles.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/no_redundant_roles.rs @@ -70,7 +70,7 @@ impl Rule for NoRedundantRoles { let roles = role_values.value.split_whitespace().collect::>(); for role in &roles { let exceptions = DEFAULT_ROLE_EXCEPTIONS.get(&component); - if exceptions.map_or(false, |set| set.contains(role)) { + if exceptions.is_some_and(|set| set.contains(role)) { ctx.diagnostic_with_fix( no_redundant_roles_diagnostic(attr.span, &component, role), |fixer| fixer.delete_range(attr.span), diff --git a/crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs b/crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs index 656cb385d34cb..fd32dbd731934 100644 --- a/crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs +++ b/crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs @@ -61,8 +61,8 @@ impl Rule for NoPageCustomFont { return; } - let in_document = ctx.file_path().file_name().map_or(false, |file_name| { - file_name.to_str().map_or(false, |file_name| file_name.starts_with("_document.")) + let in_document = ctx.file_path().file_name().is_some_and(|file_name| { + file_name.to_str().is_some_and(|file_name| file_name.starts_with("_document.")) }); let span = ctx.nodes().parent_kind(node.id()).unwrap().span(); let diagnostic = if in_document { diff --git a/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs b/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs index 012291377637c..95d34899f22ff 100644 --- a/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs +++ b/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs @@ -81,7 +81,7 @@ impl Rule for PreferAwaitToCallbacks { return; } - let is_lodash = expr.callee.as_member_expression().map_or(false, |mem_expr| { + let is_lodash = expr.callee.as_member_expression().is_some_and( |mem_expr| { matches!(mem_expr.object(), Expression::Identifier(id) if matches!(id.name.as_str(), "_" | "lodash" | "underscore")) }); diff --git a/crates/oxc_linter/src/rules/react/jsx_no_target_blank.rs b/crates/oxc_linter/src/rules/react/jsx_no_target_blank.rs index 2f53829305034..b36443bdd680a 100644 --- a/crates/oxc_linter/src/rules/react/jsx_no_target_blank.rs +++ b/crates/oxc_linter/src/rules/react/jsx_no_target_blank.rs @@ -152,18 +152,20 @@ impl Rule for JsxNoTargetBlank { } } else if attribute_name == "href" || attribute_name == "action" - || ctx.settings().react.get_link_component_attrs(tag_name).map_or( - false, - |link_attribute| { + || ctx + .settings() + .react + .get_link_component_attrs(tag_name) + .is_some_and(|link_attribute| { link_attribute.contains(&CompactStr::new(attribute_name)) - }, - ) - || ctx.settings().react.get_form_component_attrs(tag_name).map_or( - false, - |form_attribute| { + }) + || ctx + .settings() + .react + .get_form_component_attrs(tag_name) + .is_some_and(|form_attribute| { form_attribute.contains(&CompactStr::new(attribute_name)) - }, - ) + }) { if let Some(val) = attribute.value.as_ref() { has_href_value = true; diff --git a/crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs b/crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs index a182341d3a58b..c77cc83c6a3a9 100644 --- a/crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs +++ b/crates/oxc_linter/src/rules/typescript/adjacent_overload_signatures.rs @@ -115,7 +115,7 @@ struct Method { impl Method { fn is_same_method(&self, other: Option<&Self>) -> bool { - other.map_or(false, |other| { + other.is_some_and(|other| { self.name == other.name && self.r#static == other.r#static && self.call_signature == other.call_signature diff --git a/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs b/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs index b0e9c05dbfe6e..23fbdefcb3cce 100644 --- a/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs +++ b/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs @@ -158,7 +158,7 @@ fn is_inferrable_type(type_annotation: &TSTypeAnnotation, init: &Expression) -> return true; } if let Expression::CallExpression(call_expr) = init.get_inner_expression() { - call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == "Symbol") + call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == "Symbol") } else { false } @@ -186,7 +186,7 @@ fn is_inferrable_type(type_annotation: &TSTypeAnnotation, init: &Expression) -> fn is_chain_call_expression_with_name(init: &Expression, name: &str) -> bool { if let Expression::ChainExpression(chain_expr) = init { if let ChainElement::CallExpression(call_expr) = &chain_expr.expression { - return call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == name); + return call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == name); } } false @@ -215,7 +215,7 @@ fn is_init_bigint(init: &Expression) -> bool { match init { Expression::CallExpression(call_expr) => { - call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == "BigInt") + call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == "BigInt") } Expression::BigIntLiteral(_) => true, _ => false, @@ -231,7 +231,7 @@ fn is_init_boolean(init: &Expression) -> bool { matches!(unary_expr.operator, UnaryOperator::LogicalNot) } Expression::CallExpression(call_expr) => { - call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == "Boolean") + call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == "Boolean") } Expression::BooleanLiteral(_) => true, _ => false, @@ -265,7 +265,7 @@ fn is_init_number(init: &Expression) -> bool { match init { Expression::Identifier(id) => id.name == "Infinity" || id.name == "NaN", Expression::CallExpression(call_expr) => { - call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == "Number") + call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == "Number") } Expression::NumericLiteral(_) => true, _ => false, @@ -277,7 +277,7 @@ fn is_init_string(init: &Expression) -> bool { } match init { Expression::CallExpression(call_expr) => { - call_expr.callee.get_identifier_reference().map_or(false, |id| id.name == "String") + call_expr.callee.get_identifier_reference().is_some_and(|id| id.name == "String") } Expression::StringLiteral(_) | Expression::TemplateLiteral(_) => true, _ => false, diff --git a/crates/oxc_linter/src/rules/unicorn/no_thenable.rs b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs index c301412324822..9e21abe341e5a 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_thenable.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs @@ -144,7 +144,7 @@ fn check_call_expression(expr: &CallExpression, ctx: &LintContext) { && !matches!(expr.arguments[0], Argument::SpreadElement(_)) && match expr.callee.as_member_expression() { Some(me) => { - me.object().get_identifier_reference().map_or(false, |ident_ref| { + me.object().get_identifier_reference().is_some_and(|ident_ref| { ident_ref.name == "Reflect" || ident_ref.name == "Object" }) && me.static_property_name() == Some("defineProperty") && !me.optional() @@ -167,7 +167,7 @@ fn check_call_expression(expr: &CallExpression, ctx: &LintContext) { Some(me) => { me.object() .get_identifier_reference() - .map_or(false, |ident_ref| ident_ref.name == "Object") + .is_some_and(|ident_ref| ident_ref.name == "Object") && me.static_property_name() == Some("fromEntries") && !me.optional() } diff --git a/crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs b/crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs index b542f53894931..10e30564dab7f 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs @@ -46,7 +46,7 @@ impl Rule for NoUnnecessaryAwait { || matches!(expr.argument, Expression::ClassExpression(_)) } || { // `+await +1` -> `++1` - ctx.nodes().parent_node(node.id()).map_or(false, |parent| { + ctx.nodes().parent_node(node.id()).is_some_and(|parent| { if let ( AstKind::UnaryExpression(parent_unary), Expression::UnaryExpression(inner_unary), diff --git a/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs b/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs index 2af3777e9e5a9..9cb8c2273b59e 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs @@ -75,7 +75,7 @@ impl Rule for NoZeroFractions { let mut fixed = fmt.clone(); let is_decimal_integer = fmt.parse::().is_ok(); let is_member_expression = - ctx.nodes().parent_node(node.id()).map_or(false, |parent_node| { + ctx.nodes().parent_node(node.id()).is_some_and(|parent_node| { matches!(parent_node.kind(), AstKind::MemberExpression(_)) }); diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_set_has.rs b/crates/oxc_linter/src/rules/unicorn/prefer_set_has.rs index 20664db08c944..6e10202615a8d 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_set_has.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_set_has.rs @@ -78,11 +78,11 @@ fn is_array_of_or_from(callee: &MemberExpression) -> bool { fn is_kind_of_array_expr(expr: &Expression) -> bool { match expr { Expression::NewExpression(new_expr) => { - new_expr.callee.get_identifier_reference().map_or(false, |ident| ident.name == "Array") + new_expr.callee.get_identifier_reference().is_some_and(|ident| ident.name == "Array") } Expression::CallExpression(call_expr) => { let Some(callee) = call_expr.callee.get_member_expr() else { - return call_expr.callee_name().map_or(false, |name| name == "Array"); + return call_expr.callee_name().is_some_and(|name| name == "Array"); }; if callee.is_computed() || callee.optional() { diff --git a/crates/oxc_linter/src/utils/express.rs b/crates/oxc_linter/src/utils/express.rs index 56e9e9e4b4fd3..a7f0f9a668043 100644 --- a/crates/oxc_linter/src/utils/express.rs +++ b/crates/oxc_linter/src/utils/express.rs @@ -93,7 +93,7 @@ const COMMON_REQUEST_NAMES: Set<&'static str> = phf_set! { "request", }; fn is_req_param(param: &FormalParameter) -> bool { - param.pattern.get_identifier().map_or(false, |id| COMMON_REQUEST_NAMES.contains(id.as_str())) + param.pattern.get_identifier().is_some_and(|id| COMMON_REQUEST_NAMES.contains(id.as_str())) } const COMMON_RESPONSE_NAMES: Set<&'static str> = phf_set! { @@ -102,7 +102,7 @@ const COMMON_RESPONSE_NAMES: Set<&'static str> = phf_set! { "response", }; fn is_res_param(param: &FormalParameter) -> bool { - param.pattern.get_identifier().map_or(false, |id| COMMON_RESPONSE_NAMES.contains(id.as_str())) + param.pattern.get_identifier().is_some_and(|id| COMMON_RESPONSE_NAMES.contains(id.as_str())) } const COMMON_NEXT_NAMES: Set<&'static str> = phf_set! { @@ -110,7 +110,7 @@ const COMMON_NEXT_NAMES: Set<&'static str> = phf_set! { "next", }; fn is_next_param(param: &FormalParameter) -> bool { - param.pattern.get_identifier().map_or(false, |id| COMMON_NEXT_NAMES.contains(id.as_str())) + param.pattern.get_identifier().is_some_and(|id| COMMON_NEXT_NAMES.contains(id.as_str())) } const COMMON_ERROR_NAMES: Set<&'static str> = phf_set! { @@ -120,5 +120,5 @@ const COMMON_ERROR_NAMES: Set<&'static str> = phf_set! { "exception", }; fn is_error_param(param: &FormalParameter) -> bool { - param.pattern.get_identifier().map_or(false, |id| COMMON_ERROR_NAMES.contains(id.as_str())) + param.pattern.get_identifier().is_some_and(|id| COMMON_ERROR_NAMES.contains(id.as_str())) } diff --git a/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs b/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs index 794da7e2db21f..66ff87a608ea7 100644 --- a/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs +++ b/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs @@ -428,7 +428,7 @@ impl<'a> KnownMemberExpressionProperty<'a> { } pub fn is_name_equal(&self, name: &str) -> bool { - self.name().map_or(false, |n| n == name) + self.name().is_some_and(|n| n == name) } pub fn is_name_unequal(&self, name: &str) -> bool { @@ -436,7 +436,7 @@ impl<'a> KnownMemberExpressionProperty<'a> { } pub fn is_name_in_modifiers(&self, modifiers: &[ModifierName]) -> bool { - self.name().map_or(false, |name| { + self.name().is_some_and(|name| { if let Some(modifier_name) = ModifierName::from(name.as_ref()) { return modifiers.contains(&modifier_name); } diff --git a/crates/oxc_linter/src/utils/react.rs b/crates/oxc_linter/src/utils/react.rs index eeee8425a75cd..567bff4a64792 100644 --- a/crates/oxc_linter/src/utils/react.rs +++ b/crates/oxc_linter/src/utils/react.rs @@ -77,7 +77,7 @@ pub fn is_hidden_from_screen_reader<'a>( } } - has_jsx_prop_ignore_case(node, "aria-hidden").map_or(false, |v| match get_prop_value(v) { + has_jsx_prop_ignore_case(node, "aria-hidden").is_some_and(|v| match get_prop_value(v) { None => true, Some(JSXAttributeValue::StringLiteral(s)) if s.value == "true" => true, Some(JSXAttributeValue::ExpressionContainer(container)) => { diff --git a/crates/oxc_minifier/src/ast_passes/peephole_substitute_alternate_syntax.rs b/crates/oxc_minifier/src/ast_passes/peephole_substitute_alternate_syntax.rs index b45d009933276..b7fe7f63ae9ce 100644 --- a/crates/oxc_minifier/src/ast_passes/peephole_substitute_alternate_syntax.rs +++ b/crates/oxc_minifier/src/ast_passes/peephole_substitute_alternate_syntax.rs @@ -955,7 +955,7 @@ impl<'a, 'b> PeepholeSubstituteAlternateSyntax { let arguments_len = e.arguments.len(); arguments_len == 0 || (arguments_len >= 1 - && e.arguments[0].as_expression().map_or(false, |first_argument| { + && e.arguments[0].as_expression().is_some_and(|first_argument| { let ty = ValueType::from(first_argument); !ty.is_undetermined() && !ty.is_object() })) diff --git a/crates/oxc_minifier/src/ast_passes/statement_fusion.rs b/crates/oxc_minifier/src/ast_passes/statement_fusion.rs index 32b6eec51e8b8..01aed31d60c62 100644 --- a/crates/oxc_minifier/src/ast_passes/statement_fusion.rs +++ b/crates/oxc_minifier/src/ast_passes/statement_fusion.rs @@ -94,7 +94,7 @@ impl<'a> StatementFusion { } Statement::BlockStatement(block) => { can_merge_block_stmt(block) - && block.body.first().map_or(false, Self::is_fusable_control_statement) + && block.body.first().is_some_and(Self::is_fusable_control_statement) } _ => false, } diff --git a/crates/oxc_parser/src/js/class.rs b/crates/oxc_parser/src/js/class.rs index cdc33ce60954c..6f5132b16e410 100644 --- a/crates/oxc_parser/src/js/class.rs +++ b/crates/oxc_parser/src/js/class.rs @@ -402,7 +402,7 @@ impl<'a> ParserImpl<'a> { ) -> Result> { let kind = if !r#static && !computed - && key.prop_name().map_or(false, |(name, _)| name == "constructor") + && key.prop_name().is_some_and(|(name, _)| name == "constructor") { MethodDefinitionKind::Constructor } else { diff --git a/crates/oxc_prettier/src/needs_parens.rs b/crates/oxc_prettier/src/needs_parens.rs index 5931d5e12b372..a92888351bd39 100644 --- a/crates/oxc_prettier/src/needs_parens.rs +++ b/crates/oxc_prettier/src/needs_parens.rs @@ -334,7 +334,7 @@ impl<'a> Prettier<'a> { .init .as_ref() .and_then(ForStatementInit::as_expression) - .map_or(false, |e| Self::starts_with_no_lookahead_token(e, ident.span)), + .is_some_and(|e| Self::starts_with_no_lookahead_token(e, ident.span)), AstKind::ForInStatement(stmt) => { if let Some(target) = stmt.left.as_assignment_target() { if let Some(e) = target.as_member_expression() { @@ -643,10 +643,9 @@ impl<'a> Prettier<'a> { } } } - Expression::SequenceExpression(e) => e - .expressions - .first() - .map_or(false, |e| Self::starts_with_no_lookahead_token(e, span)), + Expression::SequenceExpression(e) => { + e.expressions.first().is_some_and(|e| Self::starts_with_no_lookahead_token(e, span)) + } Expression::ChainExpression(e) => match &e.expression { ChainElement::CallExpression(e) => { Self::starts_with_no_lookahead_token(&e.callee, span) diff --git a/crates/oxc_regular_expression/src/parser/pattern_parser/character.rs b/crates/oxc_regular_expression/src/parser/pattern_parser/character.rs index aa1211c6c4e93..794e875496eb9 100644 --- a/crates/oxc_regular_expression/src/parser/pattern_parser/character.rs +++ b/crates/oxc_regular_expression/src/parser/pattern_parser/character.rs @@ -3,7 +3,7 @@ // ^ $ \ . * + ? ( ) [ ] { } | // ``` pub fn is_syntax_character(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| { + char::from_u32(cp).is_some_and(|ch| { matches!( ch, '^' | '$' | '\\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' @@ -16,9 +16,8 @@ pub fn is_syntax_character(cp: u32) -> bool { // ( ) [ ] { } / - \ | // ``` pub fn is_class_set_syntax_character(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| { - matches!(ch, '(' | ')' | '[' | ']' | '{' | '}' | '/' | '-' | '\\' | '|') - }) + char::from_u32(cp) + .is_some_and(|ch| matches!(ch, '(' | ')' | '[' | ']' | '{' | '}' | '/' | '-' | '\\' | '|')) } // ``` @@ -26,8 +25,8 @@ pub fn is_class_set_syntax_character(cp: u32) -> bool { // && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~ // ```` pub fn is_class_set_reserved_double_punctuator(cp1: u32, cp2: u32) -> bool { - char::from_u32(cp1).map_or(false, |ch1| { - char::from_u32(cp2).map_or(false, |ch2| { + char::from_u32(cp1).is_some_and(|ch1| { + char::from_u32(cp2).is_some_and(|ch2| { matches!( (ch1, ch2), ('&', '&') @@ -59,7 +58,7 @@ pub fn is_class_set_reserved_double_punctuator(cp1: u32, cp2: u32) -> bool { // & - ! # % , : ; < = > @ ` ~ // ``` pub fn is_class_set_reserved_punctuator(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| { + char::from_u32(cp).is_some_and(|ch| { matches!( ch, '&' | '-' | '!' | '#' | '%' | ',' | ':' | ';' | '<' | '=' | '>' | '@' | '`' | '~' @@ -68,11 +67,11 @@ pub fn is_class_set_reserved_punctuator(cp: u32) -> bool { } pub fn is_decimal_digit(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| ch.is_ascii_digit()) + char::from_u32(cp).is_some_and(|ch| ch.is_ascii_digit()) } pub fn is_octal_digit(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| ch.is_ascii_digit() && ch < '8') + char::from_u32(cp).is_some_and(|ch| ch.is_ascii_digit() && ch < '8') } pub fn is_valid_unicode(cp: u32) -> bool { @@ -85,7 +84,7 @@ pub fn is_valid_unicode(cp: u32) -> bool { // _ // ``` pub fn is_unicode_property_name_character(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| ch.is_ascii_alphabetic() || ch == '_') + char::from_u32(cp).is_some_and(|ch| ch.is_ascii_alphabetic() || ch == '_') } // ``` @@ -94,24 +93,23 @@ pub fn is_unicode_property_name_character(cp: u32) -> bool { // DecimalDigit // ``` pub fn is_unicode_property_value_character(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| ch.is_ascii_alphanumeric() || ch == '_') + char::from_u32(cp).is_some_and(|ch| ch.is_ascii_alphanumeric() || ch == '_') } pub fn is_unicode_id_start(cp: u32) -> bool { - char::from_u32(cp).map_or(false, unicode_id_start::is_id_start) + char::from_u32(cp).is_some_and(unicode_id_start::is_id_start) } pub fn is_unicode_id_continue(cp: u32) -> bool { - char::from_u32(cp).map_or(false, unicode_id_start::is_id_continue) + char::from_u32(cp).is_some_and(unicode_id_start::is_id_continue) } pub fn is_identifier_start_char(cp: u32) -> bool { - char::from_u32(cp) - .map_or(false, |ch| unicode_id_start::is_id_start(ch) || ch == '$' || ch == '_') + char::from_u32(cp).is_some_and(|ch| unicode_id_start::is_id_start(ch) || ch == '$' || ch == '_') } pub fn is_identifier_part_char(cp: u32) -> bool { - char::from_u32(cp).map_or(false, |ch| unicode_id_start::is_id_continue(ch) || ch == '$') + char::from_u32(cp).is_some_and(|ch| unicode_id_start::is_id_continue(ch) || ch == '$') } pub fn map_control_escape(cp: u32) -> Option { diff --git a/crates/oxc_regular_expression/src/parser/pattern_parser/pattern_parser_impl.rs b/crates/oxc_regular_expression/src/parser/pattern_parser/pattern_parser_impl.rs index 75697d54c4bf6..9ad376aca0ec7 100644 --- a/crates/oxc_regular_expression/src/parser/pattern_parser/pattern_parser_impl.rs +++ b/crates/oxc_regular_expression/src/parser/pattern_parser/pattern_parser_impl.rs @@ -2344,7 +2344,7 @@ impl<'a> PatternParser<'a> { // - && ClassSubtraction has ClassOperands // - && the first ClassOperand has MayContainStrings: true ast::CharacterClassContentsKind::Subtraction => { - body.iter().next().map_or(false, may_contain_strings) + body.iter().next().is_some_and(may_contain_strings) } } } diff --git a/crates/oxc_transformer/src/options/babel/mod.rs b/crates/oxc_transformer/src/options/babel/mod.rs index e9a7fdaf9160f..7749c8a6c9ec2 100644 --- a/crates/oxc_transformer/src/options/babel/mod.rs +++ b/crates/oxc_transformer/src/options/babel/mod.rs @@ -180,10 +180,10 @@ impl BabelOptions { } pub fn is_module(&self) -> bool { - self.source_type.as_ref().map_or(false, |s| s.as_str() == "module") + self.source_type.as_ref().is_some_and(|s| s.as_str() == "module") } pub fn is_unambiguous(&self) -> bool { - self.source_type.as_ref().map_or(false, |s| s.as_str() == "unambiguous") + self.source_type.as_ref().is_some_and(|s| s.as_str() == "unambiguous") } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6cc20eae8bd04..67b05271bdd5a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.83.0" +channel = "1.84.0" profile = "default" diff --git a/tasks/coverage/src/babel/mod.rs b/tasks/coverage/src/babel/mod.rs index 3f53eb7ba330e..44dfc89ce316e 100644 --- a/tasks/coverage/src/babel/mod.rs +++ b/tasks/coverage/src/babel/mod.rs @@ -110,7 +110,7 @@ impl BabelCase { let output_json = Self::read_output_json(path); if let Some(output_json) = output_json { - return output_json.errors.map_or(false, |errors| !errors.is_empty()); + return output_json.errors.is_some_and(|errors| !errors.is_empty()); } if options.throws.is_some() { diff --git a/tasks/rulegen/src/main.rs b/tasks/rulegen/src/main.rs index beb86e180546d..c819ed24218ea 100644 --- a/tasks/rulegen/src/main.rs +++ b/tasks/rulegen/src/main.rs @@ -143,7 +143,7 @@ impl TestCase { ); // ("null==null", "null === null", None), - Some(format!(r#"({code}, {output}, {config})"#)) + Some(format!(r"({code}, {output}, {config})")) } }