Repository navigation
Commit 46d0041
Summary:
`react-native/eslint-plugin`'s `no-deep-imports` rule keeps a hard-coded allowlist of the subpaths that `react-native` intentionally exposes (`isSecondaryEntryPoint`). `react-native/package.json` is exposed by the `"exports"` map in `packages/react-native/package.json` (`"./package.json": "./package.json"`) but is missing from that list, so importing it is reported as a deprecated deep import:
```
'react-native/package.json' React Native deep imports are deprecated. Please use the top level import instead.
```
Reading `react-native/package.json` is the standard way for tooling and libraries to detect the installed React Native version, and there is no top level equivalent to migrate to, so the only way out today is an `eslint-disable`.
This adds `react-native/package.json` to `isSecondaryEntryPoint`, which brings the allowlist back in line with every non-wildcard entry of the `"exports"` map (`.`, `./asset-registry`, `./react-private-interface`, `./setup-env`, `./unstable-internals-do-not-use`, `./package.json`). `Libraries/*` and `src/*` deep imports are still reported exactly as before.
## Changelog:
[GENERAL] [FIXED] - Stop `no-deep-imports` from reporting `react-native/package.json`, which is a supported entry point
Pull Request resolved: #58824
Test Plan:
Added `import` and `require` cases for `react-native/package.json` to the `valid` list in `no-deep-imports-test.js`.
Before the fix (new tests only):
```
$ yarn jest packages/eslint-plugin-react-native/__tests__/no-deep-imports-test.js
✕ import {version} from 'react-native/package.json';
✕ require('react-native/package.json');
● ../no-deep-imports › valid › import {version} from 'react-native/package.json';
message: "'react-native/package.json' React Native deep imports are deprecated. Please use the top level import instead.",
```
After the fix:
```
$ yarn jest packages/eslint-plugin-react-native
PASS packages/eslint-plugin-react-native/__tests__/no-deep-imports-test.js
PASS packages/eslint-plugin-react-native/__tests__/platform-colors-test.js
Test Suites: 2 passed, 2 total
Tests: 42 passed, 42 total
```
`eslint` is clean on the changed files.
Reviewed By: christophpurrer
Differential Revision: D125659549
Pulled By: cortinico
fbshipit-source-id: c13b3895bbfb480166f548b704838e92ec3792c5
1 parent 0bd2cb1 commit 46d0041
2 files changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
0 commit comments