mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(linter): use get_first_parameter_name from unicorn utils (#4255)
This commit is contained in:
parent
3416099a18
commit
b5a8f3c60c
1 changed files with 2 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use oxc_ast::{
|
||||
ast::{Argument, BindingPatternKind, Expression, FormalParameters, FunctionBody, Statement},
|
||||
ast::{Argument, Expression, FormalParameters, FunctionBody, Statement},
|
||||
AstKind,
|
||||
};
|
||||
use oxc_diagnostics::OxcDiagnostic;
|
||||
|
|
@ -7,7 +7,7 @@ use oxc_macros::declare_oxc_lint;
|
|||
use oxc_semantic::AstNodeId;
|
||||
use oxc_span::Span;
|
||||
|
||||
use crate::{context::LintContext, rule::Rule, AstNode};
|
||||
use crate::{context::LintContext, rule::Rule, utils::get_first_parameter_name, AstNode};
|
||||
|
||||
fn function(span0: Span, x1: &str) -> OxcDiagnostic {
|
||||
OxcDiagnostic::warn(format!("eslint-plugin-unicorn(prefer-native-coercion-functions): The function is equivalent to `{x1}`. Call `{x1}` directly.")).with_label(span0)
|
||||
|
|
@ -94,15 +94,6 @@ impl Rule for PreferNativeCoercionFunctions {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_first_parameter_name<'a>(arg: &'a FormalParameters) -> Option<&'a str> {
|
||||
let first_func_param = arg.items.first()?;
|
||||
let BindingPatternKind::BindingIdentifier(first_func_param) = &first_func_param.pattern.kind
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
Some(first_func_param.name.as_str())
|
||||
}
|
||||
|
||||
fn check_function(
|
||||
arg: &FormalParameters,
|
||||
function_body: &FunctionBody,
|
||||
|
|
|
|||
Loading…
Reference in a new issue