Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit eeef827

Browse files
committed
🎨 (src) fix eslint errors
1 parent 1656b95 commit eeef827

20 files changed

Lines changed: 172 additions & 270 deletions

src/FullScreenPortal.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ route: /api/full-screen-portal
1616

1717
## Properties
1818

19-
### `fullScreenStack: IStreamListener<IStop[]>`
19+
### `fullScreenStack: IStreamListener<StopInterface[]>`
2020

2121
MobX Strem Listener of list of React Gondola full screen Stops. This stream is observed by MobX and fires the rendering of the full screen stack in the `FullScreenPortal.render` method.
2222

@@ -25,10 +25,10 @@ MobX Strem Listener of list of React Gondola full screen Stops. This stream is o
2525
Wrap your application main canal with `FullScreenPortal`. `FullScreenPortal` must appear at the top of your tree in order to render full screen pages.
2626

2727
```tsx
28-
import React, { Component } from "react";
29-
import { FullScreenPortal } from "react-gondola";
28+
import React, { Component } from 'react';
29+
import { FullScreenPortal } from 'react-gondola';
3030

31-
import { MainCanal } from "./canals/MainCanal";
31+
import { MainCanal } from './canals/MainCanal';
3232

3333
export default class App extends Component {
3434
render() {

src/FullScreenPortal.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { fromStream } from 'mobx-utils';
55
import { Navigation } from './Navigation';
66

77
export class FullScreenPortal extends ReactComponent {
8-
fullScreenStack = fromStream(
9-
Navigation.instance.fullScreenDelegate.fullSceenStack$
10-
);
8+
fullScreenStack = fromStream(Navigation.instance.fullScreenDelegate.fullSceenStack$);
119

1210
render() {
1311
return (
@@ -18,11 +16,9 @@ export class FullScreenPortal extends ReactComponent {
1816
if (this.fullScreenStack.current) {
1917
return (
2018
this.fullScreenStack.current &&
21-
this.fullScreenStack.current.map(
22-
({ Component, name, isAuthorized }) => (
23-
<Component isAuthorized={isAuthorized} key={name} />
24-
)
25-
)
19+
this.fullScreenStack.current.map(({ Component, name, isAuthorized }) => (
20+
<Component isAuthorized={isAuthorized} key={name} />
21+
))
2622
);
2723
}
2824
return null;

src/Navigation/BackContext.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createContext } from 'react';
22
import { Observable } from 'rxjs';
3-
import { IBackEvent } from './BackHandlerDelegate';
3+
import { BackEvent } from './BackHandlerDelegate';
44
import { Navigation } from './Navigation';
55

6-
export interface IBackContext {
7-
back$: Observable<IBackEvent>;
6+
export interface BackContextInterface {
7+
back$: Observable<BackEvent>;
88
}
99

10-
export const BackContext = createContext<IBackContext>(
10+
export const BackContext = createContext<BackContextInterface>(
1111
Navigation.instance.backHandlerDelegate.defaultBackContext
1212
);

src/Navigation/BackHandlerDelegate.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BackHandler } from 'react-native';
22
import { fromEventPattern, Observable } from 'rxjs';
33
import { share } from 'rxjs/operators';
44

5-
export interface IBackEvent {
5+
export interface BackEvent {
66
target: string | null;
77
}
88

@@ -16,10 +16,10 @@ export class BackHandlerDelegate {
1616
* See https://facebook.github.io/react-native/docs/backhandler.html.
1717
* @param handler
1818
*/
19-
private addEventListener = (handler: (event: IBackEvent) => void) => {
19+
private addEventListener = (handler: (event: BackEvent) => void) => {
2020
BackHandler.addEventListener('hardwareBackPress', () => {
2121
handler({
22-
target: null
22+
target: null,
2323
});
2424
if (this.onBackCallback) {
2525
this.onBackCallback();
@@ -30,9 +30,9 @@ export class BackHandlerDelegate {
3030
});
3131
};
3232

33-
private back$: Observable<IBackEvent> = fromEventPattern<IBackEvent>(
34-
this.addEventListener
35-
).pipe(share());
33+
private back$: Observable<BackEvent> = fromEventPattern<BackEvent>(this.addEventListener).pipe(
34+
share()
35+
);
3636

3737
private onBackCallback?: () => any;
3838
setOnBackCallback = (cb: () => any) => {

src/Navigation/FullScreenDelegate.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
import { Subject, Observable } from 'rxjs';
22
import { mergeAll, map, scan } from 'rxjs/operators';
3-
import { IStop } from './Stop';
3+
import { StopInterface } from './Stop';
44

5-
type Stack = IStop[];
5+
type Stack = StopInterface[];
66

7-
interface IFullScreenStackProperties {
7+
interface FullScreenStackProperties {
88
canalId: string;
99
fullScreenStack: Stack;
1010
}
1111

12-
interface IFullScreenStackMap {
12+
interface FullScreenStackMap {
1313
[canalId: string]: Stack;
1414
}
1515

1616
export class FullScreenDelegate {
17-
canalsFullScreenStackProperties$ = new Subject<
18-
Observable<IFullScreenStackProperties>
19-
>();
17+
canalsFullScreenStackProperties$ = new Subject<Observable<FullScreenStackProperties>>();
2018

21-
fullSceenStack$: Observable<
22-
Stack
23-
> = this.canalsFullScreenStackProperties$.pipe(
19+
fullSceenStack$: Observable<Stack> = this.canalsFullScreenStackProperties$.pipe(
2420
mergeAll(),
2521
scan(
2622
(
27-
fullScreenStackMap: IFullScreenStackMap,
28-
fullScreenStackProperties: IFullScreenStackProperties
23+
fullScreenStackMap: FullScreenStackMap,
24+
fullScreenStackProperties: FullScreenStackProperties
2925
) => ({
3026
...fullScreenStackMap,
31-
[fullScreenStackProperties.canalId]:
32-
fullScreenStackProperties.fullScreenStack
27+
[fullScreenStackProperties.canalId]: fullScreenStackProperties.fullScreenStack,
3328
}),
3429
{}
3530
),
36-
map((fullScreenStackMap: IFullScreenStackMap) =>
31+
map((fullScreenStackMap: FullScreenStackMap) =>
3732
Object.keys(fullScreenStackMap).reduce(
3833
(fullScreenStack: Stack, canalId: string) =>
3934
fullScreenStack.concat(fullScreenStackMap[canalId]),

src/Navigation/Stop.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ComponentType } from 'react';
22

3-
export interface IStop {
4-
Component: ComponentType<IStopComponentProps>;
3+
export interface StopInterface {
4+
Component: ComponentType<StopComponentProps>;
55
isFullScreen?: boolean;
66
name: string;
77
isAuthorized: boolean;
88
}
99

10-
export interface IStopComponentProps {
10+
export interface StopComponentProps {
1111
isAuthorized: boolean;
1212
}

src/Navigation/__tests__/BackHandlerDelegate.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import BackHandler from 'react-native/Libraries/Utilities/__mocks__/BackHandler'
22
import { BackHandlerDelegate } from '../BackHandlerDelegate';
33

44
jest.mock('react-native', () => ({
5-
BackHandler: require.requireActual(
6-
'react-native/Libraries/Utilities/__mocks__/BackHandler'
7-
)
5+
BackHandler: require.requireActual('react-native/Libraries/Utilities/__mocks__/BackHandler'),
86
}));
97

108
describe('BackHandlerDelegate', () => {

src/StopValidator.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { ComponentType } from 'react';
22

33
import { TransitionComponentType } from './transitions/Transition';
44

5-
export interface IStop<T extends string> {
5+
export interface StopInterface<T extends string> {
66
name: T;
77
Component: ComponentType<any>;
88
isFullScreen?: boolean;
@@ -12,21 +12,16 @@ export interface IStop<T extends string> {
1212
}
1313

1414
export class StopValidator {
15-
static validate(stop: IStop<string>) {
15+
static validate(stop: StopInterface<string>) {
1616
if (!stop.name || typeof stop.name !== 'string') {
1717
throw new Error('ERR_INVALID_NAME');
1818
}
19-
if (
20-
!(
21-
React.isValidElement(stop.Component) ||
22-
typeof stop.Component === 'function'
23-
)
24-
) {
19+
if (!(React.isValidElement(stop.Component) || typeof stop.Component === 'function')) {
2520
throw new Error('ERR_INVALID_COMPONENT');
2621
}
2722
}
2823

29-
static validateList(stops: Array<IStop<string>>) {
24+
static validateList(stops: StopInterface<string>[]) {
3025
for (let index = 0; index < stops.length; index++) {
3126
const stop = stops[index];
3227
try {

src/__tests__/createCanal.test.tsx

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { stopCreator } from './utils/stopCreator';
77
import { createCanal } from '../createCanal';
88
import { Subject } from 'rxjs';
99
import { BackContext } from '../Navigation/BackContext';
10-
import { IBackEvent } from '../Navigation/BackHandlerDelegate';
10+
import { BackEvent } from '../Navigation/BackHandlerDelegate';
1111

1212
describe('createCanal', () => {
1313
it('throws an error if first arg is not a Component', () => {
@@ -41,21 +41,13 @@ describe('createCanal', () => {
4141
});
4242

4343
it('renders only the first page if all authorizations are given but the one for the second page', () => {
44-
const Canal = createCanal([
45-
stopCreator('a'),
46-
stopCreator('b'),
47-
stopCreator('c')
48-
]);
44+
const Canal = createCanal([stopCreator('a'), stopCreator('b'), stopCreator('c')]);
4945
const testRenderer = TestRenderer.create(<Canal a c />);
5046
expect(testRenderer.toJSON()).toMatchSnapshot();
5147
});
5248

5349
it('only rerender if style was modified', () => {
54-
const Canal = createCanal([
55-
stopCreator('a'),
56-
stopCreator('b'),
57-
stopCreator('c')
58-
]);
50+
const Canal = createCanal([stopCreator('a'), stopCreator('b'), stopCreator('c')]);
5951
const testRenderer = TestRenderer.create(<Canal a />);
6052
const renderSpy = jest.spyOn(
6153
// @ts-ignore
@@ -98,9 +90,7 @@ describe('createCanal', () => {
9890
// @ts-ignore
9991
createCanal([stopCreator('a'), stopCreator('a')]);
10092
} catch (error) {
101-
expect(error.message).toBe(
102-
'`createCanal` found duplicated `name: a` key.'
103-
);
93+
expect(error.message).toBe('`createCanal` found duplicated `name: a` key.');
10494
}
10595
expect.assertions(1);
10696
});
@@ -111,9 +101,7 @@ describe('createCanal', () => {
111101
const Canal = createCanal([stopCreator('a'), stopB]);
112102
const testRenderer = TestRenderer.create(<Canal a />);
113103
// @ts-ignore
114-
testRenderer.root.children[0].instance.fullScreenStackProperties$.subscribe(
115-
spy
116-
);
104+
testRenderer.root.children[0].instance.fullScreenStackProperties$.subscribe(spy);
117105
// @ts-ignore
118106
const [_, StopB] = testRenderer.root.children[0].instance.stopsList;
119107
testRenderer.update(<Canal a />);
@@ -124,9 +112,9 @@ describe('createCanal', () => {
124112
Component: StopB.Component,
125113
isAuthorized: false,
126114
isFullScreen: true,
127-
name: 'b'
128-
}
129-
]
115+
name: 'b',
116+
},
117+
],
130118
});
131119
testRenderer.update(<Canal a />);
132120
testRenderer.update(<Canal a b />);
@@ -137,9 +125,9 @@ describe('createCanal', () => {
137125
Component: StopB.Component,
138126
isAuthorized: true,
139127
isFullScreen: true,
140-
name: 'b'
141-
}
142-
]
128+
name: 'b',
129+
},
130+
],
143131
});
144132
testRenderer.update(<Canal a b />);
145133
testRenderer.update(<Canal a b />);
@@ -151,9 +139,7 @@ describe('createCanal', () => {
151139
const Canal = createCanal([stopCreator('a'), stopCreator('b', true)]);
152140
const testRenderer = TestRenderer.create(<Canal a />);
153141
// @ts-ignore
154-
testRenderer.root.children[0].instance.fullScreenStackProperties$.subscribe(
155-
spy
156-
);
142+
testRenderer.root.children[0].instance.fullScreenStackProperties$.subscribe(spy);
157143
// @ts-ignore
158144
const [_, StopB] = testRenderer.root.children[0].instance.stopsList;
159145
testRenderer.update(<Canal a b />);
@@ -166,9 +152,9 @@ describe('createCanal', () => {
166152
Component: StopB.Component,
167153
isAuthorized: true,
168154
isFullScreen: true,
169-
name: 'b'
170-
}
171-
]
155+
name: 'b',
156+
},
157+
],
172158
});
173159
expect(spy).toHaveBeenCalledWith({
174160
canalId: '0',
@@ -177,14 +163,14 @@ describe('createCanal', () => {
177163
Component: StopB.Component,
178164
isAuthorized: false,
179165
isFullScreen: true,
180-
name: 'b'
181-
}
182-
]
166+
name: 'b',
167+
},
168+
],
183169
});
184170
});
185171

186172
it('passes back events on', () => {
187-
const back$ = new Subject<IBackEvent>();
173+
const back$ = new Subject<BackEvent>();
188174
const spy = jest.fn();
189175
const Canal = createCanal([stopCreator('a'), stopCreator('b')]);
190176
const testRenderer = TestRenderer.create(
@@ -196,7 +182,7 @@ describe('createCanal', () => {
196182
testRenderer.root.children[0].instance.back$.subscribe(spy);
197183
back$.next({ target: null });
198184
expect(spy).toHaveBeenCalledWith({
199-
target: 'a'
185+
target: 'a',
200186
});
201187
testRenderer.update(
202188
<BackContext.Provider value={{ back$ }}>
@@ -205,7 +191,7 @@ describe('createCanal', () => {
205191
);
206192
back$.next({ target: null });
207193
expect(spy).toHaveBeenCalledWith({
208-
target: 'b'
194+
target: 'b',
209195
});
210196
testRenderer.update(
211197
<BackContext.Provider value={{ back$ }}>
@@ -214,7 +200,7 @@ describe('createCanal', () => {
214200
);
215201
back$.next({ target: null });
216202
expect(spy).toHaveBeenCalledWith({
217-
target: null
203+
target: null,
218204
});
219205
});
220206
});

0 commit comments

Comments
 (0)