logoESLint React
Rules

jsx-uses-react

Full Name in eslint-plugin-react-x

react-x/jsx-uses-react

Full Name in @eslint-react/eslint-plugin

@eslint-react/jsx-uses-react

Presets

  • core
  • recommended

Description

Marks React variables as used when JSX is used in the file.

If you are using the @jsx pragma this rule will mark the designated variable and not the React one.

This rule does nothing when using the New JSX Transform or if the no-unused-vars rule is not enabled.

Examples

Failing

import React from "react";
// nothing to do with React
/** @jsx Foo */
import React from "react";
// nothing to do with React
 
const Hello = <div>Hello</div>;

Passing

import React from "react";
 
const Hello = <div>Hello</div>;
/** @jsx Foo */
import Foo from "foo";
 
const Hello = <div>Hello</div>;

Implementation

On this page