Skip to content

Commit 1697b39

Browse files
authored
[eslint] Add simple-import-sort (#4092)
## Description Turns out that inbuilt `sort-import` cannot be fixed with autofix. I got inspiration from [Reanimated](https://github.com/software-mansion/react-native-reanimated/blob/8937365d427723f8fb0859c31c4d349345d2639b/eslint.config.mjs#L183) and added `simple-import-sort` ## Test plan `yarn lint-js` <img width="1085" height="149" alt="image" src="https://github.com/user-attachments/assets/c769c157-32b5-4d35-8c0c-518734e100d0" />
1 parent 6313763 commit 1697b39

285 files changed

Lines changed: 1512 additions & 1391 deletions

File tree

Some content is hidden

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

.eslintrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"project": ["./tsconfig.json"]
1717
},
1818
"env": { "browser": true, "node": true, "jest/globals": true },
19-
"plugins": ["react", "jest"],
19+
"plugins": ["react", "jest", "simple-import-sort"],
2020
"ignorePatterns": [
2121
"packages/react-native-gesture-handler/lib/**/*",
2222
"**/*.config.js",
@@ -88,6 +88,7 @@
8888
"curly": "error",
8989
"spaced-comment": "error",
9090
"no-alert": "warn",
91-
"sort-imports": "error"
91+
"simple-import-sort/imports": "error",
92+
"simple-import-sort/exports": "error"
9293
}
9394
}

apps/basic-example/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react';
22
import { Platform, SafeAreaView } from 'react-native';
3-
import ContentsButton from './ContentsButton';
43
import { GestureHandlerRootView } from 'react-native-gesture-handler';
4+
5+
import ContentsButton from './ContentsButton';
56
import NativeDetector from './NativeDetector';
67
import Navigator from './Navigator';
78
import RuntimeDecoration from './RuntimeDecoration';

apps/basic-example/src/ContentsButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import React from 'react';
2+
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
13
import {
24
GestureHandlerRootView,
35
RectButton,
46
ScrollView,
57
} from 'react-native-gesture-handler';
6-
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
7-
import React from 'react';
88

99
export default function ComplexUI() {
1010
return (

apps/basic-example/src/Navigator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BackHandler, Pressable, Text, View } from 'react-native';
21
import React, { useEffect, useState } from 'react';
2+
import { BackHandler, Pressable, Text, View } from 'react-native';
33

44
export interface RouteInfo {
55
component: React.ComponentType;

apps/basic-example/src/RuntimeDecoration.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as React from 'react';
2+
import { useState } from 'react';
3+
import { StyleSheet, Text, View } from 'react-native';
4+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
25
import Animated, {
36
runOnJS,
47
useAnimatedStyle,
58
useSharedValue,
69
} from 'react-native-reanimated';
7-
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
8-
import { StyleSheet, Text, View } from 'react-native';
10+
911
import { COLORS } from './colors';
10-
import { useState } from 'react';
1112

1213
export function RuntimeChecker({
1314
runGestureOnJS,

apps/basic-example/src/Text.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as React from 'react';
2+
import { StyleSheet, Text, View } from 'react-native';
23
import {
34
Gesture,
45
GestureDetector,
56
InterceptingGestureDetector,
6-
VirtualGestureDetector,
77
useTapGesture,
8+
VirtualGestureDetector,
89
} from 'react-native-gesture-handler';
9-
import { StyleSheet, Text, View } from 'react-native';
10+
1011
import { COLORS } from './colors';
1112

1213
function NativeDetectorExample() {

apps/common-app/src/ListWithHeader/Header.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import React, { useEffect } from 'react';
2+
import { Platform, StyleSheet } from 'react-native';
3+
import type { SharedValue } from 'react-native-reanimated';
14
import Animated, {
25
Easing,
36
interpolate,
@@ -8,15 +11,10 @@ import Animated, {
811
useSharedValue,
912
withTiming,
1013
} from 'react-native-reanimated';
11-
import { Platform, StyleSheet } from 'react-native';
12-
import React, { useEffect } from 'react';
13-
import { COLORS } from '../common';
14-
import type { SharedValue } from 'react-native-reanimated';
1514

16-
// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires
17-
const SIGNET = require('./signet.png');
18-
// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires
19-
const TEXT = require('./text.png');
15+
import { COLORS } from '../common';
16+
import SIGNET from './signet.png';
17+
import TEXT from './text.png';
2018

2119
export const HEADER_HEIGHT =
2220
Platform.OS === 'web' || Platform.OS === 'macos' ? 64 : 192;

apps/common-app/src/ListWithHeader/ListWithHeader.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import React, { useEffect } from 'react';
2+
import type { ScrollViewProps, SectionListProps } from 'react-native';
3+
import { Platform, SectionList, StyleSheet } from 'react-native';
4+
import type { GestureType } from 'react-native-gesture-handler';
5+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
6+
import type { AnimatedRef, SharedValue } from 'react-native-reanimated';
17
import Animated, {
28
runOnJS,
39
useAnimatedProps,
@@ -8,13 +14,8 @@ import Animated, {
814
useSharedValue,
915
withSpring,
1016
} from 'react-native-reanimated';
11-
import type { AnimatedRef, SharedValue } from 'react-native-reanimated';
12-
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
17+
1318
import Header, { HEADER_HEIGHT } from './Header';
14-
import { Platform, SectionList, StyleSheet } from 'react-native';
15-
import React, { useEffect } from 'react';
16-
import type { ScrollViewProps, SectionListProps } from 'react-native';
17-
import type { GestureType } from 'react-native-gesture-handler';
1819

1920
const IS_ANDROID = Platform.OS === 'android';
2021

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1+
export { COLLAPSED_HEADER_HEIGHT, HEADER_HEIGHT } from './Header';
12
export { ListWithHeader } from './ListWithHeader';
2-
export { HEADER_HEIGHT, COLLAPSED_HEADER_HEIGHT } from './Header';

apps/common-app/src/common.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import Animated, {
2-
Easing,
3-
useAnimatedStyle,
4-
useSharedValue,
5-
withTiming,
6-
} from 'react-native-reanimated';
7-
import type { Platform, StyleProp, ViewStyle } from 'react-native';
1+
import type { RefObject } from 'react';
82
import React, {
93
useCallback,
104
useEffect,
115
useImperativeHandle,
126
useRef,
137
useState,
148
} from 'react';
9+
import type { Platform, StyleProp, ViewStyle } from 'react-native';
1510
import { StyleSheet, Text, View } from 'react-native';
16-
import type { RefObject } from 'react';
11+
import Animated, {
12+
Easing,
13+
useAnimatedStyle,
14+
useSharedValue,
15+
withTiming,
16+
} from 'react-native-reanimated';
1717

1818
export interface Example {
1919
name: string;

0 commit comments

Comments
 (0)