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 ;
}
}
-const SendIntentButton = ({action, extras}: Props) => {
+const SendIntentButton = ({
+ action,
+ extras,
+}: $ReadOnly<{
+ action: string,
+ extras?: Array<{
+ key: string,
+ value: string | number | boolean,
+ ...
+ }>,
+}>) => {
const [isOpeningIntent, setIsOpeningIntent] = useState(false);
const handleIntent = async () => {
@@ -90,8 +98,8 @@ const SendIntentButton = ({action, extras}: Props) => {
);
};
-class IntentAndroidExample extends React.Component {
- render() {
+class IntentAndroidExample extends React.Component<$ReadOnly<{}>> {
+ render(): React.Node {
return (
@@ -102,7 +110,7 @@ class IntentAndroidExample extends React.Component {
- {Platform.OS === 'android' && (
+ {Platform.OS === 'android' ? (
@@ -118,7 +126,7 @@ class IntentAndroidExample extends React.Component {
]}
/>
- )}
+ ) : null}
);
}
diff --git a/packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.js b/packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.js
index a67aa00df2b..d9301a46b3d 100644
--- a/packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.js
+++ b/packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.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 RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {
@@ -19,6 +18,11 @@ import {
View,
} from 'react-native';
+type Data = $ReadOnly<{
+ clicks: number,
+ text: string,
+}>;
+
const styles = StyleSheet.create({
row: {
borderColor: 'grey',
@@ -36,12 +40,17 @@ const styles = StyleSheet.create({
},
});
-class Row extends React.Component {
+class Row extends React.Component<
+ $ReadOnly<{
+ data: Data,
+ onClick: Data => void,
+ }>,
+> {
_onClick = () => {
this.props.onClick(this.props.data);
};
- render() {
+ render(): React.Node {
return (
@@ -54,11 +63,20 @@ class Row extends React.Component {
}
}
-class RefreshControlExample extends React.Component {
- state = {
+type RefreshControlExampleState = $ReadOnly<{
+ isRefreshing: boolean,
+ loaded: number,
+ rowData: $ReadOnlyArray,
+}>;
+
+class RefreshControlExample extends React.Component<
+ $ReadOnly<{}>,
+ RefreshControlExampleState,
+> {
+ state: RefreshControlExampleState = {
isRefreshing: false,
loaded: 0,
- rowData: Array.from(new Array(20)).map((val, i) => ({
+ rowData: Array.from(new Array(20)).map((val, i) => ({
text: 'Initial row ' + i,
clicks: 0,
})),
@@ -68,14 +86,21 @@ class RefreshControlExample extends React.Component {
this._onRefresh();
}
- _onClick = row => {
- row.clicks++;
- this.setState({
- rowData: this.state.rowData,
+ _onClick = (row: Data) => {
+ this.setState(prevState => {
+ const index = prevState.rowData.indexOf(row);
+ return index < 0
+ ? null
+ : {
+ rowData: [...prevState.rowData].splice(index, 1, {
+ ...row,
+ clicks: row.clicks + 1,
+ }),
+ };
});
};
- render() {
+ render(): React.Node {
const rows = this.state.rowData.map((row, ii) => {
return
;
});
@@ -102,7 +127,7 @@ class RefreshControlExample extends React.Component {
this.setState({isRefreshing: true});
setTimeout(() => {
// prepend 10 items
- const rowData = Array.from(new Array(10))
+ const rowData = Array.from(new Array(10))
.map((val, i) => ({
text: 'Loaded row ' + (+this.state.loaded + i),
clicks: 0,
diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewIndicatorInsetsIOSExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewIndicatorInsetsIOSExample.js
index cdfbbb73361..3dec167843d 100644
--- a/packages/rn-tester/js/examples/ScrollView/ScrollViewIndicatorInsetsIOSExample.js
+++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewIndicatorInsetsIOSExample.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 * as React from 'react';
import {useState} from 'react';
import {
@@ -22,7 +21,7 @@ import {
useWindowDimensions,
} from 'react-native';
-export function ScrollViewIndicatorInsetsExample() {
+function ScrollViewIndicatorInsetsExample(): React.Node {
const [
automaticallyAdjustsScrollIndicatorInsets,
setAutomaticallyAdjustsScrollIndicatorInsets,
@@ -73,7 +72,7 @@ export function ScrollViewIndicatorInsetsExample() {
automaticallyAdjustsScrollIndicatorInsets
{' '}
- is {automaticallyAdjustsScrollIndicatorInsets + ''}
+ is {String(automaticallyAdjustsScrollIndicatorInsets)}
diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewKeyboardInsetsIOSExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewKeyboardInsetsIOSExample.js
index 276da99e475..28ddbd77867 100644
--- a/packages/rn-tester/js/examples/ScrollView/ScrollViewKeyboardInsetsIOSExample.js
+++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewKeyboardInsetsIOSExample.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 * as React from 'react';
import {useState} from 'react';
import {
@@ -21,7 +20,7 @@ import {
View,
} from 'react-native';
-export function ScrollViewKeyboardInsetsExample() {
+function ScrollViewKeyboardInsetsExample(): React.Node {
const [
automaticallyAdjustKeyboardInsets,
setAutomaticallyAdjustKeyboardInsets,
@@ -34,11 +33,14 @@ export function ScrollViewKeyboardInsetsExample() {
style: heightRestricted && styles.scrollViewHeightRestricted,
contentContainerStyle: styles.scrollViewContent,
automaticallyAdjustKeyboardInsets: automaticallyAdjustKeyboardInsets,
- keyboardDismissMode: 'interactive',
+ keyboardDismissMode: 'interactive' as const,
};
const data = [...Array(20).keys()];
- const renderItem = ({item, index}) => {
+ const renderItem = ({
+ item,
+ index,
+ }: $ReadOnly<{item: number, index: number, ...}>) => {
const largeInput = index % 5 === 4;
return (
@@ -56,7 +58,7 @@ export function ScrollViewKeyboardInsetsExample() {
automaticallyAdjustKeyboardInsets is{' '}
- {automaticallyAdjustKeyboardInsets + ''}
+ {String(automaticallyAdjustKeyboardInsets)}
setAutomaticallyAdjustKeyboardInsets(v)}
@@ -66,7 +68,7 @@ export function ScrollViewKeyboardInsetsExample() {
- FlatList is {flatList + ''}
+ FlatList is {String(flatList)}
setFlatList(v)}
@@ -77,7 +79,7 @@ export function ScrollViewKeyboardInsetsExample() {
{flatList && (
- inverted is {inverted + ''}
+ inverted is {String(inverted)}
setInverted(v)}
@@ -89,7 +91,7 @@ export function ScrollViewKeyboardInsetsExample() {
HeightRestricted is{' '}
- {heightRestricted + ''}
+ {String(heightRestricted)}
setHeightRestricted(v)}
diff --git a/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.android.js b/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.android.js
index e9109b4bf93..4665bcd2625 100644
--- a/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.android.js
+++ b/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.android.js
@@ -4,10 +4,8 @@
* 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';
-
-module.exports =
- require('react-native/Libraries/Components/UnimplementedViews/UnimplementedView').default;
+export {default} from 'react-native/Libraries/Components/UnimplementedViews/UnimplementedView';
diff --git a/packages/rn-tester/js/examples/WebSocket/WebSocketExample.js b/packages/rn-tester/js/examples/WebSocket/WebSocketExample.js
index 95d170e822a..49644f806e2 100644
--- a/packages/rn-tester/js/examples/WebSocket/WebSocketExample.js
+++ b/packages/rn-tester/js/examples/WebSocket/WebSocketExample.js
@@ -4,13 +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';
-
-/* eslint-env browser */
-
import RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {
@@ -33,8 +30,14 @@ const WS_STATES = [
/* 3 */ 'CLOSED',
];
-class Button extends React.Component {
- render(): React.MixedElement {
+class Button extends React.Component<
+ $ReadOnly<{
+ disabled: boolean,
+ label: string,
+ onPress: () => void,
+ }>,
+> {
+ render(): React.Node {
const label = (
{this.props.label}
);
@@ -51,23 +54,37 @@ class Button extends React.Component {
}
}
-class Row extends React.Component {
- render(): React.MixedElement {
+class Row extends React.Component<
+ $ReadOnly<{
+ children?: React.Node,
+ label: string,
+ value?: ?string,
+ }>,
+> {
+ render(): React.Node {
return (
{this.props.label}
- {this.props.value ? (
+ {this.props.value == null ? null : (
{this.props.value}
- ) : null}
+ )}
{this.props.children}
);
}
}
-class WebSocketImage extends React.Component {
+type WebSocketImageState = $ReadOnly<{
+ blob: ?Blob,
+}>;
+
+class WebSocketImage extends React.Component<
+ $ReadOnly<{url: string}>,
+ WebSocketImageState,
+> {
ws: ?WebSocket = null;
- state: {blob: ?Blob} = {blob: null};
+ state: WebSocketImageState = {blob: null};
+
componentDidMount() {
let ws = (this.ws = new WebSocket(this.props.url));
ws.binaryType = 'blob';
@@ -84,13 +101,15 @@ class WebSocketImage extends React.Component {
ws.send('getImage');
};
}
+
componentUnmount() {
if (this.state.blob) {
this.state.blob.close();
}
this.ws && this.ws.close();
}
- render() {
+
+ render(): React.Node {
if (!this.state.blob) {
return ;
}
@@ -103,7 +122,7 @@ class WebSocketImage extends React.Component {
}
}
-function showValue(value) {
+function showValue(value: $FlowFixMe): string {
if (value === undefined || value === null) {
return '(no value)';
}
@@ -117,7 +136,7 @@ function showValue(value) {
return value;
}
-type State = {
+type WebSocketExampleState = {
url: string,
httpUrl: string,
fetchStatus: ?string,
@@ -128,8 +147,11 @@ type State = {
outgoingMessage: string,
};
-class WebSocketExample extends React.Component {
- state: State = {
+class WebSocketExample extends React.Component<
+ $ReadOnly<{}>,
+ WebSocketExampleState,
+> {
+ state: WebSocketExampleState = {
url: DEFAULT_WS_URL,
httpUrl: DEFAULT_HTTP_URL,
fetchStatus: null,
@@ -157,11 +179,13 @@ class WebSocketExample extends React.Component {
};
_onSocketEvent = (event: MessageEvent) => {
- const state: any = {
+ const state: Partial = {
+ // $FlowFixMe[prop-missing]
socketState: event.target.readyState,
lastSocketEvent: event.type,
};
if (event.type === 'message') {
+ // $FlowFixMe[incompatible-type]
state.lastMessage = event.data;
}
this.setState(state);
@@ -179,7 +203,7 @@ class WebSocketExample extends React.Component {
this.setState({
fetchStatus: 'fetching',
});
- fetch(this.state.httpUrl).then(response => {
+ void fetch(this.state.httpUrl).then(response => {
if (response.status >= 200 && response.status < 400) {
this.setState({
fetchStatus: 'OK',
@@ -196,17 +220,17 @@ class WebSocketExample extends React.Component {
) {
return;
}
- const {outgoingMessage} = this.state;
+ const {outgoingMessage, socket} = this.state;
const buffer = new Uint8Array(outgoingMessage.length);
for (let i = 0; i < outgoingMessage.length; i++) {
buffer[i] = outgoingMessage.charCodeAt(i);
}
- this.state.socket.send(buffer);
+ socket.send(buffer);
this.setState({outgoingMessage: ''});
};
- render(): React.MixedElement {
- const socketState = WS_STATES[this.state.socketState || -1];
+ render(): React.Node {
+ const socketState = WS_STATES[this.state.socketState ?? -1];
const canConnect =
!this.state.socket || this.state.socket.readyState >= WebSocket.CLOSING;
const canSend = socketState === 'OPEN';
@@ -352,7 +376,7 @@ exports.description = 'WebSocket API';
exports.examples = [
{
title: 'Basic websocket',
- render(): React.MixedElement {
+ render(): React.Node {
return ;
},
},
diff --git a/packages/rn-tester/js/utils/RNTesterList.ios.js b/packages/rn-tester/js/utils/RNTesterList.ios.js
index 00283b43232..fa5968d9697 100644
--- a/packages/rn-tester/js/utils/RNTesterList.ios.js
+++ b/packages/rn-tester/js/utils/RNTesterList.ios.js
@@ -8,8 +8,6 @@
* @format
*/
-'use strict';
-
import type {RNTesterModule, RNTesterModuleInfo} from '../types/RNTesterTypes';
import * as RNTesterListFbInternal from './RNTesterListFbInternal';
diff --git a/scripts/build-types/index.js b/scripts/build-types/index.js
index af01930bc48..abf71faaa5d 100644
--- a/scripts/build-types/index.js
+++ b/scripts/build-types/index.js
@@ -65,6 +65,5 @@ async function main() {
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/debugger-frontend/sync-and-build.js b/scripts/debugger-frontend/sync-and-build.js
index a1184cbe250..80a21438664 100644
--- a/scripts/debugger-frontend/sync-and-build.js
+++ b/scripts/debugger-frontend/sync-and-build.js
@@ -642,6 +642,5 @@ async function createSyncDiff(
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/e2e/init-project-e2e.js b/scripts/e2e/init-project-e2e.js
index 8dc970b929c..6b47eae6399 100644
--- a/scripts/e2e/init-project-e2e.js
+++ b/scripts/e2e/init-project-e2e.js
@@ -293,6 +293,5 @@ module.exports = {
};
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/monorepo/print/index.js b/scripts/monorepo/print/index.js
index e5035e9c97e..1fc7dd10dc7 100644
--- a/scripts/monorepo/print/index.js
+++ b/scripts/monorepo/print/index.js
@@ -82,6 +82,5 @@ async function main() {
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index 168a3979f56..1abe227bb24 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -405,6 +405,5 @@ Force Quit via Activity Monitor.
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js
index 6f643a81a08..5bc22c84e97 100755
--- a/scripts/releases-ci/publish-npm.js
+++ b/scripts/releases-ci/publish-npm.js
@@ -136,6 +136,5 @@ module.exports = {
};
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases-ci/publish-updated-packages.js b/scripts/releases-ci/publish-updated-packages.js
index dbc8c161841..3b6701df304 100644
--- a/scripts/releases-ci/publish-updated-packages.js
+++ b/scripts/releases-ci/publish-updated-packages.js
@@ -152,7 +152,6 @@ function runPublish(
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases/create-release-commit.js b/scripts/releases/create-release-commit.js
index 30bbfbe13ec..7d85a783253 100644
--- a/scripts/releases/create-release-commit.js
+++ b/scripts/releases/create-release-commit.js
@@ -66,6 +66,5 @@ async function main() {
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases/prepare-ios-prebuilds.js b/scripts/releases/prepare-ios-prebuilds.js
index 2d68cba4550..e4d1ebcb888 100644
--- a/scripts/releases/prepare-ios-prebuilds.js
+++ b/scripts/releases/prepare-ios-prebuilds.js
@@ -73,6 +73,5 @@ async function main() {
}
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases/set-rn-artifacts-version.js b/scripts/releases/set-rn-artifacts-version.js
index 5931b7c45fc..bb1a2465ff0 100755
--- a/scripts/releases/set-rn-artifacts-version.js
+++ b/scripts/releases/set-rn-artifacts-version.js
@@ -168,6 +168,5 @@ module.exports = {
};
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}
diff --git a/scripts/releases/set-version.js b/scripts/releases/set-version.js
index c9038fa1c60..a48d697a394 100644
--- a/scripts/releases/set-version.js
+++ b/scripts/releases/set-version.js
@@ -105,6 +105,5 @@ module.exports = {
};
if (require.main === module) {
- // eslint-disable-next-line no-void
void main();
}