mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
chore: run `types -w" to fix all typos
This commit is contained in:
parent
109f551d72
commit
c2f760f1ed
11 changed files with 24 additions and 24 deletions
|
|
@ -40,8 +40,8 @@ pub enum LanguageVariant {
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SourceTypeError {
|
||||
#[error("Unkown Extension: {0}")]
|
||||
UnkownExtension(String),
|
||||
#[error("Unknown Extension: {0}")]
|
||||
UnknownExtension(String),
|
||||
}
|
||||
|
||||
impl Default for SourceType {
|
||||
|
|
@ -155,14 +155,14 @@ impl SourceType {
|
|||
}
|
||||
|
||||
/// Converts file path to `SourceType`
|
||||
/// returns `SourceTypeError::UnkownExtension` if:
|
||||
/// returns `SourceTypeError::UnknownExtension` if:
|
||||
/// * there is no file name
|
||||
/// * the file extension is not one of "js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx"
|
||||
/// # Errors
|
||||
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, SourceTypeError> {
|
||||
let file_name =
|
||||
path.as_ref().file_name().and_then(std::ffi::OsStr::to_str).ok_or_else(|| {
|
||||
SourceTypeError::UnkownExtension("Please provide a valid file name.".to_string())
|
||||
SourceTypeError::UnknownExtension("Please provide a valid file name.".to_string())
|
||||
})?;
|
||||
|
||||
let extension = path
|
||||
|
|
@ -172,7 +172,7 @@ impl SourceType {
|
|||
.filter(|s| VALID_EXTENSIONS.contains(s))
|
||||
.ok_or_else(|| {
|
||||
let path = path.as_ref().to_string_lossy();
|
||||
SourceTypeError::UnkownExtension(
|
||||
SourceTypeError::UnknownExtension(
|
||||
format!("Please provide a valid file extension for {path}: .js, .mjs, .jsx or .cjs for JavaScript, or .ts, .mts, .cts or .tsx for TypeScript"),
|
||||
)
|
||||
})?;
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ impl Rule for EqEqEq {
|
|||
|
||||
if !is_valid_comparison {
|
||||
let operator = binary_expr.operator.as_str();
|
||||
let prefered_operator = to_strict_operator(binary_expr.operator).as_str();
|
||||
let preferred_operator = to_strict_operator(binary_expr.operator).as_str();
|
||||
ctx.diagnostic_with_fix(
|
||||
EqEqEqDiagnostic(operator, prefered_operator, binary_expr.span),
|
||||
|| Fix::new(prefered_operator, binary_expr.span),
|
||||
EqEqEqDiagnostic(operator, preferred_operator, binary_expr.span),
|
||||
|| Fix::new(preferred_operator, binary_expr.span),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
|
|||
enum UseIsnanDiagnostic {
|
||||
#[error("eslint(use-isnan): Requires calls to isNaN() when checking for NaN")]
|
||||
#[diagnostic(severity(warning), help("Use the isNaN function to compare with NaN."))]
|
||||
ComparisinWithNaN(#[label] Span),
|
||||
ComparisonWithNaN(#[label] Span),
|
||||
#[error("eslint(use-isnan): Requires calls to isNaN() when checking for NaN")]
|
||||
#[diagnostic(
|
||||
severity(warning),
|
||||
|
|
@ -81,10 +81,10 @@ impl Rule for UseIsnan {
|
|||
match node.get().kind() {
|
||||
AstKind::BinaryExpression(expr) if expr.operator.is_compare() || expr.operator.is_equality() => {
|
||||
if is_nan_identifier(&expr.left) {
|
||||
ctx.diagnostic(UseIsnanDiagnostic::ComparisinWithNaN(expr.left.span()));
|
||||
ctx.diagnostic(UseIsnanDiagnostic::ComparisonWithNaN(expr.left.span()));
|
||||
}
|
||||
if is_nan_identifier(&expr.right) {
|
||||
ctx.diagnostic(UseIsnanDiagnostic::ComparisinWithNaN(expr.right.span()));
|
||||
ctx.diagnostic(UseIsnanDiagnostic::ComparisonWithNaN(expr.right.span()));
|
||||
}
|
||||
}
|
||||
AstKind::SwitchCase(case) if self.enforce_for_switch_case => {
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ pub struct SpreadLastElement(#[label("Spread must be last element")] pub Span);
|
|||
#[derive(Debug, Error, Diagnostic)]
|
||||
#[error("Unexpected trailing comma after rest element")]
|
||||
#[diagnostic()]
|
||||
pub struct RestElementTraillingComma(
|
||||
pub struct RestElementTrailingComma(
|
||||
#[label("Unexpected trailing comma after rest element")] pub Span,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
if self.at(Kind::Comma) {
|
||||
if self.peek_at(Kind::RBrack) {
|
||||
self.error(diagnostics::RestElementTraillingComma(self.cur_token().span()));
|
||||
self.error(diagnostics::RestElementTrailingComma(self.cur_token().span()));
|
||||
} else {
|
||||
self.error(diagnostics::RestElement(span));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ impl<'a> Parser<'a> {
|
|||
Kind::LBrack => self.parse_array_expression(),
|
||||
// ObjectLiteral
|
||||
Kind::LCurly => self.parse_object_expression(),
|
||||
// FunctionExpession, GeneratorExpression
|
||||
// FunctionExpression, GeneratorExpression
|
||||
Kind::Function => self.parse_function_expression(span, false),
|
||||
// ClassExpression
|
||||
Kind::Class => self.parse_class_expression(),
|
||||
|
|
@ -803,7 +803,7 @@ impl<'a> Parser<'a> {
|
|||
// This is need for jsx `<div>=</div>` case
|
||||
let kind = self.re_lex_right_angle();
|
||||
|
||||
// Omit the In keyword for the grammer in 13.10 Relational Operators
|
||||
// Omit the In keyword for the grammar in 13.10 Relational Operators
|
||||
// RelationalExpression[In, Yield, Await] :
|
||||
// [+In] RelationalExpression[+In, ?Yield, ?Await] in ShiftExpression[?Yield, ?Await]
|
||||
if kind == Kind::In && !self.ctx.has_in()
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ impl<'a> CoverGrammar<'a, ArrayExpression<'a>> for ArrayAssignmentTarget<'a> {
|
|||
if i == len - 1 {
|
||||
rest = Some(AssignmentTarget::cover(elem.unbox().argument, p)?);
|
||||
if let Some(span) = expr.trailing_comma {
|
||||
p.error(diagnostics::RestElementTraillingComma(span));
|
||||
p.error(diagnostics::RestElementTrailingComma(span));
|
||||
}
|
||||
} else {
|
||||
return Err(diagnostics::SpreadLastElement(elem.span).into());
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ impl<'a> Parser<'a> {
|
|||
_ if self.ts_enabled() && self.at_start_of_ts_declaration() => {
|
||||
self.parse_ts_declaration_statement(start_span)
|
||||
}
|
||||
_ => self.parse_expression_or_labeled_statment(),
|
||||
_ => self.parse_expression_or_labeled_statement(),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_expression_or_labeled_statment(&mut self) -> Result<Statement<'a>> {
|
||||
fn parse_expression_or_labeled_statement(&mut self) -> Result<Statement<'a>> {
|
||||
let span = self.start_span();
|
||||
let expr = self.parse_expression()?;
|
||||
if let Expression::Identifier(ident) = &expr {
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ pub trait SeparatedList<'a>: Sized {
|
|||
/// Close element, e.g.. `}` `]` `)`
|
||||
fn close(&self) -> Kind;
|
||||
|
||||
/// Seperator element, e.g. `,`
|
||||
fn seperator(&self) -> Kind {
|
||||
/// Separator element, e.g. `,`
|
||||
fn separator(&self) -> Kind {
|
||||
Kind::Comma
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ pub trait SeparatedList<'a>: Sized {
|
|||
if first {
|
||||
first = false;
|
||||
} else {
|
||||
p.expect(self.seperator())?;
|
||||
p.expect(self.separator())?;
|
||||
if p.at(self.close()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ mod test_is_declaration {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_lexical_decleration() {
|
||||
fn test_lexical_declaration() {
|
||||
run_check("const a = 1", true);
|
||||
run_check("let a = 1", true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
/// It is the caller's savety to always check by `Kind::is_modifier_kind`
|
||||
/// It is the caller's safety to always check by `Kind::is_modifier_kind`
|
||||
/// before converting [`Kind`] to [`ModifierFlags`] so that we can assume here that
|
||||
/// the convertion always succeeds.
|
||||
/// the conversion always succeeds.
|
||||
impl From<Kind> for ModifierFlags {
|
||||
fn from(value: Kind) -> Self {
|
||||
match value {
|
||||
|
|
|
|||
Loading…
Reference in a new issue