Skip to content

Commit

Permalink
Merge pull request #78 from kanzitelli/fix-eslint
Browse files Browse the repository at this point in the history
[fix] ESLint
  • Loading branch information
kanzitelli authored Feb 28, 2022
2 parents 647d21c + ec2deff commit 9a966ba
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 333 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
module.exports = {
root: true,
extends: ['@react-native-community', 'plugin:@typescript-eslint/recommended'],
extends: '@react-native-community',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-shadow': ['error'],
'no-shadow': 'off',
'no-undef': 'off',
},
},
],
};
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
printWidth: 120,
bracketSpacing: false,
arrowParens: 'avoid',
};
};
8 changes: 1 addition & 7 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,4 @@ export const beforeStart = async (): PVoid => {

export const App = () => Root(Screen(screens.get('Main'))); // or Root(Stack(Component(screens.get('Main'))))
export const TabsApp = () =>
Root(
BottomTabs([
Screen(screens.get('Main')),
Screen(screens.get('Example')),
Screen(screens.get('Settings')),
]),
);
Root(BottomTabs([Screen(screens.get('Main')), Screen(screens.get('Example')), Screen(screens.get('Settings'))]));
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@babel/core": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@babel/runtime": "^7.16.7",
"@react-native-community/eslint-config": "^3.0.1",
"@react-native-community/eslint-config": "2.0.0",
"@tsconfig/react-native": "^1.0.4",
"@types/i18n-js": "^3.8.2",
"@types/jest": "^27.4.0",
Expand All @@ -61,10 +61,11 @@
"@types/react-native": "^0.66.11",
"@types/react-native-vector-icons": "^6.4.10",
"@types/react-test-renderer": "^17.0.1",
"@typescript-eslint/parser": "^5.9.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"babel-jest": "^27.4.6",
"dotenv-cli": "^4.1.1",
"eslint": "^8.6.0",
"eslint": "7.14.0",
"jest": "^27.4.7",
"metro-react-native-babel-preset": "^0.66.2",
"patch-package": "^6.4.7",
Expand Down
11 changes: 2 additions & 9 deletions src/components/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ type ActionProps = {
onPress?: () => void;
};

export const Action: React.FC<ActionProps> = ({
title,
icon,
rightIcon,
info,
disabled,
onPress,
}: ActionProps) => {
export const Action: React.FC<ActionProps> = ({title, icon, rightIcon, info, disabled, onPress}: ActionProps) => {
const b = {disabled, onPress};
const iconSize = 22;

return (
<View padding-s4>
<Bounceable {...b}>
<Row style={{justifyContent: 'space-between'}}>
<Row spread>
<Row>
{icon ? (
<View marginR-s2>
Expand Down
4 changes: 1 addition & 3 deletions src/components/component-sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ type ExampleComponentProps = {
title?: string;
};

export const ExampleComponent: React.FC<ExampleComponentProps> = ({
title,
}: ExampleComponentProps) => {
export const ExampleComponent: React.FC<ExampleComponentProps> = ({title}: ExampleComponentProps) => {
return (
<View>
<Text>{title}</Text>
Expand Down
11 changes: 7 additions & 4 deletions src/components/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Icon: React.FC<IconProps> = ({
onPress,
bounceable = true,
}: IconProps) => {
const Icon = useMemo(
const _Icon = useMemo(
() => (
<View {...viewProps}>
<IconComponent name={name} size={size} color={color} />
Expand All @@ -32,10 +32,13 @@ export const Icon: React.FC<IconProps> = ({
[viewProps, name, size, color],
);

if (!bounceable) return Icon;
if (!bounceable) {
return _Icon;
}

return (
<Bounceable onPress={onPress} disabled={!!!onPress}>
{Icon}
<Bounceable onPress={onPress} disabled={!onPress}>
{_Icon}
</Bounceable>
);
};
10 changes: 2 additions & 8 deletions src/screens/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export const Main: ScreenComponent = observer(({componentId}) => {
<BButton
marginV-s1
label={t.do('section.navigation.button.passProps')}
onPress={() =>
screens.push<ExampleScreenProps>(componentId, 'Example', {value: randomNum()})
}
onPress={() => screens.push<ExampleScreenProps>(componentId, 'Example', {value: randomNum()})}
/>
<BButton
marginV-s1
Expand Down Expand Up @@ -94,11 +92,7 @@ export const Main: ScreenComponent = observer(({componentId}) => {
</Text>
<Text marginB-s2 text60R textColor>
Counter:{' '}
<If
_={counter.loading}
_then={() => <ActivityIndicator />}
_else={<Text>{counter.value}</Text>}
/>
<If _={counter.loading} _then={() => <ActivityIndicator />} _else={<Text>{counter.value}</Text>} />
</Text>
<BButton margin-s1 label="-" onPress={counter.dec} />
<BButton margin-s1 label="+" onPress={counter.inc} />
Expand Down
10 changes: 2 additions & 8 deletions src/screens/screen-sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export const Example: ScreenComponent<ExampleScreenProps> = observer(({component
<BButton
marginV-s1
label={t.do('section.navigation.button.passProps')}
onPress={() =>
screens.push<ExampleScreenProps>(componentId, 'Example', {value: randomNum()})
}
onPress={() => screens.push<ExampleScreenProps>(componentId, 'Example', {value: randomNum()})}
/>
</View>

Expand All @@ -51,11 +49,7 @@ export const Example: ScreenComponent<ExampleScreenProps> = observer(({component
</Section>

<Reanimated2 stID="reanimated2" />
<BButton
marginV-s1
label={t.do('section.navigation.button.back')}
onPress={() => screens.pop(componentId)}
/>
<BButton marginV-s1 label={t.do('section.navigation.button.back')} onPress={() => screens.pop(componentId)} />

<Text textColor center>
localized with i18n-js
Expand Down
22 changes: 4 additions & 18 deletions src/screens/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ export const Settings: ScreenComponent = observer(() => {
console.log(option);
};

const appearanceActions: AppearanceAction[] = useMemo(
() => [{name: 'System'}, {name: 'Light'}, {name: 'Dark'}],
[],
);
const appearanceActions: AppearanceAction[] = useMemo(() => [{name: 'System'}, {name: 'Light'}, {name: 'Dark'}], []);
const AppearanceActionSheet = useMemo(
() => (
<ActionSheet
Expand All @@ -81,10 +78,7 @@ export const Settings: ScreenComponent = observer(() => {
[pickers.appearance],
);

const languageActions: LanguageAction[] = useMemo(
() => [{name: 'System'}, {name: 'English'}, {name: 'Russian'}],
[],
);
const languageActions: LanguageAction[] = useMemo(() => [{name: 'System'}, {name: 'English'}, {name: 'Russian'}], []);
const LanguageActionSheet = useMemo(
() => (
<ActionSheet
Expand Down Expand Up @@ -157,16 +151,8 @@ export const Settings: ScreenComponent = observer(() => {

<Section bg title="About">
<View>
<Action
disabled
title="App name"
info={Application.applicationName ?? 'No app name'}
/>
<Action
disabled
title="Version"
info={Application.nativeApplicationVersion ?? '0.0'}
/>
<Action disabled title="App name" info={Application.applicationName ?? 'No app name'} />
<Action disabled title="Version" info={Application.nativeApplicationVersion ?? '0.0'} />
</View>
</Section>
</View>
Expand Down
11 changes: 2 additions & 9 deletions src/services/navigation/sharedTransition.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import {
AnimationOptions,
Options,
SharedElementTransition,
StackAnimationOptions,
} from 'react-native-navigation';
import {AnimationOptions, Options, SharedElementTransition, StackAnimationOptions} from 'react-native-navigation';
import {SharedTransitionElement, SharedTransitionId, SharedTransitionNativeId} from './types';

export const genNativeId = (id?: SharedTransitionId): SharedTransitionNativeId => id || 'id';

export const genSharedElementTransition = (
e: SharedTransitionElement,
): SharedElementTransition => ({
export const genSharedElementTransition = (e: SharedTransitionElement): SharedElementTransition => ({
...e.rest,
fromId: genNativeId(e.id),
toId: genNativeId(e.id),
Expand Down
8 changes: 1 addition & 7 deletions src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ export class UIStore implements IStore {

makePersistable(this, {
name: UIStore.name,
properties: [
'appLaunches',
'isSystemAppearance',
'appearance',
'isSystemLanguage',
'language',
],
properties: ['appLaunches', 'isSystemAppearance', 'appearance', 'isSystemLanguage', 'language'],
});
}

Expand Down
Loading

0 comments on commit 9a966ba

Please sign in to comment.