diff --git a/.eslintrc.js b/.eslintrc.js index 11ef162364d..55a02ed93d3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,6 +27,7 @@ module.exports = { files: ['*.js', '*.js.flow', '*.jsx'], parser: 'hermes-eslint', rules: { + 'no-void': 0, // These rules are not required with hermes-eslint 'ft-flow/define-flow-type': 0, 'ft-flow/use-flow-type': 0, diff --git a/packages/community-cli-plugin/src/commands/start/OpenDebuggerKeyboardHandler.js b/packages/community-cli-plugin/src/commands/start/OpenDebuggerKeyboardHandler.js index 259bd35eeb7..310ae49c297 100644 --- a/packages/community-cli-plugin/src/commands/start/OpenDebuggerKeyboardHandler.js +++ b/packages/community-cli-plugin/src/commands/start/OpenDebuggerKeyboardHandler.js @@ -92,7 +92,6 @@ export default class OpenDebuggerKeyboardHandler { this.#clearTerminalMenu(); } else if (targets.length === 1) { const target = targets[0]; - // eslint-disable-next-line no-void void this.#tryOpenDebuggerForTarget(target); } else { this.#targetsShownForSelection = targets; @@ -135,7 +134,6 @@ export default class OpenDebuggerKeyboardHandler { targetIndex < this.#targetsShownForSelection.length ) { const target = this.#targetsShownForSelection[targetIndex]; - // eslint-disable-next-line no-void void this.#tryOpenDebuggerForTarget(target); return true; } diff --git a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js index 30e9a0cf731..f6a2b38f715 100644 --- a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js +++ b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js @@ -95,7 +95,6 @@ export default function attachKeyHandlers({ messageSocket.broadcast('devMenu', null); break; case 'j': - // eslint-disable-next-line no-void void openDebuggerKeyboardHandler.handleOpenDebugger(); break; case CTRL_C: diff --git a/packages/dev-middleware/src/__tests__/InspectorDeviceUtils.js b/packages/dev-middleware/src/__tests__/InspectorDeviceUtils.js index ba40765285b..66653bf81e1 100644 --- a/packages/dev-middleware/src/__tests__/InspectorDeviceUtils.js +++ b/packages/dev-middleware/src/__tests__/InspectorDeviceUtils.js @@ -148,7 +148,6 @@ export class DeviceMock extends DeviceAgent { return; } if (maybePayload instanceof Promise) { - // eslint-disable-next-line no-void void maybePayload.then(payload => { if (!payload) { return; diff --git a/packages/dev-middleware/src/utils/DefaultBrowserLauncher.js b/packages/dev-middleware/src/utils/DefaultBrowserLauncher.js index e9e87f966fb..bfcf0cc75cc 100644 --- a/packages/dev-middleware/src/utils/DefaultBrowserLauncher.js +++ b/packages/dev-middleware/src/utils/DefaultBrowserLauncher.js @@ -8,8 +8,6 @@ * @format */ -import type {BrowserLauncher} from '../types/BrowserLauncher'; - const {spawn} = require('child_process'); const ChromeLauncher = require('chrome-launcher'); const {Launcher: EdgeLauncher} = require('chromium-edge-launcher'); diff --git a/packages/polyfills/console.js b/packages/polyfills/console.js index 145542a6dd2..89039ca76a5 100644 --- a/packages/polyfills/console.js +++ b/packages/polyfills/console.js @@ -11,7 +11,7 @@ 'use client'; -/* eslint-disable no-shadow, eqeqeq, no-unused-vars, no-void, no-control-regex */ +/* eslint-disable no-shadow, eqeqeq, no-unused-vars, no-control-regex */ /** * This pipes all of our console logging functions to native logging so that diff --git a/packages/react-native/scripts/ios-prebuild.js b/packages/react-native/scripts/ios-prebuild.js index efa8689d2e1..bf5c502fca1 100644 --- a/packages/react-native/scripts/ios-prebuild.js +++ b/packages/react-native/scripts/ios-prebuild.js @@ -177,6 +177,5 @@ async function main() { } if (require.main === module) { - // eslint-disable-next-line no-void void main(); } diff --git a/packages/rn-tester/IntegrationTests/LoggingTestModule.js b/packages/rn-tester/IntegrationTests/LoggingTestModule.js index 44132cf229d..9b55170d85c 100644 --- a/packages/rn-tester/IntegrationTests/LoggingTestModule.js +++ b/packages/rn-tester/IntegrationTests/LoggingTestModule.js @@ -4,38 +4,34 @@ * 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 */ -'use strict'; - -const invariant = require('invariant'); -const BatchedBridge = - require('react-native/Libraries/BatchedBridge/BatchedBridge').default; +import invariant from 'invariant'; +import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge'; const LoggingTestModule = { - logToConsole: function (str) { - console.log(str); + logToConsole(message: string): void { + console.log(message); }, - logToConsoleAfterWait: function (str, timeout_ms) { + logToConsoleAfterWait(message: string, delay: number): void { setTimeout(function () { - console.log(str); - }, timeout_ms); + console.log(message); + }, delay); }, - warning: function (str) { - console.warn(str); + warning(message: string): void { + console.warn(message); }, - invariant: function (str) { - invariant(false, str); + invariant(message: string): void { + invariant(false, message); }, - logErrorToConsole: function (str) { - console.error(str); + logErrorToConsole(message: string): void { + console.error(message); }, - throwError: function (str) { - throw new Error(str); + throwError(message: string): void { + throw new Error(message); }, }; BatchedBridge.registerCallableModule('LoggingTestModule', LoggingTestModule); - -module.exports = LoggingTestModule; diff --git a/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js b/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js index 2121f025ff2..3d2794d08ec 100644 --- a/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js +++ b/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js @@ -4,14 +4,6 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict * @format */ - -'use strict'; - -// eslint-disable-next-line no-unused-vars -const __fbBatchedBridge = { - flushedQueue: function () { - return null; - }, -}; diff --git a/packages/rn-tester/js/examples/BoxShadow/BoxShadowExample.js b/packages/rn-tester/js/examples/BoxShadow/BoxShadowExample.js index c231ef85711..a6d66167b06 100644 --- a/packages/rn-tester/js/examples/BoxShadow/BoxShadowExample.js +++ b/packages/rn-tester/js/examples/BoxShadow/BoxShadowExample.js @@ -4,13 +4,12 @@ * 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 */ -'use strict'; - -const React = require('react'); -const {Image, StyleSheet, View} = require('react-native'); +import * as React from 'react'; +import {Image, StyleSheet, View} from 'react-native'; const styles = StyleSheet.create({ box: { @@ -79,28 +78,28 @@ exports.examples = [ { title: 'Basic shadow', description: 'shadowOpacity: 0.5, shadowOffset: {2, 2}', - render() { + render(): React.Node { return ; }, }, { title: 'Colored shadow', description: "shadowColor: 'red', shadowRadius: 0", - render() { + render(): React.Node { return ; }, }, { title: 'Shaped shadow', description: 'borderRadius: 50', - render() { + render(): React.Node { return ; }, }, { title: 'Image shadow', description: 'Image shadows are derived exactly from the pixels.', - render() { + render(): React.Node { return ( @@ -125,10 +124,10 @@ exports.examples = [ { title: 'Basic elevation', description: 'elevation: 1, 3, 6', - platform: 'android', - render() { + platform: 'android' as const, + render(): React.Node { return ( - + @@ -139,10 +138,10 @@ exports.examples = [ { title: 'Fractional elevation', description: 'elevation: 0.1, 0.5, 1.5', - platform: 'android', - render() { + platform: 'android' as const, + render(): React.Node { return ( - + @@ -153,10 +152,10 @@ exports.examples = [ { title: 'Colored shadow', description: "shadowColor: 'red', 'blue', '#00FF0080'", - platform: 'android', - render() { + platform: 'android' as const, + render(): React.Node { return ( - + @@ -167,10 +166,10 @@ exports.examples = [ { title: 'Shaped shadow', description: 'borderRadius: 50', - platform: 'android', - render() { + platform: 'android' as const, + render(): React.Node { return ( - + @@ -181,10 +180,10 @@ exports.examples = [ { title: 'Borders', description: 'borderWidth: 5', - platform: 'android', - render() { + platform: 'android' as const, + render(): React.Node { return ( - + diff --git a/packages/rn-tester/js/examples/Cursor/CursorExample.js b/packages/rn-tester/js/examples/Cursor/CursorExample.js index 77936112305..231f3a5338c 100644 --- a/packages/rn-tester/js/examples/Cursor/CursorExample.js +++ b/packages/rn-tester/js/examples/Cursor/CursorExample.js @@ -4,13 +4,12 @@ * 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 */ -'use strict'; - -const React = require('react'); -const {StyleSheet, Text, View} = require('react-native'); +import * as React from 'react'; +import {StyleSheet, Text, View} from 'react-native'; const styles = StyleSheet.create({ invisibleBox: { @@ -52,7 +51,7 @@ const styles = StyleSheet.create({ }, }); -function CursorExampleAuto() { +function CursorExampleAuto(): React.Node { return ( @@ -65,7 +64,7 @@ function CursorExampleAuto() { ); } -function CursorExamplePointer() { +function CursorExamplePointer(): React.Node { return ( @@ -78,20 +77,7 @@ function CursorExamplePointer() { ); } -function CursorExamplePointer() { - return ( - - - - - - - - - ); -} - -function CursorExampleViewFlattening() { +function CursorExampleViewFlattening(): React.Node { return ( diff --git a/packages/rn-tester/js/examples/Linking/LinkingExample.js b/packages/rn-tester/js/examples/Linking/LinkingExample.js index d200ad1ac02..57df6c12eed 100644 --- a/packages/rn-tester/js/examples/Linking/LinkingExample.js +++ b/packages/rn-tester/js/examples/Linking/LinkingExample.js @@ -4,11 +4,10 @@ * 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 */ -'use strict'; - import RNTesterBlock from '../../components/RNTesterBlock'; import RNTesterText from '../../components/RNTesterText'; import React from 'react'; @@ -23,28 +22,27 @@ import { View, } from 'react-native'; -type Props = $ReadOnly<{ - url?: ?string, -}>; - -class OpenURLButton extends React.Component { - handleClick = () => { - Linking.canOpenURL(this.props.url).then(supported => { - if (supported) { - Linking.openURL(this.props.url); - } else { - console.log( - `Don't know how to open URI: ${ - this.props.url - }, ensure you have an app installed that handles the "${ - this.props.url.split(':')?.[0] - }" scheme`, - ); - } - }); +class OpenURLButton extends React.Component< + $ReadOnly<{ + url: string, + }>, +> { + handleClick = async () => { + const supported = await Linking.canOpenURL(this.props.url); + if (supported) { + void Linking.openURL(this.props.url); + } else { + console.log( + `Don't know how to open URI: ${ + this.props.url + }, ensure you have an app installed that handles the "${ + this.props.url.split(':')?.[0] + }" scheme`, + ); + } }; - render() { + render(): React.Node { return ( @@ -55,17 +53,27 @@ class OpenURLButton extends React.Component { } } -class OpenSettingsExample extends React.Component { - openSettings() { - Linking.openSettings(); - } +class OpenSettingsExample extends React.Component<$ReadOnly<{}>> { + openSettings = () => { + void Linking.openSettings(); + }; - render() { + render(): React.Node { return