Consolidate package checks into one Jest test (#57509)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57509

Simplify/unify various mechanisms for the monorepo's package invariants.

These checks were previously scattered:
- `private/monorepo-tests` package (manifest field checks)
- `.github/workflow-scripts/lint_files.sh` (`.npmignore` ban)
- `react-native/eslint-plugin-monorepo` (manifest field checks — duplicated)

This folds everything into `scripts/monorepo-tests/__tests__/check-packages-test.js`. A plain Jest test is the most extensible home for future checks.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D111471313

fbshipit-source-id: ea50abd8148d92e70605dd7f809654348e3c0080
This commit is contained in:
Alex Hunt authored and meta-codesync[bot] committed 2026-07-10 12:27:14 -07:00
1 parent c948b61c05
commit 0ed6c560da
11 files changed
+42 -301

No files matched your search

@@ -0,0 +1,42 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import {REPO_ROOT} from '../../shared/consts';
import {
getReactNativePackage,
getWorkspaceRoot,
} from '../../shared/monorepoUtils';
import {globSync} from 'tinyglobby';
describe('package manifests', () => {
test('the workspace root must not declare runtime dependencies', async () => {
const {packageJson} = await getWorkspaceRoot();
expect(packageJson).not.toHaveProperty('dependencies');
});
test('the react-native package must not declare devDependencies', async () => {
const {packageJson} = await getReactNativePackage();
expect(packageJson).not.toHaveProperty('devDependencies');
});
});
describe('package file structure', () => {
test('packages must not contain .npmignore files', () => {
// Publishing must be controlled via the package.json "files" field, which is
// easier to audit and does not silently expand what gets shipped to npm.
const npmignoreFiles = globSync('{packages,private}/**/.npmignore', {
cwd: REPO_ROOT,
dot: true,
ignore: ['**/node_modules/**'],
});
expect(npmignoreFiles).toEqual([]);
});
});