logoESLint React

is-from-react

Reports all identifiers initialized from React in JSON format. Useful for debugging. This rule should only be used for debugging purposes; otherwise, leave it off.

Full Name in eslint-plugin-react-debug

react-debug/is-from-react

Features

🐞

Rule Details

This rule reports all identifiers initialized from React in JSON format. It tracks named imports, default imports, namespace accesses, and chained member accesses originating from the configured React importSource.

Examples

Named imports from React

// This rule reports named imports that originate from React.
import { useState } from "react";
//       ^^^^^^^^
//       - {"name":"useState","importSource":"react"}

Default import and namespace access

// This rule reports the default React import and member accesses.
import React from "react";
//     ^^^^^
//     - {"name":"React","importSource":"react"}

const Children = React.Children;
//    ^^^^^^^^   ^^^^^ ^^^^^^^^
//    |          |     - {"name":"Children","importSource":"react"}
//    |          - {"name":"React","importSource":"react"}
//    - {"name":"Children","importSource":"react"}

Chained member access from React imports

// This rule reports identifiers derived from React through chained access.
import { Children } from "react";
//       ^^^^^^^^
//       - {"name":"Children","importSource":"react"}

const toArray = Children.toArray;
//    ^^^^^^^   ^^^^^^^^ ^^^^^^^
//    |         |        - {"name":"toArray","importSource":"react"}
//    |         - {"name":"Children","importSource":"react"}
//    - {"name":"toArray","importSource":"react"}

Custom React import source

When settings["react-x"].importSource is set to "@pika/react":

// This rule respects the custom importSource setting.
import { useState } from "@pika/react";
//       ^^^^^^^^
//       - {"name":"useState","importSource":"@pika/react"}
import React from "@pika/react";
//     ^^^^^
//     - {"name":"React","importSource":"@pika/react"}

const Children = React.Children;
//    ^^^^^^^^   ^^^^^ ^^^^^^^^
//    |          |     - {"name":"Children","importSource":"@pika/react"}
//    |          - {"name":"React","importSource":"@pika/react"}
//    - {"name":"Children","importSource":"@pika/react"}
import { Children } from "@pika/react";
//       ^^^^^^^^
//       - {"name":"Children","importSource":"@pika/react"}

const toArray = Children.toArray;
//    ^^^^^^^   ^^^^^^^^ ^^^^^^^
//    |         |        - {"name":"toArray","importSource":"@pika/react"}
//    |         - {"name":"Children","importSource":"@pika/react"}
//    - {"name":"toArray","importSource":"@pika/react"}

Resources


See Also

On this page