Skip to content

Commit d21dbb4

Browse files
sort imports (#1729)
1 parent 1219944 commit d21dbb4

File tree

106 files changed

+245
-201
lines changed

Some content is hidden

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

106 files changed

+245
-201
lines changed

eslint.config.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import tseslint from 'typescript-eslint';
22
import callstackConfig from '@callstack/eslint-config/react-native.flat.js';
3+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
34

45
export default [
56
{
@@ -14,9 +15,24 @@ export default [
1415
},
1516
...callstackConfig,
1617
...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+
},
1731
{
1832
rules: {
1933
'no-console': 'error',
34+
'import/order': 'off',
35+
'@typescript-eslint/consistent-type-imports': 'error',
2036
},
2137
},
2238
{

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"babel-plugin-module-resolver": "^5.0.2",
8383
"del-cli": "^6.0.0",
8484
"eslint": "^9.17.0",
85+
"eslint-plugin-simple-import-sort": "^12.1.1",
8586
"flow-bin": "~0.170.0",
8687
"jest": "^29.7.0",
8788
"prettier": "^2.8.8",

src/__tests__/config.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getConfig, configure, resetToDefaults } from '../config';
1+
import { configure, getConfig, resetToDefaults } from '../config';
22

33
beforeEach(() => {
44
resetToDefaults();

src/__tests__/fire-event-textInput.test.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { Text, TextInput, TextInputProps } from 'react-native';
3-
import { render, fireEvent, screen } from '..';
2+
import type { TextInputProps } from 'react-native';
3+
import { Text, TextInput } from 'react-native';
4+
import { fireEvent, render, screen } from '..';
45

56
function WrappedTextInput(props: TextInputProps) {
67
return <TextInput {...props} />;

src/__tests__/host-component-names.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { Image, Modal, ScrollView, Switch, Text, TextInput } from 'react-native';
3+
import { render, screen } from '..';
34
import {
45
isHostImage,
56
isHostModal,
@@ -8,7 +9,6 @@ import {
89
isHostText,
910
isHostTextInput,
1011
} from '../helpers/host-component-names';
11-
import { render, screen } from '..';
1212

1313
test('detects host Text component', () => {
1414
render(<Text>Hello</Text>);

src/__tests__/host-text-nesting.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { Text, Pressable, View } from 'react-native';
3-
import { render, within, screen } from '../pure';
2+
import { Pressable, Text, View } from 'react-native';
3+
import { render, screen, within } from '../pure';
44

55
/**
66
* Our queries interact differently with composite and host elements, and some specific cases require us

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
2-
import { Animated, ViewStyle } from 'react-native';
2+
import type { ViewStyle } from 'react-native';
3+
import { Animated } from 'react-native';
34
import { act, render, screen } from '..';
45

56
type AnimatedViewProps = {

src/__tests__/render-hook.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { ReactNode } from 'react';
1+
import type { ReactNode } from 'react';
2+
import React from 'react';
23
import TestRenderer from 'react-test-renderer';
34
import { renderHook } from '../pure';
45

src/__tests__/render-string-validation.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { View, Text, Pressable } from 'react-native';
3-
import { render, fireEvent, screen } from '..';
2+
import { Pressable, Text, View } from 'react-native';
3+
import { fireEvent, render, screen } from '..';
44

55
// eslint-disable-next-line no-console
66
const originalConsoleError = console.error;

src/__tests__/render.test.tsx

+2-1
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';
3-
import { fireEvent, render, RenderAPI, screen } from '..';
3+
import type { RenderAPI } from '..';
4+
import { fireEvent, render, screen } from '..';
45

56
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
67
const PLACEHOLDER_CHEF = 'Who inspected freshness?';

src/__tests__/screen.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { View, Text } from 'react-native';
2+
import { Text, View } from 'react-native';
33
import { render, screen } from '..';
44

55
test('screen has the same queries as render result', () => {

src/__tests__/wait-for.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { Text, TouchableOpacity, View, Pressable } from 'react-native';
3-
import { fireEvent, render, waitFor, configure, screen } from '..';
2+
import { Pressable, Text, TouchableOpacity, View } from 'react-native';
3+
import { configure, fireEvent, render, screen, waitFor } from '..';
44

55
class Banana extends React.Component<any> {
66
changeFresh = () => {

src/__tests__/within.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { View, Text, TextInput } from 'react-native';
3-
import { render, within, getQueriesForElement } from '..';
2+
import { Text, TextInput, View } from 'react-native';
3+
import { getQueriesForElement, render, within } from '..';
44

55
test('within() exposes basic queries', async () => {
66
const rootQueries = render(

src/act.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ function withGlobalActEnvironment(actImplementation: ReactAct) {
7272
const act = withGlobalActEnvironment(reactAct) as ReactAct;
7373

7474
export default act;
75-
export { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment };
75+
export { getIsReactActEnvironment, setIsReactActEnvironment as setReactActEnvironment };

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DebugOptions } from './helpers/debug';
1+
import type { DebugOptions } from './helpers/debug';
22

33
/**
44
* Global configuration options for React Native Testing Library.

src/fire-event.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
2-
import {
3-
ViewProps,
4-
TextProps,
5-
TextInputProps,
1+
import type {
62
PressableProps,
73
ScrollViewProps,
4+
TextInputProps,
5+
TextProps,
6+
ViewProps,
87
} from 'react-native';
8+
import type { ReactTestInstance } from 'react-test-renderer';
99
import act from './act';
1010
import { isElementMounted, isHostElement } from './helpers/component-tree';
1111
import { isHostScrollView, isHostTextInput } from './helpers/host-component-names';
1212
import { isPointerEventEnabled } from './helpers/pointer-events';
1313
import { isEditableTextInput } from './helpers/text-input';
14-
import { Point, StringWithAutocomplete } from './types';
1514
import { nativeState } from './native-state';
15+
import type { Point, StringWithAutocomplete } from './types';
1616

1717
type EventHandler = (...args: unknown[]) => unknown;
1818

src/helpers/__tests__/accessiblity.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { View, Text, TextInput, Pressable, Switch, TouchableOpacity } from 'react-native';
3-
import { render, isHiddenFromAccessibility, isInaccessible, screen } from '../..';
2+
import { Pressable, Switch, Text, TextInput, TouchableOpacity, View } from 'react-native';
3+
import { isHiddenFromAccessibility, isInaccessible, render, screen } from '../..';
44
import { computeAriaLabel, isAccessibilityElement } from '../accessibility';
55

66
describe('isHiddenFromAccessibility', () => {

src/helpers/accessibility.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {
2-
AccessibilityRole,
3-
AccessibilityState,
4-
AccessibilityValue,
5-
Role,
6-
StyleSheet,
7-
} from 'react-native';
1+
import type { AccessibilityRole, AccessibilityState, AccessibilityValue, Role } from 'react-native';
2+
import { StyleSheet } from 'react-native';
83
import type { ReactTestInstance } from 'react-test-renderer';
94
import { getHostSiblings, getUnsafeRootElement, isHostElement } from './component-tree';
105
import { findAll } from './find-all';

src/helpers/component-tree.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
22
import { screen } from '../screen';
33
/**
44
* ReactTestInstance referring to host element.

src/helpers/debug.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ReactTestRendererJSON } from 'react-test-renderer';
2-
import format, { FormatOptions } from './format';
2+
import type { FormatOptions } from './format';
3+
import format from './format';
34
import { logger } from './logger';
45

56
export type DebugOptions = {

src/helpers/find-all.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
22
import { getConfig } from '../config';
33
import { isHiddenFromAccessibility } from './accessibility';
4-
import { HostTestInstance, isHostElement } from './component-tree';
4+
import type { HostTestInstance } from './component-tree';
5+
import { isHostElement } from './component-tree';
56

67
interface FindAllOptions {
78
/** Match elements hidden from accessibility */

src/helpers/format-default.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { StyleSheet, ViewStyle } from 'react-native';
1+
import type { ViewStyle } from 'react-native';
2+
import { StyleSheet } from 'react-native';
23
import { removeUndefinedKeys } from './object';
34

45
const propsToDisplay = [

src/helpers/format.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ReactTestRendererJSON } from 'react-test-renderer';
2-
import prettyFormat, { NewPlugin, plugins } from 'pretty-format';
2+
import type { NewPlugin } from 'pretty-format';
3+
import prettyFormat, { plugins } from 'pretty-format';
34

45
export type MapPropsFunction = (
56
props: Record<string, unknown>,

src/helpers/host-component-names.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
2-
import { HostTestInstance } from './component-tree';
1+
import type { ReactTestInstance } from 'react-test-renderer';
2+
import type { HostTestInstance } from './component-tree';
33

44
const HOST_TEXT_NAMES = ['Text', 'RCTText'];
55
const HOST_TEXT_INPUT_NAMES = ['TextInput'];

src/helpers/logger.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as nodeConsole from 'console';
2-
import * as nodeUtil from 'util';
31
import chalk from 'chalk';
2+
import * as nodeConsole from 'console';
43
import redent from 'redent';
4+
import * as nodeUtil from 'util';
55

66
export const logger = {
77
debug(message: unknown, ...args: unknown[]) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
22
import {
33
computeAriaBusy,
44
computeAriaChecked,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
2+
import type { TextMatch } from '../../matches';
23
import { computeAriaValue } from '../accessibility';
3-
import { TextMatch } from '../../matches';
44
import { matchStringProp } from './match-string-prop';
55

66
export interface AccessibilityValueMatcher {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
2-
import { matches, TextMatch, TextMatchOptions } from '../../matches';
1+
import type { ReactTestInstance } from 'react-test-renderer';
2+
import type { TextMatch, TextMatchOptions } from '../../matches';
3+
import { matches } from '../../matches';
34
import { computeAriaLabel } from '../accessibility';
45

56
export function matchAccessibilityLabel(

src/helpers/matchers/match-string-prop.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TextMatch } from '../../matches';
1+
import type { TextMatch } from '../../matches';
22

33
/**
44
* Matches the given string property again string or regex matcher.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ReactTestInstance } from 'react-test-renderer';
2-
import { matches, TextMatch, TextMatchOptions } from '../../matches';
2+
import type { TextMatch, TextMatchOptions } from '../../matches';
3+
import { matches } from '../../matches';
34
import { getTextContent } from '../text-content';
45

56
/**

src/helpers/pointer-events.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
22
import { getHostParent } from './component-tree';
33

44
/**

src/helpers/string-validation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactTestRendererNode } from 'react-test-renderer';
1+
import type { ReactTestRendererNode } from 'react-test-renderer';
22

33
export const validateStringsRenderedWithinText = (
44
rendererJSON: ReactTestRendererNode | Array<ReactTestRendererNode> | null,

src/helpers/text-input.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactTestInstance } from 'react-test-renderer';
1+
import type { ReactTestInstance } from 'react-test-renderer';
22
import { nativeState } from '../native-state';
33
import { isHostTextInput } from './host-component-names';
44

src/helpers/timers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ const { clearTimeoutFn, setImmediateFn, setTimeoutFn } = runWithRealTimers(
8787
) as BindTimeFunctions;
8888

8989
export {
90-
runWithRealTimers,
91-
jestFakeTimersAreEnabled,
9290
clearTimeoutFn as clearTimeout,
91+
jestFakeTimersAreEnabled,
92+
runWithRealTimers,
9393
setImmediateFn as setImmediate,
9494
setTimeoutFn as setTimeout,
9595
};

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { cleanup } from './pure';
2-
import { flushMicroTasks } from './flush-micro-tasks';
3-
import { getIsReactActEnvironment, setReactActEnvironment } from './act';
41
import './matchers/extend-expect';
2+
import { getIsReactActEnvironment, setReactActEnvironment } from './act';
3+
import { flushMicroTasks } from './flush-micro-tasks';
4+
import { cleanup } from './pure';
55

66
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
77
// If we're running in a test runner that supports afterEach

src/matchers/__tests__/to-be-disabled.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import {
33
Button,
44
Pressable,
5+
Text,
56
TextInput,
67
TouchableHighlight,
78
TouchableNativeFeedback,
89
TouchableOpacity,
910
TouchableWithoutFeedback,
10-
Text,
1111
View,
1212
} from 'react-native';
1313
import { render, screen } from '../..';

src/matchers/__tests__/to-be-on-the-screen.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { View, Text } from 'react-native';
2+
import { Text, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
test('toBeOnTheScreen() example test', () => {

src/matchers/__tests__/to-be-visible.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { View, Modal } from 'react-native';
2+
import { Modal, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
test('toBeVisible() on empty view', () => {

src/matchers/__tests__/to-have-accessible-name.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { View, Text, TextInput, Image } from 'react-native';
2+
import { Image, Text, TextInput, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
test('toHaveAccessibleName() handles view with "accessibilityLabel" prop', () => {

src/matchers/__tests__/to-have-prop.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { View, Text, TextInput } from 'react-native';
2+
import { Text, TextInput, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
test('toHaveProp() basic case', () => {

src/matchers/__tests__/to-have-style.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet, View, Pressable } from 'react-native';
2+
import { Pressable, StyleSheet, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
const styles = StyleSheet.create({

src/matchers/__tests__/to-have-text-content.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { View, Text } from 'react-native';
2+
import { Text, View } from 'react-native';
33
import { render, screen } from '../..';
44

55
test('toHaveTextContent() example test', () => {

0 commit comments

Comments
 (0)