chore(app): fixa eslintfel, lägg till lint check i workflow (#171)
This commit is contained in:
parent
016fa2b36e
commit
91186d571c
|
@ -1 +0,0 @@
|
|||
extends: standard
|
|
@ -26,7 +26,9 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: npx lerna bootstrap
|
||||
|
||||
- name: Run tests
|
||||
run: yarn test
|
||||
- name: Run linting and tests
|
||||
run: |
|
||||
yarn lint
|
||||
yarn test
|
||||
env:
|
||||
CI: true
|
||||
|
|
|
@ -27,8 +27,10 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: npx lerna bootstrap
|
||||
|
||||
- name: Run tests
|
||||
run: yarn test
|
||||
- name: Run linting and tests
|
||||
run: |
|
||||
yarn lint
|
||||
yarn test
|
||||
env:
|
||||
CI: true
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"bootstrap": "npx lerna bootstrap",
|
||||
"test": "npx lerna run test --stream"
|
||||
"test": "npx lerna run test --stream",
|
||||
"lint": "npx lerna run lint --stream"
|
||||
},
|
||||
"version": "1.4.0"
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
extends: '@react-native-community',
|
||||
rules: {
|
||||
semi: ['error', 'never'],
|
||||
},
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": ["@react-native-community", "prettier"],
|
||||
"plugins": ["prettier"],
|
||||
"env": {
|
||||
"jest": true
|
||||
}
|
||||
}
|
|
@ -23,25 +23,32 @@ export const Calendar = () => {
|
|||
)
|
||||
|
||||
return !data?.length ? (
|
||||
<View style={{ flex: 1 }}>
|
||||
<View style={styles.emptyState}>
|
||||
<Image
|
||||
source={require('../assets/girls.png')}
|
||||
style={{ height: 200, width: '100%' }}
|
||||
style={styles.emptyStateImage}
|
||||
/>
|
||||
<Text category="h5">Det ser lite tomt ut i kalendern</Text>
|
||||
</View>
|
||||
) : (
|
||||
<List
|
||||
style={styles.container}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
data={data.sort((a, b) => b.startDate < a.startDate)}
|
||||
ItemSeparatorComponent={Divider}
|
||||
renderItem={renderItem}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
style={styles.container}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
emptyState: {
|
||||
flex: 1,
|
||||
},
|
||||
emptyStateImage: {
|
||||
height: 200,
|
||||
width: '100%',
|
||||
},
|
||||
container: {
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
|
@ -49,10 +56,4 @@ const styles = StyleSheet.create({
|
|||
contentContainer: {
|
||||
padding: 10,
|
||||
},
|
||||
ongoing: {
|
||||
color: 'red',
|
||||
},
|
||||
normal: {
|
||||
color: 'black',
|
||||
},
|
||||
})
|
||||
|
|
|
@ -62,11 +62,11 @@ export const ChildListItem = ({ navigation, child, color }) => {
|
|||
}
|
||||
|
||||
const Header = (props) => (
|
||||
<View {...props} style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||
<View style={{ margin: 20, marginRight: 0 }}>
|
||||
<View {...props} style={styles.cardHeader}>
|
||||
<View style={styles.cardAvatar}>
|
||||
<Avatar source={require('../assets/avatar.png')} shape="square" />
|
||||
</View>
|
||||
<View style={{ margin: 20, flex: 1 }}>
|
||||
<View style={styles.cardHeaderText}>
|
||||
<Text category="h6">{studentName(child.name)}</Text>
|
||||
<Text category="s1">{`${getClassName()}`}</Text>
|
||||
</View>
|
||||
|
@ -184,6 +184,12 @@ const styles = StyleSheet.create({
|
|||
card: {
|
||||
marginBottom: 20,
|
||||
},
|
||||
cardHeader: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
cardAvatar: { margin: 20, marginRight: 0 },
|
||||
cardHeaderText: { margin: 20, flex: 1 },
|
||||
itemFooter: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-evenly',
|
||||
|
|
|
@ -62,6 +62,7 @@ export const Login = ({ navigation }) => {
|
|||
if (cachedSsn && socialSecurityNumber !== cachedSsn) {
|
||||
setSocialSecurityNumber(cachedSsn)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [cachedSsn])
|
||||
|
||||
const loginHandler = async () => {
|
||||
|
@ -74,6 +75,7 @@ export const Login = ({ navigation }) => {
|
|||
api.on('login', loginHandler)
|
||||
|
||||
return () => api.off('login', loginHandler)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
/* Helpers */
|
||||
|
@ -141,57 +143,33 @@ export const Login = ({ navigation }) => {
|
|||
return (
|
||||
<KeyboardAvoidingView
|
||||
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
||||
style={{ flex: 1 }}
|
||||
style={styles.keyboardAvoidingView}
|
||||
>
|
||||
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }}>
|
||||
<SafeAreaView style={styles.safeArea}>
|
||||
<>
|
||||
{isLoggedIn ? (
|
||||
<Layout
|
||||
style={{
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
paddingHorizontal: 20,
|
||||
}}
|
||||
>
|
||||
<Layout style={styles.loggedInWrap}>
|
||||
<Text category="h2" adjustsFontSizeToFit numberOfLines={1}>
|
||||
Öppna Skolplattformen
|
||||
</Text>
|
||||
<Text
|
||||
category="h6"
|
||||
style={{ color: '#9CA3AF', marginTop: 4, marginBottom: 20 }}
|
||||
>
|
||||
<Text category="h6" style={styles.subtitle}>
|
||||
Det {argument} alternativet
|
||||
</Text>
|
||||
{isFemale ? (
|
||||
<Image
|
||||
source={require('../assets/kvinna.png')}
|
||||
style={{ maxHeight: 300, width: '100%' }}
|
||||
style={styles.loggedInImage}
|
||||
/>
|
||||
) : (
|
||||
<Image
|
||||
source={require('../assets/man.png')}
|
||||
style={{
|
||||
maxHeight: 300,
|
||||
width: '100%',
|
||||
borderBottomWidth: 1,
|
||||
}}
|
||||
style={styles.loggedInImage}
|
||||
/>
|
||||
)}
|
||||
<View
|
||||
style={{
|
||||
marginTop: 32,
|
||||
}}
|
||||
>
|
||||
<View style={styles.loggedInContent}>
|
||||
<Text category="h5">{ssnValue}</Text>
|
||||
<Text
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
marginBottom: 20,
|
||||
marginTop: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.loggedInText}>
|
||||
{error || 'Hurra, du är inloggad!'}
|
||||
</Text>
|
||||
<Button
|
||||
|
@ -202,7 +180,7 @@ export const Login = ({ navigation }) => {
|
|||
>
|
||||
{error ? 'Försök igen' : 'Fortsätt'}
|
||||
</Button>
|
||||
<View style={{ marginTop: 10 }}>
|
||||
<View style={styles.logoutButton}>
|
||||
<Button
|
||||
onPress={() => startLogout()}
|
||||
accessoryRight={CloseOutlineIcon}
|
||||
|
@ -214,56 +192,29 @@ export const Login = ({ navigation }) => {
|
|||
</View>
|
||||
</Layout>
|
||||
) : (
|
||||
<Layout
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: 24,
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<View style={{ justifyContent: 'flex-end' }}>
|
||||
<Layout style={styles.loginWrap}>
|
||||
<View style={styles.loginContent}>
|
||||
<Text
|
||||
category="h2"
|
||||
style={{ textAlign: 'center' }}
|
||||
style={styles.title}
|
||||
adjustsFontSizeToFit
|
||||
numberOfLines={1}
|
||||
>
|
||||
Öppna Skolplattformen
|
||||
</Text>
|
||||
<Text
|
||||
category="h6"
|
||||
style={{
|
||||
color: '#9CA3AF',
|
||||
marginTop: 4,
|
||||
marginBottom: 32,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Text category="h6" style={styles.subtitle}>
|
||||
Det {argument} alternativet
|
||||
</Text>
|
||||
<Image
|
||||
source={require('../assets/boys.png')}
|
||||
style={{
|
||||
height: 320,
|
||||
marginTop: -20,
|
||||
marginLeft: -10,
|
||||
width: '110%',
|
||||
}}
|
||||
style={styles.boysImage}
|
||||
/>
|
||||
<View
|
||||
style={{
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'flex-start',
|
||||
paddingHorizontal: 20,
|
||||
paddingBottom: 72,
|
||||
marginTop: 48,
|
||||
}}
|
||||
>
|
||||
<View style={styles.socialSecurityNumberWrap}>
|
||||
<Input
|
||||
label="Personnummer"
|
||||
autoFocus
|
||||
value={ssnValue}
|
||||
style={{ minHeight: 70 }}
|
||||
style={styles.socialSecurityNumber}
|
||||
accessoryLeft={PersonIcon}
|
||||
accessoryRight={clearInput}
|
||||
keyboardType="numeric"
|
||||
|
@ -278,7 +229,7 @@ export const Login = ({ navigation }) => {
|
|||
onPress={async () =>
|
||||
await startLogin(socialSecurityNumber)
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
style={styles.bankIdButton}
|
||||
appearence="ghost"
|
||||
disabled={!valid}
|
||||
status="primary"
|
||||
|
@ -298,7 +249,7 @@ export const Login = ({ navigation }) => {
|
|||
onBackdropPress={() => showModal(false)}
|
||||
>
|
||||
<Card disabled>
|
||||
<Text style={{ margin: 10 }}>Väntar på BankID...</Text>
|
||||
<Text style={styles.bankIdLoading}>Väntar på BankID...</Text>
|
||||
|
||||
<Button visible={!isLoggedIn} onPress={() => showModal(false)}>
|
||||
Avbryt
|
||||
|
@ -313,6 +264,8 @@ export const Login = ({ navigation }) => {
|
|||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
keyboardAvoidingView: { flex: 1 },
|
||||
safeArea: { flex: 1, backgroundColor: '#fff' },
|
||||
container: {
|
||||
minHeight: 192,
|
||||
},
|
||||
|
@ -322,4 +275,54 @@ const styles = StyleSheet.create({
|
|||
backdrop: {
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
},
|
||||
title: { textAlign: 'center' },
|
||||
subtitle: {
|
||||
color: '#9CA3AF',
|
||||
marginTop: 4,
|
||||
marginBottom: 32,
|
||||
textAlign: 'center',
|
||||
},
|
||||
boysImage: {
|
||||
height: 320,
|
||||
marginTop: -20,
|
||||
marginLeft: -10,
|
||||
width: '110%',
|
||||
},
|
||||
socialSecurityNumberWrap: {
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'flex-start',
|
||||
paddingHorizontal: 20,
|
||||
paddingBottom: 72,
|
||||
marginTop: 48,
|
||||
},
|
||||
socialSecurityNumber: { minHeight: 70 },
|
||||
bankIdButton: { width: '100%' },
|
||||
bankIdLoading: { margin: 10 },
|
||||
|
||||
loggedInWrap: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
loggedInImage: {
|
||||
maxHeight: 300,
|
||||
width: '100%',
|
||||
},
|
||||
loggedInText: {
|
||||
textAlign: 'center',
|
||||
marginBottom: 20,
|
||||
marginTop: 10,
|
||||
},
|
||||
loggedInContent: {
|
||||
marginTop: 32,
|
||||
},
|
||||
logoutButton: { marginTop: 10 },
|
||||
|
||||
loginWrap: {
|
||||
flex: 1,
|
||||
padding: 24,
|
||||
justifyContent: 'center',
|
||||
},
|
||||
loginContent: { justifyContent: 'flex-end' },
|
||||
})
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
import { Text } from '@ui-kitten/components'
|
||||
import React from 'react'
|
||||
import { Linking } from 'react-native'
|
||||
import { Linking, StyleSheet } from 'react-native'
|
||||
import MarkdownBase from 'react-native-markdown-display'
|
||||
import { Image } from './image.component'
|
||||
|
||||
const rules = {
|
||||
image: (node) => {
|
||||
const { src } = node.attributes
|
||||
const url = src.startsWith('/') ? `https://elevstockholm.sharepoint.com${src}` : src;
|
||||
return (
|
||||
<Image
|
||||
key={src}
|
||||
src={url}
|
||||
style={{ width: '100%', minHeight: 300 }}
|
||||
/>
|
||||
)
|
||||
const url = src.startsWith('/')
|
||||
? `https://elevstockholm.sharepoint.com${src}`
|
||||
: src
|
||||
return <Image key={src} src={url} style={styles.markdownImage} />
|
||||
},
|
||||
link: (node, children, _parent, styles) => {
|
||||
return (
|
||||
|
@ -36,3 +32,7 @@ export const Markdown = ({ style, children }) => {
|
|||
</MarkdownBase>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
markdownImage: { width: '100%', minHeight: 300 },
|
||||
})
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
"@ui-kitten/metro-config": "5.0.0",
|
||||
"babel-jest": "^26.6.3",
|
||||
"eslint": "^7.19.0",
|
||||
"eslint-config-prettier": "^8.0.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"jest": "^26.6.3",
|
||||
"metro-react-native-babel-preset": "^0.65.0",
|
||||
"mockdate": "^3.0.2",
|
||||
|
|
|
@ -3370,6 +3370,11 @@ eslint-config-prettier@^6.10.1:
|
|||
dependencies:
|
||||
get-stdin "^6.0.0"
|
||||
|
||||
eslint-config-prettier@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.0.0.tgz#024d661444319686c588c8849c8da33815dbdb1c"
|
||||
integrity sha512-5EaAVPsIHu+grmm5WKjxUia4yHgRrbkd8I0ffqUSwixCPMVBrbS97UnzlEY/Q7OWo584vgixefM0kJnUfo/VjA==
|
||||
|
||||
eslint-plugin-eslint-comments@^3.1.2:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
|
||||
|
@ -3397,6 +3402,13 @@ eslint-plugin-prettier@3.1.2:
|
|||
dependencies:
|
||||
prettier-linter-helpers "^1.0.0"
|
||||
|
||||
eslint-plugin-prettier@^3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz#7079cfa2497078905011e6f82e8dd8453d1371b7"
|
||||
integrity sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==
|
||||
dependencies:
|
||||
prettier-linter-helpers "^1.0.0"
|
||||
|
||||
eslint-plugin-react-hooks@^4.0.4:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556"
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "babel-eslint",
|
||||
"extends": ["prettier", "eslint:recommended", "plugin:react/recommended"],
|
||||
"plugins": ["prettier"],
|
||||
"env": { "browser": true, "node": true, "jest": true },
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
// No typing in project
|
||||
"react/prop-types": "off",
|
||||
// React included automatically in Next.js
|
||||
"react/react-in-jsx-scope": "off",
|
||||
// Allow unescaped characters like '
|
||||
"react/no-unescaped-entities": "off"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
root: true
|
||||
parser: babel-eslint
|
||||
extends:
|
||||
- prettier
|
||||
- 'eslint:recommended'
|
||||
- 'plugin:react/recommended'
|
||||
plugins:
|
||||
- prettier
|
||||
env:
|
||||
browser: true
|
||||
node: true
|
||||
jest: true
|
||||
settings:
|
||||
react:
|
||||
version: "detect"
|
||||
rules:
|
||||
# No typing in project
|
||||
"react/prop-types": "off"
|
||||
# React included automatically in Next.js
|
||||
"react/react-in-jsx-scope": "off"
|
||||
# Allow unescaped characters like '
|
||||
"react/no-unescaped-entities": "off"
|
Loading…
Reference in New Issue