From f047f9504d2bcb8358f928edd1152361a545d484 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 19 Jul 2023 14:55:13 +0200 Subject: [PATCH] chore: format code in test examples (#1812) ## Description Working with test examples is stressful for eyes as ESlint is making my screen red. ## Changes "Fixed all autofixable problems" in test examples. Essentially I've adjusted eslint & prettier configs and run `prettier . --write` in examples. ## Checklist - [ ] Ensured that CI passes --- FabricTestExample/.eslintrc.js | 8 + FabricTestExample/.prettierrc.js | 2 +- FabricTestExample/App.js | 2 +- FabricTestExample/index.js | 4 +- FabricTestExample/metro.config.js | 3 +- FabricTestExample/src/Test1017.tsx | 25 +-- FabricTestExample/src/Test1031.tsx | 42 +++-- FabricTestExample/src/Test1032.tsx | 18 +- FabricTestExample/src/Test1036.tsx | 10 +- FabricTestExample/src/Test1072.tsx | 16 +- FabricTestExample/src/Test1084.tsx | 20 ++- FabricTestExample/src/Test1091.tsx | 10 +- FabricTestExample/src/Test1096.tsx | 14 +- FabricTestExample/src/Test1097.tsx | 20 +-- FabricTestExample/src/Test111.js | 12 +- FabricTestExample/src/Test1153.tsx | 13 +- FabricTestExample/src/Test1157.tsx | 18 +- FabricTestExample/src/Test1162.tsx | 25 +-- .../Test1166/AndroidDifferentScreenSearch.tsx | 18 +- .../AndroidSearchBarCustomization.tsx | 6 +- .../src/Test1166/AndroidSearchBarEvents.tsx | 18 +- .../src/Test1166/AndroidSearchTypes.tsx | 18 +- FabricTestExample/src/Test1166/index.tsx | 14 +- FabricTestExample/src/Test1188.tsx | 8 +- FabricTestExample/src/Test1190.tsx | 46 +++-- FabricTestExample/src/Test1198.tsx | 10 +- FabricTestExample/src/Test1204.tsx | 8 +- FabricTestExample/src/Test1209.tsx | 22 ++- FabricTestExample/src/Test1213.tsx | 8 +- FabricTestExample/src/Test1214.tsx | 35 ++-- FabricTestExample/src/Test1227.tsx | 14 +- FabricTestExample/src/Test1228.tsx | 15 +- FabricTestExample/src/Test1259.tsx | 4 +- FabricTestExample/src/Test1260.tsx | 48 ++++-- FabricTestExample/src/Test1296.tsx | 29 ++-- FabricTestExample/src/Test1299.tsx | 18 +- FabricTestExample/src/Test1391.tsx | 28 ++-- FabricTestExample/src/Test1419.tsx | 72 ++++---- FabricTestExample/src/Test1463.tsx | 41 +++-- FabricTestExample/src/Test1473.tsx | 29 ++-- FabricTestExample/src/Test1476.tsx | 108 +++++++----- FabricTestExample/src/Test1646.tsx | 12 +- FabricTestExample/src/Test1649.tsx | 158 ++++++++++-------- FabricTestExample/src/Test1683.tsx | 12 +- FabricTestExample/src/Test1726.tsx | 18 +- FabricTestExample/src/Test263.js | 24 +-- FabricTestExample/src/Test349.js | 28 ++-- FabricTestExample/src/Test364.js | 7 +- FabricTestExample/src/Test42.tsx | 15 +- FabricTestExample/src/Test528.js | 27 +-- FabricTestExample/src/Test550.js | 10 +- FabricTestExample/src/Test556.js | 38 +++-- FabricTestExample/src/Test564.js | 16 +- FabricTestExample/src/Test577.js | 6 +- FabricTestExample/src/Test593.tsx | 68 ++++---- FabricTestExample/src/Test619.js | 92 ++++++---- FabricTestExample/src/Test624.js | 14 +- FabricTestExample/src/Test640.js | 35 ++-- FabricTestExample/src/Test642.tsx | 10 +- FabricTestExample/src/Test645.js | 41 +++-- FabricTestExample/src/Test648.js | 11 +- FabricTestExample/src/Test649.js | 18 +- FabricTestExample/src/Test654.js | 29 ++-- FabricTestExample/src/Test658.js | 14 +- FabricTestExample/src/Test662.tsx | 47 +++--- FabricTestExample/src/Test691.js | 50 +++--- FabricTestExample/src/Test702.js | 25 ++- FabricTestExample/src/Test706.js | 16 +- FabricTestExample/src/Test713.js | 125 +++++++++----- FabricTestExample/src/Test726.js | 15 +- FabricTestExample/src/Test748.tsx | 37 +++- FabricTestExample/src/Test750.js | 6 +- FabricTestExample/src/Test758.tsx | 17 +- FabricTestExample/src/Test761.tsx | 52 +++--- FabricTestExample/src/Test779.tsx | 57 +++++-- FabricTestExample/src/Test780.tsx | 4 +- FabricTestExample/src/Test791.tsx | 84 +++++----- FabricTestExample/src/Test800.tsx | 18 +- FabricTestExample/src/Test817.tsx | 32 ++-- FabricTestExample/src/Test830.tsx | 11 +- FabricTestExample/src/Test831.tsx | 37 ++-- FabricTestExample/src/Test844.tsx | 12 +- FabricTestExample/src/Test852.tsx | 16 +- FabricTestExample/src/Test860.tsx | 17 +- FabricTestExample/src/Test861.tsx | 10 +- FabricTestExample/src/Test865.tsx | 18 +- FabricTestExample/src/Test881.tsx | 14 +- FabricTestExample/src/Test887.tsx | 28 ++-- FabricTestExample/src/Test898.tsx | 38 ++--- FabricTestExample/src/Test913.tsx | 31 ++-- FabricTestExample/src/Test999.tsx | 29 +++- FabricTestExample/src/TestFreeze.tsx | 16 +- TestsExample/.eslintrc.js | 8 + TestsExample/.prettierrc.js | 2 +- TestsExample/App.js | 2 +- TestsExample/__tests__/App.test.tsx | 2 +- TestsExample/index.js | 4 +- TestsExample/metro.config.js | 3 +- TestsExample/src/Test1017.tsx | 25 +-- TestsExample/src/Test1031.tsx | 42 +++-- TestsExample/src/Test1032.tsx | 17 +- TestsExample/src/Test1036.tsx | 10 +- TestsExample/src/Test1072.tsx | 4 +- TestsExample/src/Test1084.tsx | 20 ++- TestsExample/src/Test1091.tsx | 10 +- TestsExample/src/Test1096.tsx | 11 +- TestsExample/src/Test1097.tsx | 34 ++-- TestsExample/src/Test111.js | 12 +- TestsExample/src/Test1153.tsx | 13 +- TestsExample/src/Test1157.tsx | 18 +- TestsExample/src/Test1162.tsx | 25 +-- .../Test1166/AndroidDifferentScreenSearch.tsx | 18 +- .../AndroidSearchBarCustomization.tsx | 6 +- .../src/Test1166/AndroidSearchBarEvents.tsx | 18 +- .../src/Test1166/AndroidSearchTypes.tsx | 18 +- TestsExample/src/Test1166/index.tsx | 14 +- TestsExample/src/Test1188.tsx | 8 +- TestsExample/src/Test1190.tsx | 46 +++-- TestsExample/src/Test1198.tsx | 10 +- TestsExample/src/Test1204.tsx | 8 +- TestsExample/src/Test1209.tsx | 18 +- TestsExample/src/Test1213.tsx | 8 +- TestsExample/src/Test1214.tsx | 47 ++++-- TestsExample/src/Test1227.tsx | 14 +- TestsExample/src/Test1228.tsx | 15 +- TestsExample/src/Test1259.tsx | 4 +- TestsExample/src/Test1260.tsx | 43 +++-- TestsExample/src/Test1296.tsx | 29 ++-- TestsExample/src/Test1299.tsx | 18 +- TestsExample/src/Test1391.tsx | 30 ++-- TestsExample/src/Test1419.tsx | 72 ++++---- TestsExample/src/Test1473.tsx | 29 ++-- TestsExample/src/Test1476.tsx | 115 +++++++------ TestsExample/src/Test1509.tsx | 6 +- TestsExample/src/Test1539.tsx | 8 +- TestsExample/src/Test1646.tsx | 12 +- TestsExample/src/Test1649.tsx | 157 +++++++++-------- TestsExample/src/Test1683.tsx | 12 +- TestsExample/src/Test1726.tsx | 20 +-- TestsExample/src/Test1791.tsx | 22 +-- TestsExample/src/Test263.js | 24 +-- TestsExample/src/Test349.js | 28 ++-- TestsExample/src/Test364.js | 7 +- TestsExample/src/Test42.tsx | 43 +++-- TestsExample/src/Test528.js | 27 +-- TestsExample/src/Test550.js | 10 +- TestsExample/src/Test556.js | 26 +-- TestsExample/src/Test564.js | 16 +- TestsExample/src/Test577.js | 6 +- TestsExample/src/Test593.tsx | 68 ++++---- TestsExample/src/Test619.js | 92 ++++++---- TestsExample/src/Test624.js | 16 +- TestsExample/src/Test640.js | 35 ++-- TestsExample/src/Test642.tsx | 24 +-- TestsExample/src/Test645.js | 41 +++-- TestsExample/src/Test648.js | 11 +- TestsExample/src/Test649.js | 18 +- TestsExample/src/Test654.js | 29 ++-- TestsExample/src/Test658.js | 14 +- TestsExample/src/Test662.tsx | 47 +++--- TestsExample/src/Test691.js | 50 +++--- TestsExample/src/Test702.js | 25 ++- TestsExample/src/Test706.js | 16 +- TestsExample/src/Test713.js | 125 +++++++++----- TestsExample/src/Test726.js | 15 +- TestsExample/src/Test748.tsx | 37 +++- TestsExample/src/Test750.js | 6 +- TestsExample/src/Test758.tsx | 17 +- TestsExample/src/Test761.tsx | 52 +++--- TestsExample/src/Test779.tsx | 57 +++++-- TestsExample/src/Test780.tsx | 52 +++--- TestsExample/src/Test791.tsx | 84 +++++----- TestsExample/src/Test800.tsx | 17 +- TestsExample/src/Test817.tsx | 31 ++-- TestsExample/src/Test830.tsx | 11 +- TestsExample/src/Test831.tsx | 37 ++-- TestsExample/src/Test844.tsx | 12 +- TestsExample/src/Test852.tsx | 16 +- TestsExample/src/Test860.tsx | 96 +++++++---- TestsExample/src/Test861.tsx | 10 +- TestsExample/src/Test865.tsx | 18 +- TestsExample/src/Test881.tsx | 14 +- TestsExample/src/Test887.tsx | 28 ++-- TestsExample/src/Test898.tsx | 39 ++--- TestsExample/src/Test913.tsx | 31 ++-- TestsExample/src/Test999.tsx | 29 +++- TestsExample/src/TestFreeze.tsx | 16 +- TestsExample/tsconfig.json | 2 +- 188 files changed, 2844 insertions(+), 2212 deletions(-) diff --git a/FabricTestExample/.eslintrc.js b/FabricTestExample/.eslintrc.js index 187894b6af..cfc90f7103 100644 --- a/FabricTestExample/.eslintrc.js +++ b/FabricTestExample/.eslintrc.js @@ -1,4 +1,12 @@ module.exports = { root: true, extends: '@react-native', + overrides: [ + { + files: ['*.tsx', '*.js'], + rules: { + 'react-native/no-inline-styles': 'off', + }, + }, + ], }; diff --git a/FabricTestExample/.prettierrc.js b/FabricTestExample/.prettierrc.js index 2b540746a7..2ae7b381ed 100644 --- a/FabricTestExample/.prettierrc.js +++ b/FabricTestExample/.prettierrc.js @@ -1,7 +1,7 @@ module.exports = { arrowParens: 'avoid', bracketSameLine: true, - bracketSpacing: false, + bracketSpacing: true, singleQuote: true, trailingComma: 'all', }; diff --git a/FabricTestExample/App.js b/FabricTestExample/App.js index 26fdc433b3..6c272a5fa9 100644 --- a/FabricTestExample/App.js +++ b/FabricTestExample/App.js @@ -1,7 +1,7 @@ /* eslint-disable no-unused-vars */ import React from 'react'; -import {enableFreeze} from 'react-native-screens'; +import { enableFreeze } from 'react-native-screens'; import Test42 from './src/Test42'; import Test111 from './src/Test111'; diff --git a/FabricTestExample/index.js b/FabricTestExample/index.js index a850d031de..9b73932914 100644 --- a/FabricTestExample/index.js +++ b/FabricTestExample/index.js @@ -2,8 +2,8 @@ * @format */ -import {AppRegistry} from 'react-native'; +import { AppRegistry } from 'react-native'; import App from './App'; -import {name as appName} from './app.json'; +import { name as appName } from './app.json'; AppRegistry.registerComponent(appName, () => App); diff --git a/FabricTestExample/metro.config.js b/FabricTestExample/metro.config.js index 048f7b12bf..7825403986 100644 --- a/FabricTestExample/metro.config.js +++ b/FabricTestExample/metro.config.js @@ -24,8 +24,7 @@ module.exports = { resolver: { blacklistRE: exclusionList( modules.map( - (m) => - new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`), + m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`), ), ), diff --git a/FabricTestExample/src/Test1017.tsx b/FabricTestExample/src/Test1017.tsx index f297170fe4..486aac64dc 100644 --- a/FabricTestExample/src/Test1017.tsx +++ b/FabricTestExample/src/Test1017.tsx @@ -1,13 +1,13 @@ -import {NavigationContainer, RouteProp} from '@react-navigation/native'; +import { NavigationContainer, RouteProp } from '@react-navigation/native'; import { createStackNavigator, StackNavigationProp, TransitionPresets, } from '@react-navigation/stack'; import React from 'react'; -import {Alert, LogBox} from 'react-native'; -import {StyleSheet, Text, View, FlatList, Pressable} from 'react-native'; -import {ScrollView} from 'react-native-gesture-handler'; +import { Alert, LogBox } from 'react-native'; +import { StyleSheet, Text, View, FlatList, Pressable } from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; import { Header, @@ -36,7 +36,7 @@ LogBox.ignoreLogs([ const Stack = createStackNavigator(); -const dataset = Array.from({length: 100}, (_, i) => ({ +const dataset = Array.from({ length: 100 }, (_, i) => ({ title: `Title ${i}`, value: i, })); @@ -44,7 +44,7 @@ const dataset = Array.from({length: 100}, (_, i) => ({ const Screen: React.FC<{ route: RouteProp; navigation: StackNavigationProp; -}> = ({route, navigation}) => { +}> = ({ route, navigation }) => { for (let i = 0; i < 10 ** 3; i++) {} const isSecondScreen = route.name === Route.SecondScreen; @@ -58,7 +58,7 @@ const Screen: React.FC<{ const renderItem = (item: DataItem) => ( @@ -75,8 +75,8 @@ const Screen: React.FC<{ item.value.toString()} - renderItem={({item}) => renderItem(item)} + keyExtractor={item => item.value.toString()} + renderItem={({ item }) => renderItem(item)} ItemSeparatorComponent={() => } ListHeaderComponent={!isSecondScreen && Header} ListHeaderComponentStyle={styles.headerWrapper} @@ -91,16 +91,17 @@ const Screen: React.FC<{ const App: React.FC = () => { return ( - + diff --git a/FabricTestExample/src/Test1031.tsx b/FabricTestExample/src/Test1031.tsx index 74a874dfc0..cb9e7c3a8d 100644 --- a/FabricTestExample/src/Test1031.tsx +++ b/FabricTestExample/src/Test1031.tsx @@ -1,36 +1,50 @@ import * as React from 'react'; -import {Button} from 'react-native'; -import {NavigationContainer, ParamListBase} from '@react-navigation/native'; -import {createNativeStackNavigator, NativeStackNavigationProp, useHeaderHeight} from 'react-native-screens/native-stack'; +import { Button } from 'react-native'; +import { NavigationContainer, ParamListBase } from '@react-navigation/native'; +import { + createNativeStackNavigator, + NativeStackNavigationProp, + useHeaderHeight, +} from 'react-native-screens/native-stack'; const Stack = createNativeStackNavigator(); export default function App() { return ( - + - + ); } -function First({navigation}: {navigation: NativeStackNavigationProp}) { +function First({ + navigation, +}: { + navigation: NativeStackNavigationProp; +}) { console.log(useHeaderHeight()); return ( - + }} + /> ); }; const Details = () => { return ( - - + + ); }; const App = () => { return ( - - JS Navigation + + + JS Navigation + - - + + - Native Navigation + + Native Navigation + - - - + + + diff --git a/TestsExample/src/Test1227.tsx b/TestsExample/src/Test1227.tsx index 98d74bff0b..4e21c9f9e6 100644 --- a/TestsExample/src/Test1227.tsx +++ b/TestsExample/src/Test1227.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import {Button, View} from 'react-native'; -import {NavigationContainer, ParamListBase} from '@react-navigation/native'; +import { Button, View } from 'react-native'; +import { NavigationContainer, ParamListBase } from '@react-navigation/native'; import { createNativeStackNavigator, NativeStackNavigationProp, @@ -16,12 +16,12 @@ export default function App() { @@ -34,7 +34,7 @@ function First({ navigation: NativeStackNavigationProp; }) { return ( - +