Skip to content

Commit

Permalink
chore: update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Mar 22, 2020
1 parent 043924c commit 179b631
Show file tree
Hide file tree
Showing 59 changed files with 198 additions and 201 deletions.
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(api) {
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
Expand Down
10 changes: 5 additions & 5 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const modules = ['@expo/vector-icons']
// List all packages under `packages/`
.readdirSync(packages)
// Ignore hidden files such as .DS_Store
.filter(p => !p.startsWith('.'))
.map(p => {
.filter((p) => !p.startsWith('.'))
.map((p) => {
const pak = JSON.parse(
fs.readFileSync(path.join(packages, p, 'package.json'), 'utf8')
);
Expand Down Expand Up @@ -50,9 +50,9 @@ module.exports = {
blacklistRE: blacklist(
fs
.readdirSync(packages)
.map(p => path.join(packages, p))
.map((p) => path.join(packages, p))
.map(
it => new RegExp(`^${escape(path.join(it, 'node_modules'))}\\/.*$`)
(it) => new RegExp(`^${escape(path.join(it, 'node_modules'))}\\/.*$`)
)
),

Expand All @@ -65,7 +65,7 @@ module.exports = {
},

server: {
enhanceMiddleware: middleware => {
enhanceMiddleware: (middleware) => {
return (req, res, next) => {
// When an asset is imported outside the project root, it has wrong path on Android
// This happens for the back button in stack, so we fix the path to correct one
Expand Down
4 changes: 2 additions & 2 deletions example/src/Screens/BottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function BottomTabsScreen() {
return (
<BottomTabs.Navigator
screenOptions={{
tabBarButton: props => <TouchableBounce {...props} />,
tabBarButton: (props) => <TouchableBounce {...props} />,
}}
>
<BottomTabs.Screen
Expand All @@ -38,7 +38,7 @@ export default function BottomTabsScreen() {
tabBarIcon: getTabBarIcon('file-document-box'),
}}
>
{props => <SimpleStackScreen {...props} headerMode="none" />}
{(props) => <SimpleStackScreen {...props} headerMode="none" />}
</BottomTabs.Screen>
<BottomTabs.Screen
name="Chat"
Expand Down
8 changes: 5 additions & 3 deletions example/src/Screens/DynamicTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function BottomTabsScreen() {

return (
<BottomTabs.Navigator>
{tabs.map(i => (
{tabs.map((i) => (
<BottomTabs.Screen
key={i}
name={`tab-${i}`}
Expand All @@ -29,12 +29,14 @@ export default function BottomTabsScreen() {
{() => (
<View style={styles.container}>
<Title>Tab {i}</Title>
<Button onPress={() => setTabs(tabs => [...tabs, tabs.length])}>
<Button onPress={() => setTabs((tabs) => [...tabs, tabs.length])}>
Add a tab
</Button>
<Button
onPress={() =>
setTabs(tabs => (tabs.length > 1 ? tabs.slice(0, -1) : tabs))
setTabs((tabs) =>
tabs.length > 1 ? tabs.slice(0, -1) : tabs
)
}
>
Remove a tab
Expand Down
2 changes: 1 addition & 1 deletion example/src/Screens/MaterialBottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function MaterialBottomTabsScreen() {
tabBarColor: '#C9E7F8',
}}
>
{props => <SimpleStackScreen {...props} headerMode="none" />}
{(props) => <SimpleStackScreen {...props} headerMode="none" />}
</MaterialBottomTabs.Screen>
<MaterialBottomTabs.Screen
name="Chat"
Expand Down
5 changes: 1 addition & 4 deletions example/src/Shared/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ export default function Chat(props: Partial<ScrollViewProps>) {
styles.input,
{ backgroundColor: colors.card, color: colors.text },
]}
placeholderTextColor={Color(colors.text)
.alpha(0.5)
.rgb()
.string()}
placeholderTextColor={Color(colors.text).alpha(0.5).rgb().string()}
placeholder="Write a message"
underlineColorAndroid="transparent"
/>
Expand Down
5 changes: 1 addition & 4 deletions example/src/Shared/NewsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export default function NewsFeed(props: Props) {
<Card style={styles.card}>
<TextInput
placeholder="What's on your mind?"
placeholderTextColor={Color(colors.text)
.alpha(0.5)
.rgb()
.string()}
placeholderTextColor={Color(colors.text).alpha(0.5).rgb().string()}
style={styles.input}
/>
</Card>
Expand Down
8 changes: 4 additions & 4 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default function App() {
<NavigationContainer
ref={containerRef}
initialState={initialState}
onStateChange={state =>
onStateChange={(state) =>
AsyncStorage.setItem(
NAVIGATION_PERSISTENCE_KEY,
JSON.stringify(state)
Expand Down Expand Up @@ -298,12 +298,12 @@ export default function App() {
theme.dark ? 'light' : 'dark'
);

setTheme(t => (t.dark ? DefaultTheme : DarkTheme));
setTheme((t) => (t.dark ? DefaultTheme : DarkTheme));
}}
/>
<Divider />
{(Object.keys(SCREENS) as (keyof typeof SCREENS)[]).map(
name => (
(name) => (
<List.Item
key={name}
title={SCREENS[name].title}
Expand All @@ -315,7 +315,7 @@ export default function App() {
)}
</Stack.Screen>
{(Object.keys(SCREENS) as (keyof typeof SCREENS)[]).map(
name => (
(name) => (
<Stack.Screen
key={name}
name={name}
Expand Down
6 changes: 3 additions & 3 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const node_modules = path.resolve(__dirname, '..', 'node_modules');
const packages = path.resolve(__dirname, '..', 'packages');

module.exports = async function(env, argv) {
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);

config.context = path.resolve(__dirname, '..');
Expand All @@ -20,7 +20,7 @@ module.exports = async function(env, argv) {
});

config.resolve.plugins = config.resolve.plugins.filter(
p => !(p instanceof ModuleScopePlugin)
(p) => !(p instanceof ModuleScopePlugin)
);

Object.assign(config.resolve.alias, {
Expand All @@ -30,7 +30,7 @@ module.exports = async function(env, argv) {
'@expo/vector-icons': path.resolve(node_modules, '@expo/vector-icons'),
});

fs.readdirSync(packages).forEach(name => {
fs.readdirSync(packages).forEach((name) => {
config.resolve.alias[`@react-navigation/${name}`] = path.resolve(
packages,
name,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"husky": "^4.2.3",
"jest": "^25.1.0",
"lerna": "^3.20.2",
"prettier": "^1.19.1",
"prettier": "^2.0.1",
"typescript": "^3.7.5"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/bottom-tabs/src/views/BottomTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default function BottomTabBar({
const handleLayout = (e: LayoutChangeEvent) => {
const { height, width } = e.nativeEvent.layout;

setLayout(layout => {
setLayout((layout) => {
if (height === layout.height && width === layout.width) {
return layout;
} else {
Expand Down
4 changes: 1 addition & 3 deletions packages/bottom-tabs/src/views/BottomTabItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ export default function BottomTabBarItem({

const inactiveTintColor =
customInactiveTintColor === undefined
? Color(colors.text)
.mix(Color(colors.card), 0.5)
.hex()
? Color(colors.text).mix(Color(colors.card), 0.5).hex()
: customInactiveTintColor;

const renderLabel = ({ focused }: { focused: boolean }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/bottom-tabs/src/views/SafeAreaProviderCompat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Props = {
export default function SafeAreaProviderCompat({ children }: Props) {
return (
<SafeAreaConsumer>
{insets => {
{(insets) => {
if (insets) {
// If we already have insets, don't wrap the stack in another safe area provider
// This avoids an issue with updates at the cost of potentially incorrect values
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/src/createCompatNavigatorFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function createCompatNavigatorFactory<
function Navigator({ screenProps }: { screenProps?: unknown }) {
const screens = React.useMemo(
() =>
routeNames.map(name => {
routeNames.map((name) => {
let getScreenComponent: () => CompatScreenType<NavigationPropType>;

let initialParams;
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/src/useCompatNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function useCompatNavigation<
const route = useRoute();

const isFirstRouteInParent = useNavigationState(
state => state.routes[0].key === route.key
(state) => state.routes[0].key === route.key
);

const context = React.useRef<Record<string, any>>({});
Expand Down
5 changes: 3 additions & 2 deletions packages/compat/src/withNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export default function withNavigation<
return <Comp ref={onRef} navigation={navigation} {...rest} />;
};

WrappedComponent.displayName = `withNavigation(${Comp.displayName ||
Comp.name})`;
WrappedComponent.displayName = `withNavigation(${
Comp.displayName || Comp.name
})`;

return WrappedComponent;
}
5 changes: 3 additions & 2 deletions packages/compat/src/withNavigationFocus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export default function withNavigationFocus<
return <Comp ref={onRef} isFocused={isFocused} {...rest} />;
};

WrappedComponent.displayName = `withNavigationFocus(${Comp.displayName ||
Comp.name})`;
WrappedComponent.displayName = `withNavigationFocus(${
Comp.displayName || Comp.name
})`;

return WrappedComponent;
}
6 changes: 3 additions & 3 deletions packages/core/src/BaseNavigationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const getPartialState = (
return {
...partialState,
stale: true,
routes: state.routes.map(route => {
routes: state.routes.map((route) => {
if (route.state === undefined) {
return route as Route<string> & {
state?: PartialState<NavigationState>;
Expand Down Expand Up @@ -156,15 +156,15 @@ const BaseNavigationContainer = React.forwardRef(
throw new Error(NOT_INITIALIZED_ERROR);
}

listeners[0](navigation => navigation.dispatch(action));
listeners[0]((navigation) => navigation.dispatch(action));
};

const canGoBack = () => {
if (listeners[0] == null) {
return false;
}

const { result, handled } = listeners[0](navigation =>
const { result, handled } = listeners[0]((navigation) =>
navigation.canGoBack()
);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/SceneView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function SceneView<

const getCurrentState = React.useCallback(() => {
const state = getState();
const currentRoute = state.routes.find(r => r.key === route.key);
const currentRoute = state.routes.find((r) => r.key === route.key);

return currentRoute ? currentRoute.state : undefined;
}, [getState, route.key]);
Expand All @@ -62,7 +62,7 @@ export default function SceneView<

setState({
...state,
routes: state.routes.map(r =>
routes: state.routes.map((r) =>
r.key === route.key ? { ...r, state: child } : r
),
});
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/BaseNavigationContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ it('handle dispatching with ref', () => {

return (
<React.Fragment>
{state.routes.map(route => descriptors[route.key].render())}
{state.routes.map((route) => descriptors[route.key].render())}
</React.Fragment>
);
};
Expand Down Expand Up @@ -220,7 +220,7 @@ it('handle resetting state with ref', () => {

return (
<React.Fragment>
{state.routes.map(route => descriptors[route.key].render())}
{state.routes.map((route) => descriptors[route.key].render())}
</React.Fragment>
);
};
Expand Down Expand Up @@ -371,7 +371,7 @@ it('emits state events when the state changes', () => {

return (
<React.Fragment>
{state.routes.map(route => descriptors[route.key].render())}
{state.routes.map((route) => descriptors[route.key].render())}
</React.Fragment>
);
};
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/__tests__/__fixtures__/MockRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function MockRouter(options: DefaultRouterOptions) {
key: String(MockRouterKey.current++),
index,
routeNames,
routes: routeNames.map(name => ({
routes: routeNames.map((name) => ({
name,
key: name,
params: routeParamList[name],
Expand All @@ -43,9 +43,9 @@ export default function MockRouter(options: DefaultRouterOptions) {
}

const routes = state.routes
.filter(route => routeNames.includes(route.name))
.filter((route) => routeNames.includes(route.name))
.map(
route =>
(route) =>
({
...route,
key: route.key || `${route.name}-${MockRouterKey.current++}`,
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function MockRouter(options: DefaultRouterOptions) {
},

getStateForRouteNamesChange(state, { routeNames }) {
const routes = state.routes.filter(route =>
const routes = state.routes.filter((route) =>
routeNames.includes(route.name)
);

Expand All @@ -86,7 +86,7 @@ export default function MockRouter(options: DefaultRouterOptions) {
},

getStateForRouteFocus(state, key) {
const index = state.routes.findIndex(r => r.key === key);
const index = state.routes.findIndex((r) => r.key === key);

if (index === -1 || index === state.index) {
return state;
Expand All @@ -105,7 +105,7 @@ export default function MockRouter(options: DefaultRouterOptions) {

case 'NAVIGATE': {
const index = state.routes.findIndex(
route => route.name === action.payload.name
(route) => route.name === action.payload.name
);

if (index === -1) {
Expand Down
Loading

0 comments on commit 179b631

Please sign in to comment.