Files
react-native/private/eslint-plugin-monorepo/rules/no-react-node-imports.js
Tim Yung d17f7d0a29 RN: Private Package for Monorepo ESLint Rules (#51858)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51858

Creates a new private package for the ESLint rules that are defined in the `facebook/react-native` repository for linting the monorepo itself: `react-native/eslint-plugin-monorepo`

It resides in a new `private/` directory that will be used for all private packages. I plan to move private packages over from `packages/` and `tools/`.

This also eliminates the need for the `eslint-plugin-lint` dependency in open source.

Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D76088698

fbshipit-source-id: 697d5d91421cda4ef3f96d0497a96954cd047296
2025-06-09 20:30:32 -07:00

46 lines
1.0 KiB
JavaScript

/**
* 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.
*
* @format
* @noflow
*/
'use strict';
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow named Node imports from react',
},
messages: {
nodeImport:
'React.Node is React.ReactNode in TypeScript. To help us replace these correctly during type translation, prefer `import * as React` and using `React.Node`.',
},
schema: [],
},
create(context) {
return {
ImportDeclaration(node) {
if (node.source.value === 'react') {
node.specifiers.forEach(specifier => {
if (
specifier.type === 'ImportSpecifier' &&
specifier.imported.name === 'Node'
) {
context.report({
node: specifier,
messageId: 'nodeImport',
});
}
});
}
},
};
},
};