Skip to content

Commit

Permalink
add eslint, optional disable press for table rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Wolfe committed May 2, 2023
1 parent 9e297ca commit 8631af0
Show file tree
Hide file tree
Showing 8 changed files with 3,089 additions and 359 deletions.
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import", "react-hooks"],
"rules": {
"import/no-anonymous-default-export": 0,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/consistent-type-imports": "warn"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"@typescript-eslint/parser": "./tsconfig.json"
}
}
}
Empty file removed .eslintrc.js
Empty file.
2 changes: 1 addition & 1 deletion App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ionicons from '@expo/vector-icons/Ionicons';
import { Modal, SafeAreaView, ScrollView } from 'react-native';
import { SafeAreaView, ScrollView } from 'react-native';
import { Button } from 'components/Button';
import { Flex } from 'components/Flex';
import { HorizontalScroll } from 'components/HorizontalScroll';
Expand Down
3,385 changes: 3,039 additions & 346 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,33 @@
"build:esm": "tsc --project tsconfig.build-esm.json && tsc-alias -p tsconfig.build-esm.json",
"dev": "expo start -c",
"dev:clean": "expo r -c",
"lint": "eslint \"**/*.{ts,tsx}\"",
"rm:build": "rimraf lib",
"storybook": "start-storybook -p 6006",
"typecheck": "tsc --noEmit"
},
"author": "Matthew Wolfe",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/core": "^7.21.5",
"@types/react": "^18.2.0",
"@types/react-native": "^0.71.6",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"babel-plugin-module-resolver": "^5.0.0",
"expo": "^48.0.13",
"eslint": "^8.39.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"expo": "^48.0.15",
"metro-react-native-babel-preset": "^0.76.3",
"prettier": "^2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.71.7",
"rimraf": "^5.0.0",
"tsc-alias": "^1.8.5",
"tsc-alias": "^1.8.6",
"typescript": "^5.0.4"
},
"peerDependencies": {
Expand Down
7 changes: 1 addition & 6 deletions src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import React from 'react';
import { StyleSheet, Switch as SwitchBase } from 'react-native';
import { theme } from 'theme';
import { Switch as SwitchBase } from 'react-native';

import type { Props } from './Switch.types';

const switchStyles = StyleSheet.create({
base: {},
});

function Switch(props: Props) {
return <SwitchBase {...props} />;
}
Expand Down
15 changes: 12 additions & 3 deletions src/components/TableRow/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ const styles = StyleSheet.create({
},
});

function TableRow({ last = false, left, onPress, rightIcon, rightText, subtitle, title }: Props) {
function TableRow({
disablePress,
last = false,
left,
onPress,
rightIcon,
rightText,
subtitle,
title,
}: Props) {
const [active, setActive] = useState<boolean>(false);

const rootStyles = useMemo(
() => ({
...styles.root,
...(subtitle ? styles.rootWithSubtitle : {}),
...(active ? styles.active : {}),
...(active && !disablePress ? styles.active : {}),
...(last ? styles.last : {}),
}),
[active, last, subtitle]
[active, disablePress, last, subtitle]
);

return (
Expand Down
1 change: 1 addition & 0 deletions src/components/TableRow/TableRow.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
import type { TouchableOpacityProps } from 'react-native';

interface BaseProps {
disablePress?: boolean;
last?: boolean;
left?: ReactNode;
onPress?: TouchableOpacityProps['onPress'];
Expand Down

0 comments on commit 8631af0

Please sign in to comment.