Skip to content

Commit 6505c03

Browse files
authored
Merge pull request #24 from RoboJackets/jvogt23-patch-1
Added ESLint
2 parents d384574 + 37b53c0 commit 6505c03

File tree

17 files changed

+806
-366
lines changed

17 files changed

+806
-366
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
.eslintrc.js
3+
metro.config.js

.eslintrc.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native',
4-
};
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaFeatures: { jsx: true },
6+
ecmaVersion: 2022,
7+
sourceType: 'module',
8+
project: ['./tsconfig.json'],
9+
},
10+
plugins: ['@typescript-eslint', 'react', 'react-native', 'prettier'],
11+
extends: [
12+
'eslint:recommended',
13+
'plugin:@typescript-eslint/recommended',
14+
'plugin:react/recommended',
15+
'plugin:react-native/all',
16+
'plugin:prettier/recommended', // Prettier integration
17+
],
18+
env: {
19+
es2022: true,
20+
node: true,
21+
browser: true,
22+
'react-native/react-native': true,
23+
},
24+
settings: {
25+
react: { version: 'detect' },
26+
},
27+
rules: {
28+
// TypeScript rules
29+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
30+
'@typescript-eslint/explicit-module-boundary-types': 'off',
31+
32+
// React rules
33+
'react/prop-types': 'off', // TS handles props types
34+
35+
// React Native rules
36+
'react-native/no-inline-styles': 'warn',
37+
'react-native/split-platform-components': 'warn',
38+
'react-native/no-color-literals': 'off',
39+
40+
// Prettier formatting rules
41+
'prettier/prettier': [
42+
'error',
43+
{
44+
singleQuote: true,
45+
trailingComma: 'all',
46+
printWidth: 100,
47+
tabWidth: 2,
48+
semi: true,
49+
},
50+
],
51+
},
52+
};

.github/workflows/eslint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# ESLint is a tool for identifying and reporting on patterns
6+
# found in ECMAScript/JavaScript code.
7+
# More details at https://github.com/eslint/eslint
8+
# and https://eslint.org
9+
10+
name: ESLint
11+
12+
on:
13+
push:
14+
branches: [ "main" ]
15+
pull_request:
16+
# The branches below must be a subset of the branches above
17+
branches: [ "main" ]
18+
schedule:
19+
- cron: '17 23 * * 6'
20+
21+
jobs:
22+
eslint:
23+
name: Run eslint scanning
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
security-events: write
28+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Install dependencies
34+
run: npm install
35+
36+
- name: Run ESLint
37+
env:
38+
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
39+
run: npx eslint .
40+
--config .eslintrc.js
41+
--ext .js,.jsx,.ts,.tsx
42+
--max-warnings=0
43+
continue-on-error: false

.prettierrc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
2-
arrowParens: 'avoid',
3-
singleQuote: true,
4-
trailingComma: 'all',
5-
};
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"semi": true
7+
}

App.tsx

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,28 @@
11
import { NavigationContainer } from '@react-navigation/native';
22
import React, { createContext, ReactNode, useState } from 'react';
3-
import { NativeModules, StyleSheet, useColorScheme } from 'react-native';
43
import RootStack from './Navigation/RootStack';
54

6-
75
type AuthContextType = {
86
authenticated: boolean | null;
9-
setAuthenticated: (u: boolean ) => void;
7+
setAuthenticated: (u: boolean) => void;
108
};
119

1210
type AuthProviderProps = {
1311
children: ReactNode;
14-
}
12+
};
1513

1614
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
1715

18-
function AuthProvider({children}: AuthProviderProps) {
16+
function AuthProvider({ children }: AuthProviderProps) {
1917
const [authenticated, setAuthenticated] = useState(false);
20-
return(
18+
return (
2119
<AuthContext.Provider value={{ authenticated, setAuthenticated }}>
2220
{children}
2321
</AuthContext.Provider>
24-
)
22+
);
2523
}
2624

2725
function App() {
28-
const { BuzzCardReader } = NativeModules;
29-
const isDarkMode = useColorScheme() === 'dark';
30-
const [readerText, setReaderText] = useState("No text found");
31-
const [scanning, setScanning] = useState(false);
32-
33-
const selectApp = [0x90, 0x5A, 0x00, 0x00, 0x03, 0xCD, 0xBB, 0xBB, 0x00];
34-
const readFile = [0x90, 0xBD, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00];
35-
36-
async function readNfc() {
37-
setScanning(true);
38-
}
39-
40-
/*return (
41-
<View style={styles.container}>
42-
<Text style={styles.baseText}>
43-
{readerText}
44-
</Text>
45-
<Button title="Scan" onPress={readNfc} />
46-
<NfcScanModal scanning={scanning} appCmd={selectApp}
47-
readCmd={readFile} modalText='Place your BuzzCard near the phone.'
48-
callback={(error, result) => {
49-
if (error) {
50-
setReaderText(error.message);
51-
} else {
52-
//setReaderText(result?.toString() ?? 'yeet');
53-
setReaderText(typeof result);
54-
}
55-
setScanning(false);
56-
}}/>
57-
</View>
58-
);*/
5926
return (
6027
<AuthProvider>
6128
<NavigationContainer>
@@ -65,15 +32,4 @@ function App() {
6532
);
6633
}
6734

68-
const styles = StyleSheet.create({
69-
container: {
70-
flex: 1,
71-
},
72-
baseText: {
73-
fontFamily: 'Cochin',
74-
textAlign: 'center',
75-
marginTop: 50,
76-
},
77-
});
78-
7935
export default App;

Attendance/AttendanceScreen.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import { ParamListBase, useNavigation } from '@react-navigation/native';
2-
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
31
import React from 'react';
42
import { Text, View } from 'react-native';
53

64
function AttendanceScreen() {
7-
8-
const navigation = useNavigation<NativeStackNavigationProp<ParamListBase>>();
9-
10-
return (
5+
return (
6+
// eslint-disable-next-line react-native/no-inline-styles
117
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
12-
<Text>Attendance Screen</Text>
8+
<Text>Attendance Screen</Text>
139
</View>
14-
);
10+
);
1511
}
1612

17-
export default AttendanceScreen;
13+
export default AttendanceScreen;

Auth/AuthenticationScreen.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ import React, { useContext } from 'react';
22
import { Button, Text, View } from 'react-native';
33
import { AuthContext } from '../App';
44

5-
65
function AuthenticationScreen() {
6+
const auth = useContext(AuthContext);
77

8-
const auth = useContext(AuthContext);
9-
10-
const login = () => {
11-
auth?.setAuthenticated(true);
12-
};
8+
const login = () => {
9+
auth?.setAuthenticated(true);
10+
};
1311

14-
return (
12+
return (
13+
// eslint-disable-next-line react-native/no-inline-styles
1514
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
16-
<Text>Authentication Screen</Text>
17-
<Button title="Login" onPress={ login } />
15+
<Text>Authentication Screen</Text>
16+
<Button title="Login" onPress={login} />
1817
</View>
19-
);
18+
);
2019
}
2120

22-
export default AuthenticationScreen;
21+
export default AuthenticationScreen;

Merchandise/MerchandiseScreen.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import { Text, View } from 'react-native';
33

44
function MerchandiseScreen() {
5-
6-
return (
5+
return (
6+
// eslint-disable-next-line react-native/no-inline-styles
77
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
88
<Text>Merchandise Screen</Text>
99
</View>
10-
);
10+
);
1111
}
1212

13-
export default MerchandiseScreen;
13+
export default MerchandiseScreen;

Navigation/NavBar.tsx

Lines changed: 45 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,54 @@ import MerchandiseScreen from '../Merchandise/MerchandiseScreen';
77
import SettingsScreen from '../Settings/SettingsScreen';
88

99
type NavBarProps = {
10-
hidden?: boolean | null;
11-
}
10+
hidden?: boolean | null;
11+
};
1212

1313
const Tab = createBottomTabNavigator();
1414

1515
function NavBar(props: NavBarProps) {
16-
return (
17-
<Tab.Navigator
18-
screenOptions={{
19-
headerShown: false,
20-
tabBarStyle: props.hidden ? {display: 'none'} : {}
21-
}}
22-
>
23-
<Tab.Screen
24-
name="Attendance"
25-
component={AttendanceScreen}
26-
options={{
27-
tabBarIcon: ({focused, color, size}) => {
28-
return (
29-
<MaterialDesignIcons
30-
name="contactless-payment-circle-outline"
31-
color={color}
32-
size={size}
33-
/>
34-
)
35-
}
36-
}}
37-
/>
38-
<Tab.Screen
39-
name="Merchandise"
40-
component={MerchandiseScreen}
41-
options={{
42-
tabBarIcon: ({focused, color, size}) => {
43-
return (
44-
<MaterialDesignIcons
45-
name="storefront-outline"
46-
color={color}
47-
size={size}
48-
/>
49-
)
50-
}
51-
}}
52-
/>
53-
<Tab.Screen
54-
name="Settings"
55-
component={SettingsScreen}
56-
options={{
57-
tabBarIcon: ({focused, color, size}) => {
58-
return (
59-
<MaterialIcons
60-
name="settings"
61-
color={color}
62-
size={size}
63-
/>
64-
)
65-
}
66-
}}
67-
/>
68-
</Tab.Navigator>
69-
)
16+
return (
17+
<Tab.Navigator
18+
screenOptions={{
19+
headerShown: false,
20+
tabBarStyle: props.hidden ? { display: 'none' } : {},
21+
}}
22+
>
23+
<Tab.Screen
24+
name="Attendance"
25+
component={AttendanceScreen}
26+
options={{
27+
tabBarIcon: ({ color, size }) => {
28+
return (
29+
<MaterialDesignIcons
30+
name="contactless-payment-circle-outline"
31+
color={color}
32+
size={size}
33+
/>
34+
);
35+
},
36+
}}
37+
/>
38+
<Tab.Screen
39+
name="Merchandise"
40+
component={MerchandiseScreen}
41+
options={{
42+
tabBarIcon: ({ color, size }) => {
43+
return <MaterialDesignIcons name="storefront-outline" color={color} size={size} />;
44+
},
45+
}}
46+
/>
47+
<Tab.Screen
48+
name="Settings"
49+
component={SettingsScreen}
50+
options={{
51+
tabBarIcon: ({ color, size }) => {
52+
return <MaterialIcons name="settings" color={color} size={size} />;
53+
},
54+
}}
55+
/>
56+
</Tab.Navigator>
57+
);
7058
}
7159

72-
export default NavBar;
60+
export default NavBar;

0 commit comments

Comments
 (0)