Skip to content

Commit

Permalink
refact: unified prettier config across repository (#2250)
Browse files Browse the repository at this point in the history
## Description

This PR intents to unify prettier config across example apps. Inititally
I wanted to copy the configuration but It's more convenient to just use
the one from the root (by not overriding it).

## Changes

- removed per project `.prettierrc` files
- fixed eslint export syntax in Example
- formatted affected files

<!--

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->

<!--
## Test code and steps to reproduce

Please include code that can be used to test this change and short
description how this example should work.
This snippet should be as minimal as possible and ready to be pasted
into editor (don't exclude exports or remove "not important" parts of
reproduction example)
-->

## Checklist

- [x] Ensured that CI passes
  • Loading branch information
alduzy authored Jul 18, 2024
1 parent 8013dc8 commit c70f23b
Show file tree
Hide file tree
Showing 80 changed files with 422 additions and 393 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module.exports = {
'react-native-screens/gesture-handler',
],
'import/ignore': [
'node_modules/react-native/index\\.js$',
'node_modules/react-native/index\\.js$',
'react-native/Libraries/Utilities/codegenNativeComponent.*',
'react-native/Libraries/Types/CodegenTypes.*'
'react-native/Libraries/Types/CodegenTypes.*',
],
'import/resolver': {
node: {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-archs-consistency.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Test consistency between Paper & Fabric
on:
on:
pull_request:
branches:
- main
paths:
paths:
- src/fabric/**
- android/src/paper/java/com/facebook/react/viewmanagers/**
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
bracketSameLine: true,
bracketSpacing: true,
singleQuote: true,
trailingComma: 'es5',
trailingComma: 'all',
};
2 changes: 1 addition & 1 deletion .watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
2 changes: 1 addition & 1 deletion Example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.export = {
module.exports = {
root: true,
extends: '@react-native',
};
6 changes: 0 additions & 6 deletions Example/.prettierrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion Example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
1 change: 0 additions & 1 deletion Example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
"name": "ScreensExample",
"displayName": "ScreensExample"
}

24 changes: 12 additions & 12 deletions Example/e2e/examplesTests/bottomTabs.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ describe('Bottom tabs and native stack', () => {

it('should go to main screen and back', async () => {
await expect(
element(by.id('root-screen-example-BottomTabsAndStack'))
element(by.id('root-screen-example-BottomTabsAndStack')),
).toBeVisible();
await element(by.id('root-screen-example-BottomTabsAndStack')).tap();

await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toBeVisible();
});

it('should go to details screen', async () => {
await element(by.id('root-screen-example-BottomTabsAndStack')).tap();
await element(by.id('bottom-tabs-A-more-details-button')).tap();
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 1');
});

it('should go to details screen and back', async () => {
await element(by.id('root-screen-example-BottomTabsAndStack')).tap();
await element(by.id('bottom-tabs-A-more-details-button')).tap();
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 1');
if (device.getPlatform() === 'ios') {
await element(by.type('_UIButtonBarButton')).tap();
} else {
await device.pressBack();
}
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 0');
});

Expand All @@ -45,12 +45,12 @@ describe('Bottom tabs and native stack', () => {

await element(by.id('bottom-tabs-B-tab')).tap();
await expect(element(by.id('bottom-tabs-B-header-right-id'))).toHaveText(
'B'
'B',
);

await element(by.id('bottom-tabs-A-tab')).tap();
await expect(element(by.id('bottom-tabs-A-header-right-id'))).toHaveText(
'A'
'A',
);
});

Expand All @@ -59,12 +59,12 @@ describe('Bottom tabs and native stack', () => {

await element(by.id('bottom-tabs-A-more-details-button')).tap();
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 1');

await element(by.id('bottom-tabs-A-tab')).multiTap(2);
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 0');
});

Expand All @@ -74,17 +74,17 @@ describe('Bottom tabs and native stack', () => {
await element(by.id('bottom-tabs-A-more-details-button')).tap();
await element(by.id('bottom-tabs-A-more-details-button')).tap();
await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 2');

await element(by.id('bottom-tabs-B-tab')).tap();
await expect(
element(by.id('bottom-tabs-B-more-details-button'))
element(by.id('bottom-tabs-B-more-details-button')),
).toHaveLabel('More details 0');
await element(by.id('bottom-tabs-A-tab')).tap();

await expect(
element(by.id('bottom-tabs-A-more-details-button'))
element(by.id('bottom-tabs-A-more-details-button')),
).toHaveLabel('More details 2');
});
});
38 changes: 19 additions & 19 deletions Example/e2e/examplesTests/events.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ const pressBack = async () => {
const awaitClassicalEventBehavior = async () => {
if (device.getPlatform() === 'ios') {
await expect(
element(by.text('9. Chats | transitionStart | closing'))
element(by.text('9. Chats | transitionStart | closing')),
).toExist();
await expect(
element(by.text('10. Privacy | transitionStart | closing'))
element(by.text('10. Privacy | transitionStart | closing')),
).toExist();
await expect(
element(by.text('11. Main | transitionStart | opening'))
element(by.text('11. Main | transitionStart | opening')),
).toExist();
await expect(
element(by.text('12. Chats | transitionEnd | closing'))
element(by.text('12. Chats | transitionEnd | closing')),
).toExist();
await expect(
element(by.text('13. Privacy | transitionEnd | closing'))
element(by.text('13. Privacy | transitionEnd | closing')),
).toExist();
await expect(element(by.text('14. Privacy | beforeRemove'))).toExist();
await expect(element(by.text('15. Chats | beforeRemove'))).toExist();
await expect(
element(by.text('16. Main | transitionEnd | opening'))
element(by.text('16. Main | transitionEnd | opening')),
).toExist();
} else {
await expect(element(by.text('9. Privacy | beforeRemove'))).toExist();
await expect(element(by.text('10. Chats | beforeRemove'))).toExist();
await expect(
element(by.text('11. Main | transitionStart | opening'))
element(by.text('11. Main | transitionStart | opening')),
).toExist();
await expect(
element(by.text('12. Main | transitionEnd | opening'))
element(by.text('12. Main | transitionEnd | opening')),
).toExist();
}
};
Expand All @@ -64,10 +64,10 @@ describe('Events', () => {
await element(by.id('root-screen-playground-Events')).tap();

await expect(
element(by.text('1. Main | transitionStart | opening'))
element(by.text('1. Main | transitionStart | opening')),
).toExist();
await expect(
element(by.text('2. Main | transitionEnd | opening'))
element(by.text('2. Main | transitionEnd | opening')),
).toExist();
});

Expand All @@ -79,7 +79,7 @@ describe('Events', () => {
await element(by.type('_UIButtonBarButton')).tap();
} else {
await element(
by.type('androidx.appcompat.widget.AppCompatImageButton')
by.type('androidx.appcompat.widget.AppCompatImageButton'),
).tap();
}

Expand All @@ -98,7 +98,7 @@ describe('Events', () => {
await element(by.type('_UIButtonBarButton')).tap();
} else {
await element(
by.type('androidx.appcompat.widget.AppCompatImageButton')
by.type('androidx.appcompat.widget.AppCompatImageButton'),
).tap();
}

Expand All @@ -114,22 +114,22 @@ describe('Events', () => {
await element(by.id('events-go-to-chats')).tap();

await expect(
element(by.text('3. Main | transitionStart | closing'))
element(by.text('3. Main | transitionStart | closing')),
).toExist();
await expect(
element(by.text('4. Chats | transitionStart | opening'))
element(by.text('4. Chats | transitionStart | opening')),
).toExist();
await expect(
element(by.text('5. Privacy | transitionStart | opening'))
element(by.text('5. Privacy | transitionStart | opening')),
).toExist();
await expect(
element(by.text('6. Main | transitionEnd | closing'))
element(by.text('6. Main | transitionEnd | closing')),
).toExist();
await expect(
element(by.text('7. Chats | transitionEnd | opening'))
element(by.text('7. Chats | transitionEnd | opening')),
).toExist();
await expect(
element(by.text('8. Privacy | transitionEnd | opening'))
element(by.text('8. Privacy | transitionEnd | opening')),
).toExist();
});

Expand All @@ -145,7 +145,7 @@ describe('Events', () => {
await element(by.type('_UIButtonBarButton')).tap();
} else {
await element(
by.type('androidx.appcompat.widget.AppCompatImageButton')
by.type('androidx.appcompat.widget.AppCompatImageButton'),
).tap();
}

Expand Down
8 changes: 4 additions & 4 deletions Example/e2e/examplesTests/simpleNativeStack.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ describe('Simple Native Stack', () => {

it('should go to main screen', async () => {
await expect(
element(by.id('root-screen-example-SimpleNativeStack'))
element(by.id('root-screen-example-SimpleNativeStack')),
).toBeVisible();
await element(by.id('root-screen-example-SimpleNativeStack')).tap();
await expect(
element(by.id('simple-native-stack-go-to-detail'))
element(by.id('simple-native-stack-go-to-detail')),
).toBeVisible();
});

it('should go to detail screen', async () => {
await element(by.id('simple-native-stack-go-to-detail')).tap();
await expect(
element(by.id('simple-native-stack-detail-go-back'))
element(by.id('simple-native-stack-detail-go-back')),
).toBeVisible();
});

it('should go back to main screen', async () => {
await element(by.id('simple-native-stack-detail-go-back')).tap();
await expect(
element(by.id('simple-native-stack-go-to-detail'))
element(by.id('simple-native-stack-go-to-detail')),
).toBeVisible();
});
});
14 changes: 7 additions & 7 deletions Example/e2e/examplesTests/stackPresentation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ describe('Simple Stack Presentation', () => {

it('should go to main screen', async () => {
await expect(
element(by.id('root-screen-example-StackPresentation'))
element(by.id('root-screen-example-StackPresentation')),
).toBeVisible();
await element(by.id('root-screen-example-StackPresentation')).tap();
await expect(
element(by.id('stack-presentation-root-scroll-view'))
element(by.id('stack-presentation-root-scroll-view')),
).toBeVisible();
});

it('should push form screen', async () => {
await element(by.id('stack-presentation-push-button')).tap();
await expect(
element(by.id('stack-presentation-form-screen-go-back-button'))
element(by.id('stack-presentation-form-screen-go-back-button')),
).toBeVisible();
await element(by.id('stack-presentation-form-screen-go-back-button')).tap();
await expect(
element(by.id('stack-presentation-root-scroll-view'))
element(by.id('stack-presentation-root-scroll-view')),
).toBeVisible();
});

it('should open modal', async () => {
await element(by.id('stack-presentation-modal-button')).tap();
await expect(
element(by.id('stack-presentation-modal-screen-go-back-button'))
element(by.id('stack-presentation-modal-screen-go-back-button')),
).toBeVisible();
await element(
by.id('stack-presentation-modal-screen-go-back-button')
by.id('stack-presentation-modal-screen-go-back-button'),
).tap();
await expect(
element(by.id('stack-presentation-root-scroll-view'))
element(by.id('stack-presentation-root-scroll-view')),
).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion Example/e2e/firstTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Example', () => {

it('should have examples buttons', async () => {
const exampleNames = Object.keys(SCREENS).filter(
name => SCREENS[name].type === 'example'
name => SCREENS[name].type === 'example',
);
for (const name of exampleNames) {
await expect(element(by.id(`root-screen-example-${name}`))).toBeVisible();
Expand Down
8 changes: 4 additions & 4 deletions Example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const config = {
blockList: exclusionList(
modules.map(
m =>
new RegExp(`^${escape(path.join(rnsRoot, 'node_modules', m))}\\/.*$`)
)
new RegExp(`^${escape(path.join(rnsRoot, 'node_modules', m))}\\/.*$`),
),
),

extraNodeModules: modules.reduce((acc, name) => {
Expand Down Expand Up @@ -65,15 +65,15 @@ const config = {
__dirname,
'node_modules',
moduleName,
`index${ext}`
`index${ext}`,
);

const possibleSrcPath = path.join(
__dirname,
'node_modules',
moduleName,
'src',
`index${ext}`
`index${ext}`,
);

if (fs.existsSync(possiblePath)) {
Expand Down
7 changes: 0 additions & 7 deletions FabricExample/.prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions FabricExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Installing & running application

Before running application you need to install all dependencies. To do that:

- In project's root directory run `yarn install`
- In FabricExample directory run `yarn install`

Expand Down
2 changes: 1 addition & 1 deletion FabricExample/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals';
import { it } from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
Expand Down
Loading

0 comments on commit c70f23b

Please sign in to comment.