Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ declare_source_rule! {
///
/// Group matchers can also be glob patterns and list of glob patterns.
/// Glob patterns select imports and exports with a source that matches the pattern.
/// In the following example, we create two groups: one that gathers imports/exports with a source starting with `@my/lib` except `@my/lib/speciaal` and the other that gathers imports/exports starting with `@/`.
/// In the following example, we create two groups: one that gathers imports/exports with a source starting with `@my/lib` except `@my/lib/special` and the other that gathers imports/exports starting with `@/`.
///
/// ```json
/// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Rule for NoSvgWithoutTitle {
}
}

/// Checks if the given attribute is attached to the `svg` element and the attribute value is used by the `id` of the childs element.
/// Checks if the given attribute is attached to the `svg` element and the attribute value is used by the `id` of the child element.
fn is_valid_attribute_value(
attribute: Option<JsxAttribute>,
jsx_child_list: &JsxChildList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Rule for NoUselessStringRaw {
},
)
.note(markup! {
"Remove the String.raw call beacause it's useless here, String.raw can deal with string which contains escape sequence like \\n, \\t, \\r, \\\\, \\\", \\\'."
"Remove the String.raw call because it's useless here, String.raw can deal with string which contains escape sequence like \\n, \\t, \\r, \\\\, \\\", \\\'."
}),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Rule for NoUselessThisAlias {
}
is_this_alias = true;
}
// This cehck is useful when the loop is not executed (no write).
// This check is useful when the loop is not executed (no write).
if !is_this_alias {
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ fn analyze_fine(cfg: &JsControlFlowGraph, signals: &mut UnreachableRanges) {
'blocks: for (block_id, block) in cfg.block_id_iter() {
match block_paths.get(&block_id) {
// Block has incoming paths, but may be unreachable if they all
// have a dominating terminator intruction
// have a dominating terminator instruction
Some(paths) => {
let mut terminators = Vec::new();
for path in paths {
Expand Down Expand Up @@ -444,7 +444,7 @@ fn traverse_cfg(
});

// This maps holds a list of "path state", the active terminator
// intruction for each path that can reach the block
// instruction for each path that can reach the block
let mut block_paths = FxHashMap::default();

while let Some(mut path) = queue.pop_front() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ impl Rule for UseJsonImportAttributes {
let prev_assertions = prev_assertion.assertions();

let mut items = vec![entry];
let mut seperators = vec![];
let mut separators = vec![];

// if there is more than 1 assertion, we need to add a comma after the first attribute
if prev_assertions.len() > 0 {
seperators.push(
separators.push(
make::token(T![,])
.with_trailing_trivia([(TriviaPieceKind::Whitespace, " ")]),
);
Expand All @@ -220,12 +220,12 @@ impl Rule for UseJsonImportAttributes {
items.push(node);
}
if let Ok(Some(trailing_separator)) = trailing_separator {
seperators.push(trailing_separator);
separators.push(trailing_separator);
}
}

prev_assertion
.with_assertions(make::js_import_assertion_entry_list(items, seperators))
.with_assertions(make::js_import_assertion_entry_list(items, separators))
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Rule for NoAwaitInLoops {
preorder.skip_subtree();
}

// skip valid case: bidning in `for in`
// skip valid case: binding in `for in`
// `async function foo() { for (var bar = await baz in qux) {} }`
if JsForVariableDeclaration::can_cast(node.kind()) {
preorder.skip_subtree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ fn test_check_unwanted_polyfill() {
let actual = check_unwanted_polyfill(src, NEXT_POLYFILLED_FEATURES);
assert_eq!(actual, None);

// Differente URL
// Different URL
let src = "https://example.com/polyfill.min.js?features=Array.prototype.includes";
let actual = check_unwanted_polyfill(src, NEXT_POLYFILLED_FEATURES);
assert_eq!(actual, None);
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/lint/style/no_useless_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn breaks_early(statement: AnyJsStatement) -> Option<()> {
stmt_stack.push((else_clause.alternate().ok()?, metadata));
}
AnyJsStatement::JsSwitchStatement(switch_stmt) => {
// To simplify, We do not take fallthoughs into account.
// To simplify, We do not take fallthroughs into account.
// Thus, this can miss some useless else.
let cases = switch_stmt.cases();
let Some(last_case) = cases.last() else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Rule for UseArrayLiterals {
&& !type_arg.is_primitive_type()
&& !matches!(type_arg, AnyTsType::TsReferenceType(_))
{
// only wrap the type in parens if its not a literal, primative, or reference
// only wrap the type in parens if its not a literal, primitive, or reference
make::parenthesized_ts(type_arg).into()
} else {
type_arg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Rule for UseEnumInitializers {
has_mutations = true;

// When creating the replacement node we first need to remove the trailing trivia.
// Otherwise nodes without a trailing comma will add [JsSyntacKind::EQ] and [EnumInitializer]
// Otherwise nodes without a trailing comma will add [JsSyntaxKind::EQ] and [EnumInitializer]
// after it.
let new_enum_member = enum_member
.clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl Rule for UseObjectSpread {
object_member_separators.extend(separators);
object_members.extend(members);
}
// All the other expressions will be spreaded.
// All the other expressions will be spread.
_ => {
object_members.push(AnyJsObjectMember::JsSpread(make::js_spread(
make::token(JsSyntaxKind::DOT3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ fn collect_non_readonly_class_member_properties(

/// Collects all all mutable (non-readonly) constructor parameters from a given class declaration. If private_only is true, it only includes parameters with private visibility.
/// It returns a Vec<PropOrParam> representing these parameters, which are candidates for being marked as readonly.
/// e.g. constructor(private paramOne: string, public paramTwo: number) {} makes both paramOne and paramTwo classs member properties.
/// e.g. constructor(private paramOne: string, public paramTwo: number) {} makes both paramOne and paramTwo class member properties.
fn collect_non_readonly_constructor_parameters(
class_declaration: &JsClassDeclaration,
private_only: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare_lint_rule! {
/// > If you think you need this then you probably want the `undefined` type instead.
///
/// The code action suggests using `undefined` instead of `void`.
/// It is unsafe because a variable with the `void` type cannot be asigned to a variable with the `undefined` type.
/// It is unsafe because a variable with the `void` type cannot be assigned to a variable with the `undefined` type.
///
/// ## Examples
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn is_global_document(expr: &AnyJsExpression, model: &SemanticModel) -> Option<(
let decl = bind.tree().declaration()?;
let decl = decl.parent_binding_pattern_declaration().unwrap_or(decl);
match decl {
// const foo = documnet;
// const foo = document;
AnyJsBindingDeclaration::JsVariableDeclarator(declarator) => {
let initializer = declarator.initializer()?;
let right_expr = initializer.expression().ok()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Rule for NoUnsafeNegation {
let node = ctx.query();
let mut mutation = ctx.root().begin();

// The action could be splitted to three steps
// The action could be split to three steps
// 1. Remove `!` operator of unary expression
// 2. Wrap the expression with `()`, convert the expression to a `JsParenthesizedExpression`
// 3. Replace the `JsParenthesizedExpression` to `JsUnaryExpression` by adding a `JsUnaryOperator::LogicalNot`
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/react/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const REACT_COMPONENT_PARAMS_LIMIT: usize = 1;
/// Represents information about a React component.
#[derive(Debug, PartialEq, Eq)]
pub(crate) struct ReactComponentInfo {
/// Range of the component defintion start token.
/// Range of the component definition start token.
/// This can be used for diagnostics in the absence of the names.
pub(crate) start_range: TextRange,
/// Name of the component.
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ fn run_plugin_test(input: &'static str, _: &str, _: &str, _: &str) {
};

// Enable at least 1 rule so that PhaseRunner will be called
// which is necessary to parse and store supression comments
// which is necessary to parse and store suppression comments
let rule_filter = RuleFilter::Rule("nursery", "noCommonJs");
let filter = AnalysisFilter {
enabled_rules: Some(slice::from_ref(&rule_filter)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div alt={function(e) {} } />
<img alt={() => void 0} />
<Img />
<Component>test</Compoennt>
<Component>test</Component>
<img alt={alt || "Alt text" } />
<img alt={photo.caption} />;
<img alt={bar()} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ snapshot_kind: text
<div alt={function(e) {} } />
<img alt={() => void 0} />
<Img />
<Component>test</Compoennt>
<Component>test</Component>
<img alt={alt || "Alt text" } />
<img alt={photo.caption} />;
<img alt={bar()} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: assigments.jsx
expression: assignments.jsx
---
# Input
```jsx
Expand All @@ -12,7 +12,7 @@ err = <React.Fragment>Error</React.Fragment>;

# Diagnostics
```
assigments.jsx:1:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
assignments.jsx:1:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i This fragment is unnecessary.

Expand All @@ -34,7 +34,7 @@ assigments.jsx:1:7 lint/complexity/noUselessFragments FIXABLE ━━━━━
```

```
assigments.jsx:2:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
assignments.jsx:2:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i This fragment is unnecessary.

Expand All @@ -58,7 +58,7 @@ assigments.jsx:2:7 lint/complexity/noUselessFragments FIXABLE ━━━━━
```

```
assigments.jsx:3:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
assignments.jsx:3:7 lint/complexity/noUselessFragments FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i This fragment is unnecessary.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ invalid.js:1:1 lint/complexity/noUselessStringRaw ━━━━━━━━━━
2 │ String.raw`abc`;
3 │ String.raw`a ${x}`;

i Remove the String.raw call beacause it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.
i Remove the String.raw call because it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.


```
Expand All @@ -35,7 +35,7 @@ invalid.js:2:1 lint/complexity/noUselessStringRaw ━━━━━━━━━━
│ ^^^^^^^^^^^^^^^
3 │ String.raw`a ${x}`;

i Remove the String.raw call beacause it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.
i Remove the String.raw call because it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.


```
Expand All @@ -50,7 +50,7 @@ invalid.js:3:1 lint/complexity/noUselessStringRaw ━━━━━━━━━━
> 3 │ String.raw`a ${x}`;
│ ^^^^^^^^^^^^^^^^^^

i Remove the String.raw call beacause it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.
i Remove the String.raw call because it's useless here, String.raw can deal with string which contains escape sequence like \n, \t, \r, \\, \", \'.


```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: overriden.js
expression: overridden.js
snapshot_kind: text
---
# Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ExtendTypeAssertion extends (A as A) {
}
}

class ExtendStatisfiesExpression extends (A satisfies A) {
class ExtendSatisfiesExpression extends (A satisfies A) {
constructor() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ExtendTypeAssertion extends (A as A) {
}
}

class ExtendStatisfiesExpression extends (A satisfies A) {
class ExtendSatisfiesExpression extends (A satisfies A) {
constructor() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: invalidNamesapceReference.ts
expression: invalidNamespaceReference.ts
---
# Input
```ts
Expand All @@ -13,7 +13,7 @@ export type T2 = Ns2; // This doesn't reference the import namespace `Ns1`

# Diagnostics
```
invalidNamesapceReference.ts:2:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidNamespaceReference.ts:2:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━

× The Ns1 variable is undeclared.

Expand All @@ -30,7 +30,7 @@ invalidNamesapceReference.ts:2:18 lint/correctness/noUndeclaredVariables ━━
```

```
invalidNamesapceReference.ts:5:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidNamespaceReference.ts:5:18 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━

× The Ns2 variable is undeclared.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ function SuppressionComments1() {
function SuppressionComments2() {
beforeReturn();
return;
// biome-ignore lint/correctness/noUnreachable: supress warning
// biome-ignore lint/correctness/noUnreachable: suppress warning
afterReturn();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function SuppressionComments1() {
function SuppressionComments2() {
beforeReturn();
return;
// biome-ignore lint/correctness/noUnreachable: supress warning
// biome-ignore lint/correctness/noUnreachable: suppress warning
afterReturn();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: inavlidSelfWrite.js
expression: invalidSelfWrite.js
---
# Input
```js
Expand All @@ -21,7 +21,7 @@ for(f = 0; cond; f++) {}

# Diagnostics
```
inavlidSelfWrite.js:1:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidSelfWrite.js:1:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This variable a is unused.

Expand All @@ -48,7 +48,7 @@ inavlidSelfWrite.js:1:5 lint/correctness/noUnusedVariables FIXABLE ━━━
```

```
inavlidSelfWrite.js:7:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidSelfWrite.js:7:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This variable d is unused.

Expand All @@ -75,7 +75,7 @@ inavlidSelfWrite.js:7:5 lint/correctness/noUnusedVariables FIXABLE ━━━
```

```
inavlidSelfWrite.js:7:8 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidSelfWrite.js:7:8 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This variable e is unused.

Expand All @@ -102,7 +102,7 @@ inavlidSelfWrite.js:7:8 lint/correctness/noUnusedVariables FIXABLE ━━━
```

```
inavlidSelfWrite.js:10:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalidSelfWrite.js:10:5 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This variable f is unused.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: validNamesapceExportType.ts
expression: validNamespaceExportType.ts
---
# Input
```ts
Expand Down
Loading