Skip to content

Commit 3db7728

Browse files
committed
order imports
1 parent afe3142 commit 3db7728

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1211
-2024
lines changed

eslint.config.mjs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ export default [
1313
'jest-setup.ts',
1414
],
1515
},
16-
//...callstackConfig,
17-
// ...tseslint.configs.strict,
18-
// {
19-
// plugins: {
20-
// 'simple-import-sort': simpleImportSort,
21-
// },
22-
// rules: {
23-
// 'simple-import-sort/imports': [
24-
// 'error',
25-
// {
26-
// groups: [['^\\u0000', '^react', '^@?\\w', '^'], ['^\\.']],
27-
// },
28-
// ],
29-
// },
30-
// },
31-
// {
32-
// rules: {
33-
// 'no-console': 'error',
34-
// 'import/order': 'off',
35-
// '@typescript-eslint/consistent-type-imports': 'error',
36-
// },
37-
// },
38-
// {
39-
// files: ['**/*.test.{ts,tsx}', 'src/test-utils/**'],
40-
// rules: {
41-
// 'react/no-multi-comp': 'off',
42-
// 'react-native/no-color-literals': 'off',
43-
// 'react-native/no-inline-styles': 'off',
44-
// 'react-native/no-raw-text': 'off',
45-
// 'react-native-a11y/has-valid-accessibility-descriptors': 'off',
46-
// 'react-native-a11y/has-valid-accessibility-ignores-invert-colors': 'off',
47-
// 'react-native-a11y/has-valid-accessibility-value': 'off',
48-
// '@typescript-eslint/no-explicit-any': 'off',
49-
// },
50-
// },
16+
...callstackConfig,
17+
...tseslint.configs.strict,
18+
{
19+
plugins: {
20+
'simple-import-sort': simpleImportSort,
21+
},
22+
rules: {
23+
'simple-import-sort/imports': [
24+
'error',
25+
{
26+
groups: [['^\\u0000', '^react', '^@?\\w', '^'], ['^\\.']],
27+
},
28+
],
29+
},
30+
},
31+
{
32+
rules: {
33+
'no-console': 'error',
34+
'import/order': 'off',
35+
'@typescript-eslint/consistent-type-imports': 'error',
36+
},
37+
},
38+
{
39+
files: ['**/*.test.{ts,tsx}', 'src/test-utils/**'],
40+
rules: {
41+
'react/no-multi-comp': 'off',
42+
'react-native/no-color-literals': 'off',
43+
'react-native/no-inline-styles': 'off',
44+
'react-native/no-raw-text': 'off',
45+
'react-native-a11y/has-valid-accessibility-descriptors': 'off',
46+
'react-native-a11y/has-valid-accessibility-ignores-invert-colors': 'off',
47+
'react-native-a11y/has-valid-accessibility-value': 'off',
48+
'@typescript-eslint/no-explicit-any': 'off',
49+
},
50+
},
5151
];

src/__tests__/react-native-animated.test.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from 'react';
2-
import { Animated, Text, ViewStyle } from 'react-native';
2+
import type { ViewStyle } from 'react-native';
3+
import { Animated, Text } from 'react-native';
4+
35
import { act, render, screen } from '..';
46

57
type AnimatedViewProps = {
@@ -41,28 +43,28 @@ describe('AnimatedView', () => {
4143
jest.useRealTimers();
4244
});
4345

44-
it('should use native driver when useNativeDriver is true', () => {
46+
it('should use native driver when useNativeDriver is true', async () => {
4547
render(
4648
<AnimatedView fadeInDuration={250} useNativeDriver={true}>
4749
<Text>Test</Text>
4850
</AnimatedView>,
4951
);
5052
expect(screen.root).toHaveStyle({ opacity: 0 });
5153

52-
act(() => jest.advanceTimersByTime(250));
54+
await act(() => jest.advanceTimersByTime(250));
5355
// This stopped working in tests in RN 0.77
5456
// expect(screen.root).toHaveStyle({ opacity: 0 });
5557
});
5658

57-
it('should not use native driver when useNativeDriver is false', () => {
59+
it('should not use native driver when useNativeDriver is false', async () => {
5860
render(
5961
<AnimatedView fadeInDuration={250} useNativeDriver={false}>
6062
<Text>Test</Text>
6163
</AnimatedView>,
6264
);
6365
expect(screen.root).toHaveStyle({ opacity: 0 });
6466

65-
act(() => jest.advanceTimersByTime(250));
67+
await act(() => jest.advanceTimersByTime(250));
6668
expect(screen.root).toHaveStyle({ opacity: 1 });
6769
});
6870
});

src/__tests__/render-hook.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* eslint-disable jest/no-conditional-expect */
2-
import React, { ReactNode } from 'react';
1+
import type { ReactNode } from 'react';
2+
import React from 'react';
3+
34
import { renderHook } from '../pure';
45

56
test('gives committed result', () => {

src/__tests__/render.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { Pressable, Text, TextInput, View } from 'react-native';
33
import { CONTAINER_TYPE } from 'universal-test-renderer';
4+
45
import { fireEvent, render, type RenderAPI, screen } from '..';
56

67
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';

src/__tests__/wait-for.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
2-
import { Text, TouchableOpacity, View, Pressable } from 'react-native';
3-
import { fireEvent, render, waitFor, configure, screen, act } from '..';
2+
import { Pressable, Text, TouchableOpacity, View } from 'react-native';
3+
4+
import { act, configure, fireEvent, render, screen, waitFor } from '..';
45

56
class Banana extends React.Component<any> {
67
changeFresh = () => {

src/event-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HostElement } from "universal-test-renderer";
1+
import type { HostElement } from 'universal-test-renderer';
22

33
export type EventHandlerOptions = {
44
/** Include check for event handler named without adding `on*` prefix. */

src/fire-event.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import {
2-
ViewProps,
3-
TextProps,
4-
TextInputProps,
1+
import type {
52
PressableProps,
63
ScrollViewProps,
4+
TextInputProps,
5+
TextProps,
6+
ViewProps,
77
} from 'react-native';
8-
import { HostElement } from 'universal-test-renderer';
8+
import type { HostElement } from 'universal-test-renderer';
9+
910
import act from './act';
11+
import { getEventHandler } from './event-handler';
1012
import { isElementMounted, isValidElement } from './helpers/component-tree';
1113
import { isHostScrollView, isHostTextInput } from './helpers/host-component-names';
1214
import { isPointerEventEnabled } from './helpers/pointer-events';
1315
import { isEditableTextInput } from './helpers/text-input';
14-
import { Point, StringWithAutocomplete } from './types';
1516
import { nativeState } from './native-state';
17+
import type { Point, StringWithAutocomplete } from './types';
1618
import { EventBuilder } from './user-event/event-builder';
17-
import { getEventHandler } from './event-handler';
1819

1920
type EventHandler = (...args: unknown[]) => unknown;
2021

@@ -145,7 +146,7 @@ fireEvent.press = (element: HostElement, ...data: unknown[]) => {
145146
? data[0].nativeEvent
146147
: null;
147148

148-
let responderGrantEvent = EventBuilder.Common.responderGrant();
149+
const responderGrantEvent = EventBuilder.Common.responderGrant();
149150
if (nativeData) {
150151
responderGrantEvent.nativeEvent = {
151152
...responderGrantEvent.nativeEvent,
@@ -156,7 +157,7 @@ fireEvent.press = (element: HostElement, ...data: unknown[]) => {
156157

157158
fireEvent(element, 'press', ...data);
158159

159-
let responderReleaseEvent = EventBuilder.Common.responderRelease();
160+
const responderReleaseEvent = EventBuilder.Common.responderRelease();
160161
if (nativeData) {
161162
responderReleaseEvent.nativeEvent = {
162163
...responderReleaseEvent.nativeEvent,

src/helpers/__tests__/component-tree.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import { View } from 'react-native';
3+
34
import { render, screen } from '../..';
4-
import { getHostSiblings, getContainerElement } from '../component-tree';
5+
import { getContainerElement, getHostSiblings } from '../component-tree';
56

67
function MultipleHostChildren() {
78
return (

src/helpers/accessibility.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import {
2-
AccessibilityRole,
3-
AccessibilityState,
4-
AccessibilityValue,
5-
Role,
6-
StyleSheet,
7-
} from 'react-native';
8-
import { HostElement } from 'universal-test-renderer';
9-
import { getHostSiblings, getContainerElement, isValidElement } from './component-tree';
1+
import type { AccessibilityRole, AccessibilityState, AccessibilityValue, Role } from 'react-native';
2+
import { StyleSheet } from 'react-native';
3+
import type { HostElement } from 'universal-test-renderer';
4+
5+
import { getContainerElement, getHostSiblings, isValidElement } from './component-tree';
106
import { findAll } from './find-all';
117
import { isHostImage, isHostSwitch, isHostText, isHostTextInput } from './host-component-names';
128
import { getTextContent } from './text-content';

src/helpers/component-tree.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { CONTAINER_TYPE, HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
import { CONTAINER_TYPE } from 'universal-test-renderer';
3+
24
import { screen } from '../screen';
35

46
/**

src/helpers/debug.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { JsonNode } from 'universal-test-renderer';
2+
3+
import type { FormatElementOptions } from './format-element';
4+
import { formatJson } from './format-element';
25
import { logger } from './logger';
3-
import { FormatElementOptions, formatJson } from './format-element';
46

57
export type DebugOptions = {
68
message?: string;

src/helpers/find-all.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
23
import { getConfig } from '../config';
34
import { isHiddenFromAccessibility } from './accessibility';
45
import { isValidElement } from './component-tree';

src/helpers/format-element.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { NewPlugin } from 'pretty-format';
22
import prettyFormat, { plugins } from 'pretty-format';
3+
import type { HostNode, JsonNode } from 'universal-test-renderer';
34

45
import type { MapPropsFunction } from './map-props';
56
import { defaultMapProps } from './map-props';
6-
import { HostNode, JsonNode } from 'universal-test-renderer';
77

88
export type FormatElementOptions = {
99
/** Minimize used space. */
@@ -33,7 +33,6 @@ export function formatElement(
3333
return element;
3434
}
3535

36-
const { children, ...props } = element.props;
3736
const childrenToDisplay = element.children.filter((child) => typeof child === 'string');
3837

3938
return prettyFormat(
@@ -42,7 +41,7 @@ export function formatElement(
4241
// a ReactTestRendererJSON instance, so it is formatted as JSX.
4342
$$typeof: Symbol.for('react.test.json'),
4443
type: `${element.type}`,
45-
props: mapProps ? mapProps(props) : props,
44+
props: mapProps ? mapProps(element.props) : element.props,
4645
children: childrenToDisplay,
4746
},
4847
// See: https://www.npmjs.com/package/pretty-format#usage-with-options

src/helpers/host-component-names.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
23
import { isValidElement } from './component-tree';
34

45
const HOST_TEXT_NAMES = ['Text', 'RCTText'];

src/helpers/matchers/match-accessibility-state.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
23
import {
34
computeAriaBusy,
45
computeAriaChecked,

src/helpers/matchers/match-accessibility-value.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
3+
import type { TextMatch } from '../../matches';
24
import { computeAriaValue } from '../accessibility';
35
import { matchStringProp } from './match-string-prop';
4-
import type { TextMatch } from '../../matches';
56

67
export interface AccessibilityValueMatcher {
78
min?: number;

src/helpers/matchers/match-label-text.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { HostElement } from 'universal-test-renderer';
2-
import { matches, TextMatch, TextMatchOptions } from '../../matches';
1+
import type { HostElement } from 'universal-test-renderer';
2+
3+
import type { TextMatch, TextMatchOptions } from '../../matches';
4+
import { matches } from '../../matches';
35
import { computeAriaLabel } from '../accessibility';
46

57
export function matchAccessibilityLabel(

src/helpers/matchers/match-text-content.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { HostElement } from 'universal-test-renderer';
2-
import { matches, TextMatch, TextMatchOptions } from '../../matches';
1+
import type { HostElement } from 'universal-test-renderer';
2+
3+
import type { TextMatch, TextMatchOptions } from '../../matches';
4+
import { matches } from '../../matches';
35
import { getTextContent } from '../text-content';
46

57
/**

src/helpers/pointer-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
22

33
/**
44
* pointerEvents controls whether the View can be the target of touch events.

src/helpers/text-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
22

33
export function getTextContent(element: HostElement | string | null): string {
44
if (!element) {

src/helpers/text-input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { HostElement } from 'universal-test-renderer';
1+
import type { HostElement } from 'universal-test-renderer';
2+
23
import { nativeState } from '../native-state';
34
import { isHostTextInput } from './host-component-names';
45

src/matchers/__tests__/to-be-empty-element.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Text, View } from 'react-native';
3+
34
import { render, screen } from '../..';
45

56
// eslint-disable-next-line @typescript-eslint/no-unused-vars

src/matchers/to-be-busy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { matcherHint } from 'jest-matcher-utils';
22
import redent from 'redent';
3-
import { HostElement } from 'universal-test-renderer';
3+
import type { HostElement } from 'universal-test-renderer';
4+
45
import { computeAriaBusy } from '../helpers/accessibility';
56
import { formatElement } from '../helpers/format-element';
67
import { checkHostElement } from './utils';

src/matchers/to-be-checked.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { matcherHint } from 'jest-matcher-utils';
2-
import { HostElement } from 'universal-test-renderer';
2+
import redent from 'redent';
3+
import type { HostElement } from 'universal-test-renderer';
4+
35
import {
46
computeAriaChecked,
57
getRole,
@@ -10,7 +12,6 @@ import { ErrorWithStack } from '../helpers/errors';
1012
import { formatElement } from '../helpers/format-element';
1113
import { isHostSwitch } from '../helpers/host-component-names';
1214
import { checkHostElement } from './utils';
13-
import redent from 'redent';
1415

1516
export function toBeChecked(this: jest.MatcherContext, element: HostElement) {
1617
checkHostElement(element, toBeChecked, this);

src/matchers/to-be-disabled.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { matcherHint } from 'jest-matcher-utils';
2-
import { HostElement } from 'universal-test-renderer';
3-
import { computeAriaDisabled } from '../helpers/accessibility';
4-
import { checkHostElement } from './utils';
52
import redent from 'redent';
3+
import type { HostElement } from 'universal-test-renderer';
4+
5+
import { computeAriaDisabled } from '../helpers/accessibility';
66
import { formatElement } from '../helpers/format-element';
7+
import { checkHostElement } from './utils';
78

89
export function toBeDisabled(this: jest.MatcherContext, element: HostElement) {
910
checkHostElement(element, toBeDisabled, this);

0 commit comments

Comments
 (0)