Skip to content

Commit

Permalink
fix: lint and prettier fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
edenstrom committed Oct 6, 2021
1 parent 97b4380 commit 169b536
Show file tree
Hide file tree
Showing 53 changed files with 13,655 additions and 14,955 deletions.
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false
"bracketSpacing": true
}
7 changes: 6 additions & 1 deletion apps/skolplattformen-sthlm/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"extends": [
"@react-native-community",
"plugin:react-native-a11y/all",
"plugin:@nrwl/nx/react",
"../../.eslintrc.json"
],
"ignorePatterns": ["!**/*", "public", ".cache", "node_modules"],
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion apps/skolplattformen-sthlm/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false
"bracketSameLine": false
}
5 changes: 1 addition & 4 deletions apps/skolplattformen-sthlm/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ const reporter = __DEV__
log: (message) => console.log(message),
error: (error, label) => console.error(label, error),
}
: {
log: () => {},
error: () => {},
}
: undefined

if (__DEV__) {
const DevMenu = require('react-native-dev-menu')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const setup = (customProps = {}) => {
beforeAll(() => {
// Hide errors from act
// https://github.com/callstack/react-native-testing-library/issues/379
jest.spyOn(console, 'error').mockImplementation(() => {})
jest.spyOn(console, 'error').mockImplementation(() => {
// noop
})
})

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const setup = (customProps = {}) => {
beforeAll(() => {
// Hide errors from state illegal state transition
// Probably due to mock
jest.spyOn(console, 'error').mockImplementation(() => {})
jest.spyOn(console, 'error').mockImplementation(() => {
// noop
})
})

beforeEach(jest.clearAllMocks)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fireEvent } from '@testing-library/react-native'
import React from 'react'
import RNCalendarEvents from 'react-native-calendar-events'
import Toast from 'react-native-simple-toast'
import { render } from '../../utils/testHelpers'
import { SaveToCalendar } from '../saveToCalendar.component'
import Toast from 'react-native-simple-toast'

jest.mock('react-native-simple-toast', () => ({
SHORT: 'short',
Expand Down Expand Up @@ -53,7 +53,9 @@ const setup = (customProps = {}) => {
beforeAll(() => {
// Hide errors from state illegal state transition
// Probably due to mock
jest.spyOn(console, 'error').mockImplementation(() => {})
jest.spyOn(console, 'error').mockImplementation(() => {
// noop
})
})

beforeEach(jest.clearAllMocks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ type ChildListItemNavigationProp = StackNavigationProp<

export const ChildListItem = ({ child, color }: ChildListItemProps) => {
// Forces rerender when child.id changes
React.useEffect(() => {}, [child.id])
React.useEffect(() => {
// noop
}, [child.id])

const navigation = useNavigation<ChildListItemNavigationProp>()
const { t } = useTranslation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Notification = ({ item }: NotificationProps) => {
const date = item.dateModified || item.dateCreated
const displayDate = date ? moment(date).fromNow() : null

const sharedCookiesEnabled: boolean = Boolean(
const sharedCookiesEnabled = Boolean(
item.url && item.url.startsWith('https://start.unikum.net/')
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SaveToCalendar = ({ event }: SaveToCalendarProps) => {
const toast = (text: string) =>
Toast.showWithGravity(text, Toast.SHORT, Toast.BOTTOM)

function removeEmptyValues<T extends object>(obj: T) {
function removeEmptyValues<T extends Record<string, unknown>>(obj: T) {
return Object.fromEntries(
Object.entries(obj).filter(([_, v]) => v != null)
) as { [K in keyof T]: any }
Expand Down
8 changes: 6 additions & 2 deletions apps/skolplattformen-sthlm/hooks/useAsyncStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ export default function useAsyncStorage<T>(
if (!storageKey) return
await AsyncStorage.setItem(storageKey, JSON.stringify(value))
setStorageItem(value)
} catch (e) {}
} catch (e) {
// noop
}
}

useEffect(() => {
async function getStoredValue() {
try {
const data = await AsyncStorage.getItem(storageKey)
if (typeof data === 'string') setStorageItem(JSON.parse(data))
} catch (e) {}
} catch (e) {
// noop
}
}

getStoredValue()
Expand Down
2 changes: 1 addition & 1 deletion apps/skolplattformen-sthlm/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module.exports = {
'react-native/jest/assetFileTransformer.js'
),
},
};
}
2 changes: 1 addition & 1 deletion apps/skolplattformen-sthlm/services/languageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const rtlList: { [key: string]: boolean } = {
}

export const isRTL = (langCode: string) => {
if (!rtlList.hasOwnProperty(langCode)) {
if (!Object.prototype.hasOwnProperty.call(rtlList, langCode)) {
return false
}
return rtlList[langCode]
Expand Down
14 changes: 8 additions & 6 deletions apps/skolplattformen-sthlm/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import '@testing-library/jest-native/extend-expect';
import moment from 'moment';
import 'moment/locale/sv';
import 'react-native-gesture-handler/jestSetup';
import '@testing-library/jest-native/extend-expect'
import moment from 'moment'
import 'moment/locale/sv'
import 'react-native-gesture-handler/jestSetup'

moment.locale('sv')

// Silence useNativeDriver error
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')

jest.mock('react-native-reanimated', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Reanimated = require('react-native-reanimated/mock')

// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
Reanimated.default.call = () => {}
Reanimated.default.call = () => {
// noop
}

return Reanimated
})

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { translate, translations } from '../translation'

describe('translation in swedish', () => {
beforeAll(() => {
i18n.translations = { ['sv']: translations.sv }
i18n.translations = { sv: translations.sv }
i18n.locale = 'sv'
})
it('should be able to translate the word settings', () => {
Expand All @@ -13,7 +13,7 @@ describe('translation in swedish', () => {

describe('translation in english', () => {
beforeAll(() => {
i18n.translations = { ['en']: translations.en }
i18n.translations = { en: translations.en }
i18n.locale = 'en'
})
it('should be able to translate the word settings', () => {
Expand Down
1 change: 1 addition & 0 deletions apps/skolplattformen-sthlm/utils/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useChild } from '../components/childContext.component'
import { Typography } from '../styles'

// https://github.com/facebook/react-native/issues/14796#issuecomment-389743259
// eslint-disable-next-line @typescript-eslint/no-var-requires
global.Buffer = global.Buffer || require('buffer').Buffer

const NUM_CHARS_AROUND_SEARCH_MATCH = 20
Expand Down
2 changes: 1 addition & 1 deletion apps/website/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false
"bracketSameLine": false
}
2 changes: 1 addition & 1 deletion libs/api-skolplattformen/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false
"bracketSameLine": false
}
32 changes: 21 additions & 11 deletions libs/api-skolplattformen/devrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const HttpProxyAgent = require('https-proxy-agent')
const agentWrapper = require('./agentFetchWrapper')
const init = require('./dist').default


const [, , personalNumber] = process.argv
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
const cookieJar = new CookieJar()
Expand Down Expand Up @@ -53,11 +52,11 @@ async function run() {
console.log('user')
const user = await api.getUser()
console.log(user)

console.log('children')
const children = await api.getChildren()
console.log(children)
/*
/*
console.log('calendar')
const calendar = await api.getCalendar(children[0])
console.log(calendar)
Expand All @@ -68,29 +67,38 @@ async function run() {
*/
try {
console.log('schedule')
const schedule = await api.getSchedule(children[1], DateTime.local(), DateTime.local().plus({ week: 1 }))
const schedule = await api.getSchedule(
children[1],
DateTime.local(),
DateTime.local().plus({ week: 1 })
)
console.log(schedule)
} catch (error) {
console.error(error)
}

let skola24children
try {
skola24children = await api.getSkola24Children()
console.log(skola24children)
} catch (error) {
console.error(error)
}

try {
console.log('timetable')
const timetable = await api.getTimetable(skola24children[0], 15, 2021, "sv")
console.log(inspect(timetable, false, 1000, true))
const timetable = await api.getTimetable(
skola24children[0],
15,
2021,
'sv'
)
console.log(inspect(timetable, false, 1000, true))
} catch (error) {
console.error(error)
}
/*

/*
console.log('news')
const news = await api.getNews(children[0])
*/
Expand Down Expand Up @@ -216,7 +224,9 @@ const record = async (info, data) => {
}

// Hack to keep it running while wating for await
const timer = setTimeout(() => {}, 999999)
const timer = setTimeout(() => {
// noop
}, 999999)

run()
.then(() => {
Expand Down
Loading

0 comments on commit 169b536

Please sign in to comment.