Skip to content

Commit a73d36e

Browse files
committed
Satisfy eslint/Prettier
1 parent bf57a84 commit a73d36e

File tree

2 files changed

+119
-153
lines changed

2 files changed

+119
-153
lines changed

src/bottom-navigation/react/index.ts

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { registerElement, NSVElement, NativeScriptProps } from "react-nativescript";
2-
import { warn } from "react-nativescript/dist/shared/logger";
1+
import { NSVElement, NativeScriptProps, registerElement } from 'react-nativescript';
2+
import { warn } from 'react-nativescript/dist/shared/logger';
33
import { BottomNavigation, SelectedIndexChangedEventData, TabContentItem, TabStrip } from '../';
4-
import { TabNavigationBaseAttributes } from "../../core/tab-navigation-base/tab-navigation-base/react";
4+
import { TabNavigationBaseAttributes } from '../../core/tab-navigation-base/tab-navigation-base/react';
55

66
// Global compile-time constant (for some reason not exported by RNS itself)
7+
// eslint-disable-next-line no-var
78
declare var __DEV__: boolean;
89

910
// ui/bottom-navigation/bottom-navigation.d.ts
10-
export type BottomNavigationAttributes = TabNavigationBaseAttributes & {
11+
export type BottomNavigationAttributes = TabNavigationBaseAttributes & {
1112
android?: any;
1213
ios?: any;
1314
items?: TabContentItem[];
@@ -17,6 +18,7 @@ export type BottomNavigationAttributes = TabNavigationBaseAttributes & {
1718
};
1819

1920
declare global {
21+
// eslint-disable-next-line @typescript-eslint/prefer-namespace-keyword
2022
module JSX {
2123
interface IntrinsicElements {
2224
bottomNavigation: NativeScriptProps<BottomNavigationAttributes, BottomNavigation>;
@@ -30,7 +32,7 @@ declare global {
3032
let installed: boolean = false;
3133

3234
export function registerBottomNavigation(): void {
33-
if(installed){
35+
if (installed) {
3436
return;
3537
}
3638
registerElement(
@@ -42,72 +44,60 @@ export function registerBottomNavigation(): void {
4244
nodeOps: {
4345
insert(child: NSVElement, parent: NSVElement<BottomNavigation>, atIndex?: number): void {
4446
const bottomNavigation = parent.nativeView;
45-
46-
if(child.nodeRole === "tabStrip"){
47-
if(child.nativeView instanceof TabStrip){
47+
48+
if (child.nodeRole === 'tabStrip') {
49+
if (child.nativeView instanceof TabStrip) {
4850
bottomNavigation.tabStrip = child.nativeView;
4951
} else {
5052
if (__DEV__) {
51-
warn(
52-
`Unable to add child "${child.nativeView.constructor.name}" as the tabStrip of <bottomNavigation> as it is not an instance of TabStrip.`
53-
);
53+
warn(`Unable to add child "${child.nativeView.constructor.name}" as the tabStrip of <bottomNavigation> as it is not an instance of TabStrip.`);
5454
}
5555
}
56-
} else if(child.nodeRole === "items"){
57-
if(child.nativeView instanceof TabContentItem === false){
56+
} else if (child.nodeRole === 'items') {
57+
if (child.nativeView instanceof TabContentItem === false) {
5858
if (__DEV__) {
59-
warn(
60-
`Unable to add child "${child.nativeView.constructor.name}" to the items of <bottomNavigation> as it is not an instance of TabContentItem.`
61-
);
62-
};
59+
warn(`Unable to add child "${child.nativeView.constructor.name}" to the items of <bottomNavigation> as it is not an instance of TabContentItem.`);
60+
}
6361
return;
6462
}
65-
63+
6664
const items = bottomNavigation.items || []; // Annoyingly, it's the consumer's responsibility to ensure there's an array there!
67-
68-
if(typeof atIndex === "undefined" || atIndex === items.length){
65+
66+
if (typeof atIndex === 'undefined' || atIndex === items.length) {
6967
bottomNavigation.items = items.concat(child.nativeView as TabContentItem);
7068
} else {
71-
bottomNavigation.items = items.slice().splice(
72-
atIndex,
73-
0,
74-
child.nativeView as TabContentItem
75-
);
69+
bottomNavigation.items = items.slice().splice(atIndex, 0, child.nativeView as TabContentItem);
7670
}
77-
} else if(child.nodeRole === "item"){
71+
} else if (child.nodeRole === 'item') {
7872
if (__DEV__) {
79-
warn(
80-
`Unable to add child "${child.nativeView.constructor.name}" to <bottomNavigation> as it had the nodeRole "item"; please correct it to "items".`
81-
);
73+
warn(`Unable to add child "${child.nativeView.constructor.name}" to <bottomNavigation> as it had the nodeRole "item"; please correct it to "items".`);
8274
}
8375
} else {
8476
if (__DEV__) {
8577
warn(
8678
`Unable to add child "${child.nativeView.constructor.name}" to <bottomNavigation> as it does not have a nodeRole specified; ` +
87-
`please set a nodeRole of "tabStrip", or "items".`
88-
)
79+
'please set a nodeRole of "tabStrip", or "items".'
80+
);
8981
}
9082
}
9183
},
9284
remove(child: NSVElement, parent: NSVElement<BottomNavigation>): void {
9385
const tabs = parent.nativeView;
94-
95-
if(child.nodeRole === "tabStrip"){
86+
87+
if (child.nodeRole === 'tabStrip') {
9688
tabs.tabStrip = null; // Anything falsy should work.
97-
} else if(child.nodeRole === "items"){
98-
tabs.items = (tabs.items || []).filter(i => i !== child.nativeView);
99-
} else if(child.nodeRole === "item"){
89+
} else if (child.nodeRole === 'items') {
90+
tabs.items = (tabs.items || []).filter((i) => i !== child.nativeView);
91+
} else if (child.nodeRole === 'item') {
10092
if (__DEV__) {
101-
warn(
102-
`Unable to remove child "${child.nativeView.constructor.name}" from <bottomNavigation> as it had the nodeRole "item"; please correct it to "items".`
103-
);
93+
warn(`Unable to remove child "${child.nativeView.constructor.name}" from <bottomNavigation> as it had the nodeRole "item"; please correct it to "items".`);
10494
}
10595
} else {
10696
if (__DEV__) {
10797
warn(
10898
`Unable to remove child "${child.nativeView.constructor.name}" from <bottomNavigation> as it does not have a nodeRole specified; ` +
109-
`please set a nodeRole of "tabStrip", or "items"`
110-
)
99+
'please set a nodeRole of "tabStrip", or "items"'
100+
);
111101
}
112102
}
113103
}

0 commit comments

Comments
 (0)