-
-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter/react): add the
rules_of_hooks
rule.
This one sounds like something straight out of `Mortal Kombat`!
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use oxc_diagnostics::{ | ||
miette::{self, Diagnostic}, | ||
thiserror::Error, | ||
}; | ||
use oxc_macros::declare_oxc_lint; | ||
use oxc_span::Span; | ||
|
||
use crate::{context::LintContext, rule::Rule, AstNode}; | ||
|
||
#[derive(Debug, Error, Diagnostic)] | ||
#[error("eslint-plugin-react-hooks(rules-of-hooks): TODO")] | ||
#[diagnostic(severity(warning), help("TODO"))] | ||
struct RulesOfHooksDiagnostic(#[label] pub Span); | ||
|
||
#[derive(Debug, Default, Clone)] | ||
pub struct RulesOfHooks; | ||
|
||
declare_oxc_lint!( | ||
/// ### What it does | ||
/// | ||
/// TODO | ||
RulesOfHooks, | ||
correctness | ||
); | ||
|
||
impl Rule for RulesOfHooks { | ||
fn run<'a>(&self, _: &AstNode<'a>, _: &LintContext<'a>) {} | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
use crate::tester::Tester; | ||
|
||
let pass = vec![("<App />;", None)]; | ||
|
||
let fail = vec![]; | ||
|
||
Tester::new(RulesOfHooks::NAME, pass, fail).test_and_snapshot(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: crates/oxc_linter/src/tester.rs | ||
expression: rules_of_hooks | ||
--- | ||
|