Skip to content

Commit

Permalink
feat(linter): diagnostic on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven committed Dec 10, 2023
1 parent c3d9dde commit b960756
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_diagnostics::{
thiserror::Error,
};
use oxc_macros::declare_oxc_lint;
use oxc_span::{Atom, Span};
use oxc_span::{Atom, Span, GetSpan};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand Down Expand Up @@ -42,8 +42,8 @@ declare_oxc_lint!(
impl Rule for ReactInJsxScope {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
let node_span = match node.kind() {
AstKind::JSXOpeningElement(v) => v.span,
AstKind::JSXFragment(v) => v.span,
AstKind::JSXOpeningElement(v) => v.name.span(),
AstKind::JSXFragment(v) => v.opening_fragment.span,
_ => return,
};
let scope = ctx.scopes();
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_linter/src/snapshots/react_in_jsx_scope.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ expression: react_in_jsx_scope
eslint-plugin-react(react-in-jsx-scope): 'React' must be in scope when using JSX
╭─[react_in_jsx_scope.tsx:1:1]
1var App, a = <App />;
· ───────
· ───
╰────
help: When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.

eslint-plugin-react(react-in-jsx-scope): 'React' must be in scope when using JSX
╭─[react_in_jsx_scope.tsx:1:1]
1var a = <App />;
· ───────
· ───
╰────
help: When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.

eslint-plugin-react(react-in-jsx-scope): 'React' must be in scope when using JSX
╭─[react_in_jsx_scope.tsx:1:1]
1var a = <img />;
· ───────
· ───
╰────
help: When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.

eslint-plugin-react(react-in-jsx-scope): 'React' must be in scope when using JSX
╭─[react_in_jsx_scope.tsx:1:1]
1var a = <>fragment</>;
· ─────────────
· ──
╰────
help: When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.

eslint-plugin-react(react-in-jsx-scope): 'React' must be in scope when using JSX
╭─[react_in_jsx_scope.tsx:1:1]
1var Foo, a = <img />;
· ───────
· ───
╰────
help: When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.

Expand Down

0 comments on commit b960756

Please sign in to comment.