noReactNativeDeepImports (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.4.13 - Diagnostic Category:
lint/suspicious/noReactNativeDeepImports - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
@react-native/no-deep-imports
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noReactNativeDeepImports": "error" } } }}Description
Section titled “Description”Disallow deep imports from the react-native package.
Deep imports reach into React Native’s internal file structure, which is not part of the public API. Internal paths can change between versions without warning, breaking code that depends on them.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import View from "react-native/Libraries/Components/View/View";code-block.js:1:18 lint/suspicious/noReactNativeDeepImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Deep imports from react-native are not allowed.
> 1 │ import View from "react-native/Libraries/Components/View/View";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ React Native's internal file structure is not part of the public API and may change between versions without warning.
ℹ Import from the top-level react-native entry point instead.
const Platform = require("react-native/Libraries/Utilities/Platform");code-block.js:1:26 lint/suspicious/noReactNativeDeepImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Deep imports from react-native are not allowed.
> 1 │ const Platform = require("react-native/Libraries/Utilities/Platform");
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ React Native's internal file structure is not part of the public API and may change between versions without warning.
ℹ Import from the top-level react-native entry point instead.
const View = require("react-native/Libraries/Components/View/View");code-block.js:1:22 lint/suspicious/noReactNativeDeepImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Deep imports from react-native are not allowed.
> 1 │ const View = require("react-native/Libraries/Components/View/View");
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ React Native's internal file structure is not part of the public API and may change between versions without warning.
ℹ Import from the top-level react-native entry point instead.
import("react-native/Libraries/Utilities/Platform");code-block.js:1:8 lint/suspicious/noReactNativeDeepImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Deep imports from react-native are not allowed.
> 1 │ import("react-native/Libraries/Utilities/Platform");
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ React Native's internal file structure is not part of the public API and may change between versions without warning.
ℹ Import from the top-level react-native entry point instead.
import { View } from "react-native";const { Platform } = require("react-native");Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.