Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency rust to v1.84.0 #8391

Merged
merged 1 commit into from
Jan 9, 2025
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 crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_diagnostics/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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,
) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_ecmascript/src/string_to_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/options/allow_warn_deny.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl TryFrom<&Value> for AllowWarnDeny {

fn invalid_int_severity<D: Display>(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}"
))
}

Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_linter/src/rules/eslint/func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 =>
{
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand All @@ -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()
}),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_undef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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))
}
}
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/valid_typeof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/jest/no_large_snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jest/prefer_jest_mocked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jest/valid_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
22 changes: 11 additions & 11 deletions crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ impl Rule for AltText {
// <input type="image">
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);
Expand All @@ -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 {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsx_a11y/autocomplete_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/jsx_a11y/no_redundant_roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Rule for NoRedundantRoles {
let roles = role_values.value.split_whitespace().collect::<Vec<_>>();
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),
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
});

Expand Down
Loading
Loading