From c2f760f1edcf1204a68a2f216421843d42f81dfb Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 11 Mar 2023 23:37:19 +0800 Subject: [PATCH] chore: run `types -w" to fix all typos --- crates/oxc_ast/src/source_type.rs | 10 +++++----- crates/oxc_linter/src/rules/eq_eq_eq.rs | 6 +++--- crates/oxc_linter/src/rules/use_isnan.rs | 6 +++--- crates/oxc_parser/src/diagnostics.rs | 2 +- crates/oxc_parser/src/js/binding.rs | 2 +- crates/oxc_parser/src/js/expression.rs | 4 ++-- crates/oxc_parser/src/js/grammar.rs | 2 +- crates/oxc_parser/src/js/statement.rs | 4 ++-- crates/oxc_parser/src/list.rs | 6 +++--- crates/oxc_parser/src/ts/declaration.rs | 2 +- crates/oxc_parser/src/ts/types.rs | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crates/oxc_ast/src/source_type.rs b/crates/oxc_ast/src/source_type.rs index 16187cb23..351165d26 100644 --- a/crates/oxc_ast/src/source_type.rs +++ b/crates/oxc_ast/src/source_type.rs @@ -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>(path: P) -> Result { 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"), ) })?; diff --git a/crates/oxc_linter/src/rules/eq_eq_eq.rs b/crates/oxc_linter/src/rules/eq_eq_eq.rs index 12fa5d6e7..d30075dc6 100644 --- a/crates/oxc_linter/src/rules/eq_eq_eq.rs +++ b/crates/oxc_linter/src/rules/eq_eq_eq.rs @@ -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), ); } } diff --git a/crates/oxc_linter/src/rules/use_isnan.rs b/crates/oxc_linter/src/rules/use_isnan.rs index 2cd958843..6d22566b5 100644 --- a/crates/oxc_linter/src/rules/use_isnan.rs +++ b/crates/oxc_linter/src/rules/use_isnan.rs @@ -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 => { diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index 38f3ff898..c8e420fab 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -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, ); diff --git a/crates/oxc_parser/src/js/binding.rs b/crates/oxc_parser/src/js/binding.rs index 0424a3be4..65feae325 100644 --- a/crates/oxc_parser/src/js/binding.rs +++ b/crates/oxc_parser/src/js/binding.rs @@ -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)); } diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index d48b29b49..170fd0522 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -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 `
=
` 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() diff --git a/crates/oxc_parser/src/js/grammar.rs b/crates/oxc_parser/src/js/grammar.rs index 78b3da4d1..4d4b8472e 100644 --- a/crates/oxc_parser/src/js/grammar.rs +++ b/crates/oxc_parser/src/js/grammar.rs @@ -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()); diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index e827c5180..7e1e89436 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -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> { + fn parse_expression_or_labeled_statement(&mut self) -> Result> { let span = self.start_span(); let expr = self.parse_expression()?; if let Expression::Identifier(ident) = &expr { diff --git a/crates/oxc_parser/src/list.rs b/crates/oxc_parser/src/list.rs index ee4d575f4..b66d8d216 100644 --- a/crates/oxc_parser/src/list.rs +++ b/crates/oxc_parser/src/list.rs @@ -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; } diff --git a/crates/oxc_parser/src/ts/declaration.rs b/crates/oxc_parser/src/ts/declaration.rs index f957cba64..10136cc40 100644 --- a/crates/oxc_parser/src/ts/declaration.rs +++ b/crates/oxc_parser/src/ts/declaration.rs @@ -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); } diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index 0b39ef505..73873ccae 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -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 for ModifierFlags { fn from(value: Kind) -> Self { match value {