Skip to content

Commit 29900fc

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Align the no-deep-imports auto-fix map with the public API (#58536)
Summary: Pull Request resolved: #58536 The auto-fix map behind `react-native/no-deep-imports` had drifted from the exports declared in `index.js.flow`, so the rule offered fixes that do not type-check and missed fixes it could have offered. It was missing 28 modules, among them EventEmitter, CoreEventTypes, PlatformTypes, RendererProxy, usePressability, AssetRegistry and the virtual collection components. It still listed `InteractionManager`, which has been removed from the public API and whose root getter now throws in development, and `Touchable`, which is a value-only runtime re-export absent from the published types — auto-fixing either one produces broken code. It also carried a malformed `./Libraries/Utilities/PlatformTypes` key and two type names, `NativeMethods` and `NativeMethodsMixin`, that the root module does not export. The map is now generated from `index.js.flow`, so it tracks the real surface. Two groups of exports stay out of the map on purpose. The rule keeps reporting those deep imports; it simply does not offer a fix for them. Renamed re-exports such as `NativeText as unstable_NativeText`, and namespace re-exports such as `export * as Systrace`, cannot be expressed by a fixer that only rewrites same-name specifiers. Names published behind an `unstable_` or `experimental_` prefix are excluded as well. They are genuine public exports, but rewriting a deep import of `ViewNativeComponent` into `unstable_NativeView` quietly moves a call site onto an experimental API, and that is a choice the author should make rather than a lint fixer. `InitializeCore` and `RootTagTypes` remain hand-written entries, since neither is derivable from `index.js.flow`: the first has no root export at all and is replaced wholesale by the `react-native/setup-env` entry point, and the second re-exports `RootTag`, which the root does export. Changelog: [General][Fixed] - Align the `react-native/no-deep-imports` auto-fix map with the package's public API Reviewed By: javache Differential Revision: D119678373 fbshipit-source-id: c31bdbc5d6dd78dde52bd619fb54ff552e0763c9
1 parent 92564f3 commit 29900fc

2 files changed

Lines changed: 397 additions & 241 deletions

File tree

packages/eslint-plugin-react-native/no-deep-imports.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ module.exports = {
202202
return (
203203
source.value === 'react-native/asset-registry' ||
204204
source.value === 'react-native/react-private-interface' ||
205-
source.value === 'react-native/setup-env'
205+
source.value === 'react-native/setup-env' ||
206+
source.value === 'react-native/unstable-internals-do-not-use'
206207
);
207208
}
208209

0 commit comments

Comments
 (0)