Skip to content

Commit 25ecbfe

Browse files
committed
fix(linter): remove use of FrameworkFlags::React to decide whether rules should run (#11383)
As mentioned in the PR above this in the stack, we never populate this value, so rules relying on framework flags that aren't the `Jest`/`Vitest` just don't work.
1 parent 0d240e4 commit 25ecbfe

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

crates/oxc_linter/src/rules/react/forward_ref_uses_ref.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::{ContextHost, FrameworkFlags};
21
use oxc_ast::{
32
AstKind,
43
ast::{CallExpression, Expression},
@@ -95,15 +94,10 @@ impl Rule for ForwardRefUsesRef {
9594

9695
check_forward_ref_inner(first_arg_as_exp, call_expr, ctx);
9796
}
98-
99-
fn should_run(&self, ctx: &ContextHost) -> bool {
100-
ctx.frameworks().contains(FrameworkFlags::React)
101-
}
10297
}
10398

10499
#[test]
105100
fn test() {
106-
use crate::LintOptions;
107101
use crate::tester::Tester;
108102

109103
let pass = vec![
@@ -206,10 +200,6 @@ fn test() {
206200
];
207201

208202
Tester::new(ForwardRefUsesRef::NAME, ForwardRefUsesRef::PLUGIN, pass, fail)
209-
.with_lint_options(LintOptions {
210-
framework_hints: FrameworkFlags::React,
211-
..LintOptions::default()
212-
})
213203
.expect_fix(fix)
214204
.test_and_snapshot();
215205
}

crates/oxc_linter/src/rules/react/no_children_prop.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ use oxc_diagnostics::OxcDiagnostic;
66
use oxc_macros::declare_oxc_lint;
77
use oxc_span::{GetSpan, Span};
88

9-
use crate::{
10-
AstNode, FrameworkFlags,
11-
context::{ContextHost, LintContext},
12-
rule::Rule,
13-
utils::is_create_element_call,
14-
};
9+
use crate::{AstNode, context::LintContext, rule::Rule, utils::is_create_element_call};
1510

1611
fn no_children_prop_diagnostic(span: Span) -> OxcDiagnostic {
1712
OxcDiagnostic::warn("Avoid passing children using a prop.")
@@ -93,17 +88,10 @@ impl Rule for NoChildrenProp {
9388
_ => {}
9489
}
9590
}
96-
97-
fn should_run(&self, ctx: &ContextHost) -> bool {
98-
// Only is JSX Context
99-
// Only when React is installed, others frameworks can use JSX too
100-
ctx.source_type().is_jsx() && ctx.frameworks().contains(FrameworkFlags::React)
101-
}
10291
}
10392

10493
#[test]
10594
fn test() {
106-
use crate::LintOptions;
10795
use crate::tester::Tester;
10896

10997
#[rustfmt::skip]
@@ -167,10 +155,5 @@ fn test() {
167155
(r#"React.createElement(MyComponent, {...props, children: "Children"})"#, None),
168156
];
169157

170-
Tester::new(NoChildrenProp::NAME, NoChildrenProp::PLUGIN, pass, fail)
171-
.with_lint_options(LintOptions {
172-
framework_hints: FrameworkFlags::React,
173-
..LintOptions::default()
174-
})
175-
.test_and_snapshot();
158+
Tester::new(NoChildrenProp::NAME, NoChildrenProp::PLUGIN, pass, fail).test_and_snapshot();
176159
}

crates/oxc_linter/src/tester.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,6 @@ impl Tester {
319319
self
320320
}
321321

322-
pub fn with_lint_options(mut self, lint_options: LintOptions) -> Self {
323-
self.lint_options = lint_options;
324-
self
325-
}
326-
327322
/// Add cases that should fix problems found in the source code.
328323
///
329324
/// These cases will fail if no fixes are produced or if the fixed source

0 commit comments

Comments
 (0)