/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/eslint-plugin-specs/__tests__/react-native-modules-test.js
57 строк
1 KB
Tim Yung
RN: Add `@noflow` to ESLint & Babel Preset Files (#51778)
04 июн 2025, 22:03
04 июн 2025, 22:03
b344aec
Код
Авторство
О чём код?
/** * 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, });