Skip to content

Commit 8f63d9c

Browse files
committed
refactor: fix eslint errors
1 parent 18c2ac4 commit 8f63d9c

13 files changed

+64
-32
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ module.exports = {
3939
'react/jsx-props-no-spreading': 'off',
4040
'react/prop-types': 'off',
4141
'@typescript-eslint/explicit-module-boundary-types': 'off',
42+
'@typescript-eslint/no-empty-function': 'off',
4243
},
4344
};

example/babel.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
12
const path = require('path');
23
const pak = require('../package.json');
34

example/metro.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
/* eslint-disable import/no-extraneous-dependencies */
3+
14
const path = require('path');
2-
/* eslint-disable-next-line */
35
const blacklist = require('metro-config/src/defaults/blacklist');
4-
/* eslint-disable-next-line */
56
const escape = require('escape-string-regexp');
67
const pak = require('../package.json');
78

example/src/examples/SelectBoxExample.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React, { useState } from 'react';
22
import { Panel, SelectBox, Fieldset } from 'react95-native';
33

4-
const options = ['apple', 'orange', 'banana', 'pear', 'watermelon'].map(o => ({
5-
label: o,
6-
value: o,
7-
}));
4+
const options = ['apple', 'orange', 'banana', 'pear', 'watermelon'].map(
5+
option => ({
6+
label: option,
7+
value: option,
8+
}),
9+
);
810

911
const SelectBoxExample = () => {
1012
const [value, setValue] = useState(options[0].value);

example/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
/* eslint-disable import/no-extraneous-dependencies */
3+
14
const path = require('path');
2-
/* eslint-disable-next-line */
35
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
46
const { resolver } = require('./metro.config');
57

src/Fieldset/Fieldset.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from 'react';
2-
import { StyleSheet, View, Text } from 'react-native';
2+
import { StyleSheet, View, Text, StyleProp, ViewStyle } from 'react-native';
33

44
import { ThemeContext } from '../common/theming/Theme';
55
import { Border } from '../common/styleElements';
@@ -9,7 +9,7 @@ export const testId = 'fieldset';
99
type Props = {
1010
label?: React.ReactNode;
1111
children: React.ReactNode;
12-
style?: Object;
12+
style?: StyleProp<ViewStyle>;
1313
};
1414

1515
const Fieldset = ({ children, label, style = {} }: Props) => {

src/Menu/Menu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet } from 'react-native';
2+
import { StyleProp, StyleSheet, ViewStyle } from 'react-native';
33

44
import { Panel } from '..';
55

@@ -10,7 +10,7 @@ type MenuProps = {
1010
// see react-native-paper
1111
children: React.ReactNode;
1212
orientation?: 'vertical' | 'horizontal';
13-
style?: Object;
13+
style?: StyleProp<ViewStyle>;
1414
};
1515

1616
const Menu = ({

src/Menu/MenuItem.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import React, { useContext, useState } from 'react';
2-
import { StyleSheet, View, TouchableHighlight } from 'react-native';
2+
import {
3+
StyleSheet,
4+
View,
5+
TouchableHighlight,
6+
StyleProp,
7+
ViewStyle,
8+
} from 'react-native';
39

410
import { ThemeContext } from '../common/theming/Theme';
511
import { blockSizes } from '../common/styles';
@@ -15,7 +21,7 @@ type Props = {
1521
// icon: React.ReactNode;
1622
onPress: () => void;
1723
disabled?: boolean;
18-
style?: Object;
24+
style?: StyleProp<ViewStyle>;
1925
};
2026

2127
export const Item = ({

src/Select/Select.tsx

+18-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
Text,
66
TouchableHighlight,
77
ImageBackground,
8+
StyleProp,
9+
ViewStyle,
810
} from 'react-native';
911

1012
import { ThemeContext } from '../common/theming/Theme';
@@ -26,8 +28,8 @@ type SelectProps = {
2628
value: any;
2729
disabled?: boolean;
2830
// TODO: what to put below?
29-
onChange: () => void;
30-
style?: Object;
31+
onChange: (value: any) => void;
32+
style?: StyleProp<ViewStyle>;
3133
menuMaxHeight?: number;
3234
};
3335

@@ -47,6 +49,19 @@ const Select = ({
4749
onChange(option.value);
4850
setIsOpen(false);
4951
}
52+
53+
function getLabelContainerBackgroundColor() {
54+
if (disabled) {
55+
return theme.material;
56+
}
57+
58+
if (isPressed) {
59+
return theme.hoverBackground;
60+
}
61+
62+
return theme.canvas;
63+
}
64+
5065
const [selectedOptions, selectOptions] = getSelectOptions({
5166
options,
5267
values: [value],
@@ -86,11 +101,7 @@ const Select = ({
86101
{
87102
borderWidth: 2,
88103
borderColor: disabled ? theme.material : theme.canvas,
89-
backgroundColor: disabled
90-
? theme.material
91-
: isPressed
92-
? theme.hoverBackground
93-
: theme.canvas,
104+
backgroundColor: getLabelContainerBackgroundColor(),
94105
},
95106

96107
isPressed && theme.border.focusSecondaryOutline,

src/Select/SelectBase.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type Option = {
1212

1313
type SelectItemProps = {
1414
option: Option;
15-
onPress: () => void;
15+
onPress: (value: any) => void;
1616
isSelected: boolean;
1717
};
1818

@@ -81,7 +81,7 @@ type SelectOptionsProps = {
8181
values: [any];
8282
disabled?: boolean;
8383
// TODO: what to put below?
84-
onChange: () => void;
84+
onChange: (value: any) => void;
8585
};
8686

8787
export default function getSelectOptions({

src/Select/SelectBox.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from 'react';
2-
import { StyleSheet, View } from 'react-native';
2+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

44
import { Border } from '../common/styleElements';
55
import { ThemeContext } from '../common/theming/Theme';
@@ -15,8 +15,8 @@ type SelectBoxProps = {
1515
value: [any] | any;
1616
// disabled?: boolean;
1717
// TODO: what to put below?
18-
onChange: () => void;
19-
style?: Object;
18+
onChange: (value: any) => void;
19+
style?: StyleProp<ViewStyle>;
2020
};
2121

2222
const SelectBox = ({

src/Text/Text.tsx

+13-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ const Text = ({
3535
Linking.openURL(linkUrl || '');
3636
};
3737

38+
const getTextStyle = () => {
39+
if (disabled) {
40+
return theme.text.disabled;
41+
}
42+
43+
if (secondary) {
44+
return theme.text.secondary;
45+
}
46+
47+
return theme.text.default;
48+
};
49+
3850
return (
3951
<NativeText
4052
style={[
41-
disabled
42-
? theme.text.disabled
43-
: secondary
44-
? theme.text.secondary
45-
: theme.text.default,
53+
getTextStyle(),
4654
linkUrl ? { ...styles.link, color: theme.anchor } : {},
4755
{
4856
fontWeight: bold ? 'bold' : 'normal',

src/common/styleElements.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { ThemeContext } from './theming/Theme';
99
type BorderProps = {
1010
invert?: boolean;
1111
variant?: 'default' | 'well' | 'outside' | 'cutout';
12-
style?: object;
13-
sharedStyle?: object;
12+
style?: StyleProp<ViewStyle>;
13+
sharedStyle?: StyleProp<ViewStyle>;
1414
radius?: number;
1515
children?: React.ReactNode;
1616
};

0 commit comments

Comments
 (0)