mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b344aec2ae
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51778 Adds `noflow` to a bunch of ESLint and Babel files that are expected to be evaluated using Node.js without Babel. Additioanlly, these files tend to depend on ESLint and Babel type definitions that are not currently readily available. In the future, these files could be migrated to use `flow strict-local` or `flow strict` using comment syntax for type annotations. But for now, adding `noflow` makes it explicit that these are known to not be typechecked. Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D75883642 fbshipit-source-id: 54236d123ca8773de42bce81189dfb5c0671563e
58 lines
1.3 KiB
JavaScript
58 lines
1.3 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';
|
|
|
|
const rule = require('../react-native-modules');
|
|
const ESLintTester = require('./eslint-tester.js');
|
|
|
|
const NATIVE_MODULES_DIR = __dirname;
|
|
|
|
const eslintTester = new ESLintTester();
|
|
|
|
const VALID_SPECS = [
|
|
{
|
|
code: `
|
|
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
|
import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes';
|
|
|
|
export interface Spec extends TurboModule {
|
|
func1(a: string): UnsafeObject,
|
|
}
|
|
export default TurboModuleRegistry.get<Spec>('XYZ');
|
|
`,
|
|
filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`,
|
|
},
|
|
];
|
|
|
|
const INVALID_SPECS = [
|
|
// Untyped NativeModule require
|
|
{
|
|
code: `
|
|
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
|
export interface Spec extends TurboModule {
|
|
func1(a: string): {||},
|
|
}
|
|
export default TurboModuleRegistry.get<Spec>('XYZ');
|
|
`,
|
|
filename: `${NATIVE_MODULES_DIR}/XYZ.js`,
|
|
errors: [
|
|
{
|
|
message: rule.errors.misnamedHasteModule('XYZ'),
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
eslintTester.run('../react-native-modules', rule, {
|
|
valid: VALID_SPECS,
|
|
invalid: INVALID_SPECS,
|
|
});
|