Align the no-deep-imports auto-fix map with the public API - #58536
Closed
rubennorte wants to merge 1 commit into
Closed
rubennorte wants to merge 1 commit into
rubennorte wants to merge 1 commit into
Conversation
Summary: 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 Differential Revision: D119678373
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D119678373. |
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 15, 2026
Summary: 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
|
This pull request has been merged in 29900fc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The auto-fix map behind
react-native/no-deep-importshad drifted from the exports declared inindex.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, andTouchable, 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/PlatformTypeskey and two type names,NativeMethodsandNativeMethodsMixin, that the root module does not export. The map is now generated fromindex.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 asexport * as Systrace, cannot be expressed by a fixer that only rewrites same-name specifiers.Names published behind an
unstable_orexperimental_prefix are excluded as well. They are genuine public exports, but rewriting a deep import ofViewNativeComponentintounstable_NativeViewquietly moves a call site onto an experimental API, and that is a choice the author should make rather than a lint fixer.InitializeCoreandRootTagTypesremain hand-written entries, since neither is derivable fromindex.js.flow: the first has no root export at all and is replaced wholesale by thereact-native/setup-enventry point, and the second re-exportsRootTag, which the root does export.Changelog:
[General][Fixed] - Align the
react-native/no-deep-importsauto-fix map with the package's public APIDifferential Revision: D119678373