Skip to content

Commit

Permalink
fix linting noise (facebook#45465)
Browse files Browse the repository at this point in the history
Summary:
## Summary:
Fix linting warnings

Changelog: [Internal]

Pull Request resolved: facebook#45465

Test Plan:
```
$ eslint .
Done in 46.11s.
$ arc f
ok No lint issues.
```

Reviewed By: cipolleschi

Differential Revision: D59805820

Pulled By: blakef

fbshipit-source-id: f33d99a6a06607c3c3762881cc7c182804b981e1
  • Loading branch information
blakef authored and facebook-github-bot committed Jul 17, 2024
1 parent 394aae1 commit 188a09e
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import * as React from 'react';

const {create, update, unmount} = require('../../../jest/renderer');
const {create, unmount, update} = require('../../../jest/renderer');
const {PlatformColor} = require('../../StyleSheet/PlatformColorValueTypes');
let Animated = require('../Animated').default;
const AnimatedProps = require('../nodes/AnimatedProps').default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const NativeAnimatedAPI = NativeAnimatedHelper.API;
* transform which can receive values from multiple parents.
*/
export function flushValue(rootNode: AnimatedNode): void {
// eslint-disable-next-line func-call-spacing
const leaves = new Set<{update: () => void, ...}>();
function findAnimatedStyles(node: AnimatedNode) {
// $FlowFixMe[prop-missing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,6 @@ function InternalTextInput(props: Props): React.Node {

const inputRef = useRef<null | React.ElementRef<HostComponent<mixed>>>(null);

// eslint-disable-next-line react-hooks/exhaustive-deps
const selection: ?Selection =
propsSelection == null
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
shadowNode,
);

// eslint-disable-next-line no-bitwise
let isAncestor = (result & DOCUMENT_POSITION_CONTAINED_BY) !== 0;

callback([isAncestor]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const translate = require('flow-api-translator');
const {promises: fs} = require('fs');
const glob = require('glob');
const {transform} = require('hermes-transform');
const os = require('os');
const path = require('path');

const PACKAGE_ROOT = path.resolve(__dirname, '../../');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const {bundleCommand: bc} = require('@react-native/community-cli-plugin');
const {execSync} = require('child_process');
const program = require('commander');
const {existsSync, readFileSync} = require('fs');
const {readFileSync} = require('fs');
const path = require('path');

program.version(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

const {RNTesterThemeContext} = require('../../components/RNTesterTheme');
const React = require('react');
const {Alert, Text, View} = require('react-native');
const {RNTesterThemeContext} = require('../../components/RNTesterTheme');

type Props = $ReadOnly<{||}>;
class AccessibilityIOSExample extends React.Component<Props> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'use strict';

import type {NativeMethods} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';

import {RNTesterThemeContext} from '../../components/RNTesterTheme';

const ScreenshotManager = require('../../../NativeModuleExample/NativeScreenshotManager');
Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/js/examples/Alert/AlertExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import type {RNTesterModule} from '../../types/RNTesterTypes';

import * as React from 'react';
import {RNTesterThemeContext} from '../../components/RNTesterTheme';
import * as React from 'react';
import {Alert, Pressable, StyleSheet, Text, View} from 'react-native';

// Shows log on the screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';

import React from 'react';
import {useState} from 'react';
import {
Button,
Image,
ImageBackground,
StyleSheet,
View,
Text,
} from 'react-native';
import {Image, ImageBackground, StyleSheet, Text, View} from 'react-native';

type Props = $ReadOnly<{
style: ViewStyleProp,
Expand Down
220 changes: 114 additions & 106 deletions packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {act, create} from 'react-test-renderer';

jest.useFakeTimers();

const skipTestSilenceLinter = it.skip;

describe('VirtualizedList', () => {
it('renders simple list', async () => {
let component;
Expand Down Expand Up @@ -460,77 +462,80 @@ describe('VirtualizedList', () => {
});

// TODO: Revisit this test case after upgrading to React 19.
it.skip('calls onStartReached when near the start', async () => {
const ITEM_HEIGHT = 40;
const layout = {width: 300, height: 600};
let data = Array(40)
.fill()
.map((_, index) => ({key: `key-${index}`}));
const onStartReached = jest.fn();
const props = {
data,
initialNumToRender: 10,
onStartReachedThreshold: 1,
windowSize: 10,
renderItem: ({item}) => <item value={item.key} />,
getItem: (items, index) => items[index],
getItemCount: items => items.length,
getItemLayout: (items, index) => ({
length: ITEM_HEIGHT,
offset: ITEM_HEIGHT * index,
index,
}),
onStartReached,
initialScrollIndex: data.length - 1,
};
let component;
await act(() => {
component = create(<VirtualizedList {...props} />);
});
skipTestSilenceLinter(
'calls onStartReached when near the start',
async () => {
const ITEM_HEIGHT = 40;
const layout = {width: 300, height: 600};
let data = Array(40)
.fill()
.map((_, index) => ({key: `key-${index}`}));
const onStartReached = jest.fn();
const props = {
data,
initialNumToRender: 10,
onStartReachedThreshold: 1,
windowSize: 10,
renderItem: ({item}) => <item value={item.key} />,
getItem: (items, index) => items[index],
getItemCount: items => items.length,
getItemLayout: (items, index) => ({
length: ITEM_HEIGHT,
offset: ITEM_HEIGHT * index,
index,
}),
onStartReached,
initialScrollIndex: data.length - 1,
};
let component;
await act(() => {
component = create(<VirtualizedList {...props} />);
});

const instance = component.getInstance();
const instance = component.getInstance();

await act(async () => {
instance._onLayout({nativeEvent: {layout, zoomScale: 1}});
instance._onContentSizeChange(300, data.length * ITEM_HEIGHT);
await act(async () => {
instance._onLayout({nativeEvent: {layout, zoomScale: 1}});
instance._onContentSizeChange(300, data.length * ITEM_HEIGHT);

// Make sure onStartReached is not called initially when initialScrollIndex is set.
await jest.runAllTimersAsync();
});
expect(onStartReached).not.toHaveBeenCalled();

await act(async () => {
// Scroll for a small amount and make sure onStartReached is not called.
instance._onScroll({
timeStamp: 1000,
nativeEvent: {
contentOffset: {y: (data.length - 2) * ITEM_HEIGHT, x: 0},
layoutMeasurement: layout,
contentSize: {...layout, height: data.length * ITEM_HEIGHT},
zoomScale: 1,
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
},
// Make sure onStartReached is not called initially when initialScrollIndex is set.
await jest.runAllTimersAsync();
});
await jest.runAllTimersAsync();
});
expect(onStartReached).not.toHaveBeenCalled();

await act(async () => {
// Scroll to start and make sure onStartReached is called.
instance._onScroll({
timeStamp: 1000,
nativeEvent: {
contentOffset: {y: 0, x: 0},
layoutMeasurement: layout,
contentSize: {...layout, height: data.length * ITEM_HEIGHT},
zoomScale: 1,
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
},
expect(onStartReached).not.toHaveBeenCalled();

await act(async () => {
// Scroll for a small amount and make sure onStartReached is not called.
instance._onScroll({
timeStamp: 1000,
nativeEvent: {
contentOffset: {y: (data.length - 2) * ITEM_HEIGHT, x: 0},
layoutMeasurement: layout,
contentSize: {...layout, height: data.length * ITEM_HEIGHT},
zoomScale: 1,
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
},
});
await jest.runAllTimersAsync();
});
await jest.runAllTimersAsync();
});
expect(onStartReached).toHaveBeenCalled();
});
expect(onStartReached).not.toHaveBeenCalled();

await act(async () => {
// Scroll to start and make sure onStartReached is called.
instance._onScroll({
timeStamp: 1000,
nativeEvent: {
contentOffset: {y: 0, x: 0},
layoutMeasurement: layout,
contentSize: {...layout, height: data.length * ITEM_HEIGHT},
zoomScale: 1,
contentInset: {right: 0, top: 0, left: 0, bottom: 0},
},
});
await jest.runAllTimersAsync();
});
expect(onStartReached).toHaveBeenCalled();
},
);

it('calls onStartReached initially', async () => {
const ITEM_HEIGHT = 40;
Expand Down Expand Up @@ -1742,52 +1747,55 @@ it('retains initial render region when an item is appended', async () => {
});

// TODO: Revisit this test case after upgrading to React 19.
it.skip('retains batch render region when an item is appended', async () => {
const items = generateItems(10);
const ITEM_HEIGHT = 10;
skipTestSilenceLinter(
'retains batch render region when an item is appended',
async () => {
const items = generateItems(10);
const ITEM_HEIGHT = 10;

let component;
await act(() => {
component = create(
<VirtualizedList
initialNumToRender={1}
maxToRenderPerBatch={1}
{...baseItemProps(items)}
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
/>,
);
});
let component;
await act(() => {
component = create(
<VirtualizedList
initialNumToRender={1}
maxToRenderPerBatch={1}
{...baseItemProps(items)}
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
/>,
);
});

await act(() => {
simulateLayout(component, {
viewport: {width: 10, height: 50},
content: {width: 10, height: 100},
await act(() => {
simulateLayout(component, {
viewport: {width: 10, height: 50},
content: {width: 10, height: 100},
});
performAllBatches();
});
performAllBatches();
});

await act(async () => {
await jest.runAllTimersAsync();
});
await act(async () => {
await jest.runAllTimersAsync();
});

await act(() => {
component.update(
<VirtualizedList
initialNumToRender={1}
maxToRenderPerBatch={1}
{...baseItemProps(items)}
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
data={generateItems(11)}
/>,
);
});
await act(() => {
component.update(
<VirtualizedList
initialNumToRender={1}
maxToRenderPerBatch={1}
{...baseItemProps(items)}
{...fixedHeightItemLayoutProps(ITEM_HEIGHT)}
data={generateItems(11)}
/>,
);
});

// Adding an item to the list after batch render should keep the existing
// rendered items rendered. We batch render 10 items, then add an 11th. Expect
// the first ten items to be present, with a spacer for the 11th until the
// next batch render.
expect(component).toMatchSnapshot();
});
// Adding an item to the list after batch render should keep the existing
// rendered items rendered. We batch render 10 items, then add an 11th. Expect
// the first ten items to be present, with a spacer for the 11th until the
// next batch render.
expect(component).toMatchSnapshot();
},
);

it('constrains batch render region when an item is removed', async () => {
const items = generateItems(10);
Expand Down
4 changes: 2 additions & 2 deletions scripts/e2e/init-template-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ function _updateScopedPackages(
fs.readFileSync(appPackageJsonPath, 'utf8'),
);

for (const [key, _] of Object.entries(appPackageJson.dependencies)) {
for (const key of Object.keys(appPackageJson.dependencies)) {
if (key.startsWith('@react-native')) {
appPackageJson.dependencies[key] = version;
}
}
for (const [key, _] of Object.entries(appPackageJson.devDependencies)) {
for (const key of Object.keys(appPackageJson.devDependencies)) {
if (key.startsWith('@react-native')) {
appPackageJson.devDependencies[key] = version;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/releases/utils/release-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const {
createHermesPrebuiltArtifactsTarball,
} = require('../../../packages/react-native/scripts/hermes/hermes-utils');
const {echo, env, exec, exit, popd, pushd, test} = require('shelljs');
const {echo, exec, exit, popd, pushd, test} = require('shelljs');

/*::
type BuildType = 'dry-run' | 'release' | 'nightly' | 'prealpha';
Expand Down

0 comments on commit 188a09e

Please sign in to comment.