Skip to content
Closed
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/oxc_linter/src/fixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct FixResult<'a> {
pub messages: Vec<Message<'a>>,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Message<'a> {
pub error: OxcDiagnostic,
pub start: u32,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ use oxc_semantic::AstNode;
pub use crate::{
config::OxlintConfig,
context::LintContext,
fixer::{Fixer, Message},
options::{AllowWarnDeny, LintOptions},
rule::{RuleCategory, RuleMeta, RuleWithSeverity},
service::{LintService, LintServiceOptions},
};
use crate::{
config::{OxlintEnv, OxlintGlobals, OxlintSettings},
fixer::Fix,
fixer::{Fixer, Message},
rules::RuleEnum,
table::RuleTable,
};
Expand Down
16 changes: 7 additions & 9 deletions crates/oxc_linter/src/rules/oxc/only_used_in_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use oxc_ast::{
use oxc_diagnostics::OxcDiagnostic;

use oxc_macros::declare_oxc_lint;
use oxc_semantic::SymbolId;
use oxc_span::{GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};
Expand Down Expand Up @@ -73,7 +74,10 @@ impl Rule for OnlyUsedInRecursion {
return;
}

if is_function_maybe_reassigned(function_id, ctx) {
let Some(function_symbol_id) = function_id.symbol_id.get() else {
return;
};
if is_function_maybe_reassigned(function_symbol_id, ctx) {
return;
}

Expand Down Expand Up @@ -131,16 +135,10 @@ fn is_argument_only_used_in_recursion<'a>(
has_references && is_used_only_in_recursion
}

fn is_function_maybe_reassigned<'a>(
function_id: &'a BindingIdentifier,
ctx: &'a LintContext<'_>,
) -> bool {
fn is_function_maybe_reassigned(function_id: SymbolId, ctx: &LintContext<'_>) -> bool {
let mut is_maybe_reassigned = false;

for reference in ctx
.semantic()
.symbol_references(function_id.symbol_id.get().expect("`symbol_id` should be set"))
{
for reference in ctx.semantic().symbol_references(function_id) {
if let Some(AstKind::SimpleAssignmentTarget(_)) =
ctx.nodes().parent_kind(reference.node_id())
{
Expand Down
7 changes: 4 additions & 3 deletions tasks/coverage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ test = false

[dependencies]
oxc_allocator = { workspace = true }
oxc_parser = { workspace = true }
oxc_ast = { workspace = true, features = ["serialize"] }
oxc_codegen = { workspace = true }
oxc_diagnostics = { workspace = true }
oxc_semantic = { workspace = true }
oxc_linter = { workspace = true }
oxc_minifier = { workspace = true }
oxc_parser = { workspace = true }
oxc_prettier = { workspace = true }
oxc_semantic = { workspace = true }
oxc_sourcemap = { workspace = true }
oxc_span = { workspace = true }
oxc_tasks_common = { workspace = true }
oxc_sourcemap = { workspace = true }
oxc_transformer = { workspace = true }

serde = { workspace = true, features = ["derive"] }
Expand Down
28 changes: 28 additions & 0 deletions tasks/coverage/linter_babel.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
commit: 4bd1b2c2

linter_babel Summary:
AST Parsed : 2079/2099 (99.05%)
Positive Passed: 2077/2099 (98.95%)
Expect to Parse: "annex-b/enabled/3.1-sloppy-labeled-functions/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "annex-b/enabled/3.1-sloppy-labeled-functions-multiple-labels/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/categorized/label-kind-switch/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/categorized/labeled-block-statement-regex/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/uncategorised/257/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/uncategorised/258/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/uncategorised/319/input.js"
Parser panicked on second pass: Invalid characters after numberExpect to Parse: "core/uncategorised/323/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "core/uncategorised/327/input.js"
Parser panicked on second pass: TS1108: A 'return' statement can only be used within a function bodyExpect to Parse: "core/uncategorised/328/input.js"
Parser panicked on second pass: TS1108: A 'return' statement can only be used within a function bodyExpect to Parse: "es2015/let/let-block-with-newline/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "es2015/statements/label-valid-func-non-strict/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "es2015/statements/label-valid-var/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "es2015/uncategorised/34/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "esprima/es2015-arrow-function/migrated_0006/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "esprima/statement-labelled/migrated_0002/input.js"
Parser panicked on second pass: Unexpected tokenExpect to Parse: "typescript/arrow-function/generic-tsx-babel-7/input.ts"
Parser panicked on first pass: Expected `<` but found `EOF`Expect to Parse: "typescript/interface/get-set-properties/input.ts"
Parser panicked on first pass: Expected `(` but found `:`Expect to Parse: "typescript/regression/nested-extends-in-arrow-type-param/input.ts"
Parser panicked on first pass: Expected `,` but found `extends`Expect to Parse: "typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts"
Parser panicked on first pass: Expected `,` but found `extends`Expect to Parse: "typescript/types/const-type-parameters/input.ts"
Parser panicked on first pass: Unexpected tokenExpect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts"
Parser panicked on first pass: Unexpected token
3 changes: 3 additions & 0 deletions tasks/coverage/linter_misc.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linter_misc Summary:
AST Parsed : 18/18 (100.00%)
Positive Passed: 18/18 (100.00%)
Loading