diff --git a/dangerfile.js b/dangerfile.js index b49a7e45f..d51c14048 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -268,11 +268,9 @@ async function pbxprojDuplicateLinkingPaths() { const buildConfig = xcodeproj.project.objects.XCBuildConfiguration const duplicateSearchPaths = Object.entries(buildConfig) - .filter(([_, val] /*: [string, any]*/) => typeof val === 'object') - .filter( - ([_, val] /*: [string, any]*/) => val.buildSettings.LIBRARY_SEARCH_PATHS, - ) - .filter(([_, val] /*: [string, any]*/) => { + .filter(([_, val]) => typeof val === 'object') + .filter(([_, val]) => val.buildSettings.LIBRARY_SEARCH_PATHS) + .filter(([_, val]) => { const searchPaths = val.buildSettings.LIBRARY_SEARCH_PATHS return uniq(searchPaths).length !== searchPaths.length }) @@ -389,12 +387,9 @@ import util from 'util' const execFile = util.promisify(childProcess.execFile) -function fastlaneBuildLogTail(log /*: Array*/, message /*: string*/) { +function fastlaneBuildLogTail(log, message) { const n = 150 - const logToPost = log - .slice(-n) - .map(stripAnsi) - .join('\n') + const logToPost = log.slice(-n).map(stripAnsi).join('\n') fail( h.details( @@ -405,11 +400,11 @@ function fastlaneBuildLogTail(log /*: Array*/, message /*: string*/) { ) } -const h /*: any*/ = new Proxy( +const h = new Proxy( {}, { get(_, property) { - return function(...children /*: Array*/) { + return function (...children) { if (!children.length) { return `<${property}>` } @@ -420,7 +415,7 @@ const h /*: any*/ = new Proxy( ) const m = { - code(attrs /*: Object*/, ...children /*: Array*/) { + code(attrs, ...children) { return ( '\n' + '```' + @@ -432,12 +427,12 @@ const m = { '\n' ) }, - json(blob /*: any*/) { + json(blob) { return m.code({language: 'json'}, JSON.stringify(blob, null, 2)) }, } -function readFile(filename /*: string*/) { +function readFile(filename) { try { return fs.readFileSync(filename, 'utf-8') } catch (err) { @@ -451,12 +446,12 @@ function readFile(filename /*: string*/) { } } -function readLogFile(filename /*: string*/) { +function readLogFile(filename) { return readFile(filename).trim() } // eslint-disable-next-line no-unused-vars -function readJsonLogFile(filename /*: string*/) { +function readJsonLogFile(filename) { try { return JSON.parse(readFile(filename)) } catch (err) { @@ -470,15 +465,11 @@ function readJsonLogFile(filename /*: string*/) { } } -function isBadDataValidationLog(log /*: string*/) { +function isBadDataValidationLog(log) { return log.split('\n').some(l => !l.endsWith('is valid')) } -function fileLog( - name /*: string*/, - log /*: string*/, - {lang = null} /*: any*/ = {}, -) { +function fileLog(name, log, {lang = null} = {}) { return markdown( `## ${name} @@ -486,7 +477,7 @@ ${m.code({language: lang}, log)}`, ) } -function parseXcodeProject(pbxprojPath /*: string*/) /*: Promise*/ { +function parseXcodeProject(pbxprojPath) { return new Promise((resolve, reject) => { const project = xcode.project(pbxprojPath) // I think this can be called twice from .parse, which is an error for a Promise @@ -506,7 +497,7 @@ function parseXcodeProject(pbxprojPath /*: string*/) /*: Promise*/ { } // eslint-disable-next-line no-unused-vars -async function listZip(filepath /*: string*/) { +async function listZip(filepath) { try { const {stdout} = await execFile('unzip', ['-l', filepath]) const lines = stdout.split('\n') @@ -531,7 +522,7 @@ async function listZip(filepath /*: string*/) { } } -function listDirectory(dirpath /*: string*/) { +function listDirectory(dirpath) { try { return fs.readdirSync(dirpath) } catch (err) { @@ -541,7 +532,7 @@ function listDirectory(dirpath /*: string*/) { } // eslint-disable-next-line no-unused-vars -function listDirectoryTree(dirpath /*: string*/) /*: any*/ { +function listDirectoryTree(dirpath) { try { const exists = fs.accessSync(dirpath, fs.F_OK) @@ -566,7 +557,7 @@ function listDirectoryTree(dirpath /*: string*/) /*: any*/ { } } -async function didNativeDependencyChange() /*: Promise*/ { +async function didNativeDependencyChange() { const diff = await danger.git.JSONDiffForFile('package.json') if (!diff.dependencies && !diff.devDependencies) { diff --git a/package.json b/package.json index fdb8c2f72..3552534f9 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "singleQuote": true, "trailingComma": "all", "bracketSpacing": false, + "arrowParens": "avoid", "semi": false }, "dependencies": { diff --git a/scripts/bundle-data.js b/scripts/bundle-data.js index b0d8924ea..0b6e40310 100755 --- a/scripts/bundle-data.js +++ b/scripts/bundle-data.js @@ -5,20 +5,20 @@ const path = require('path') const bundleDataDir = require('./bundle-data-dir') const convertDataFile = require('./convert-data-file') -const isDir = (pth) => fs.statSync(pth).isDirectory() -const isFile = (pth) => fs.statSync(pth).isFile() +const isDir = pth => fs.statSync(pth).isDirectory() +const isFile = pth => fs.statSync(pth).isFile() -const readDir = (pth) => +const readDir = pth => fs .readdirSync(pth) .filter(junk.not) - .filter((entry) => !entry.startsWith('_')) + .filter(entry => !entry.startsWith('_')) -const findDirsIn = (pth) => - readDir(pth).filter((entry) => isDir(path.join(pth, entry))) +const findDirsIn = pth => + readDir(pth).filter(entry => isDir(path.join(pth, entry))) -const findFilesIn = (pth) => - readDir(pth).filter((entry) => isFile(path.join(pth, entry))) +const findFilesIn = pth => + readDir(pth).filter(entry => isFile(path.join(pth, entry))) const args = process.argv.slice(2) const fromDir = args[0] @@ -32,7 +32,7 @@ fs.mkdirSync(toDir, {recursive: true}) // Bundle each directory of yaml files into one big json file const dirs = findDirsIn(fromDir) -dirs.forEach((dirname) => { +dirs.forEach(dirname => { const input = path.join(fromDir, dirname) const output = path.join(toDir, dirname) + '.json' console.log(`bundle-data-dir ${input} ${output}`) @@ -43,7 +43,7 @@ dirs.forEach((dirname) => { // Convert these files into JSON equivalents const files = findFilesIn(fromDir) -files.forEach((file) => { +files.forEach(file => { // Get the absolute paths to the input and output files const input = path.join(fromDir, file) const output = path.join(toDir, file).replace(/\.(.*)$/, '.json') diff --git a/scripts/make-icons.js b/scripts/make-icons.js index 8eb182d24..db3140097 100644 --- a/scripts/make-icons.js +++ b/scripts/make-icons.js @@ -10,7 +10,15 @@ const resize = (img, width, toFile) => spawn('convert', img, '-resize', `${width}x${width}`, toFile) // iOS app icons -const iosSizes = [[29, 1], [29, 2], [29, 3], [40, 2], [40, 3], [60, 2], [60, 3]] +const iosSizes = [ + [29, 1], + [29, 2], + [29, 3], + [40, 2], + [40, 3], + [60, 2], + [60, 3], +] for (const [width, density] of iosSizes) { resize( source, @@ -20,7 +28,11 @@ for (const [width, density] of iosSizes) { } // iTunes icons -const itunes = [[512, 1], [1024, 2], [1536, 3]] +const itunes = [ + [512, 1], + [1024, 2], + [1536, 3], +] for (const [width, density] of itunes) { resize(source, width, `icons/ios/iTunesArtwork@${density}x.png`) } diff --git a/source/globalize-fetch.js b/source/globalize-fetch.js index 527d151d1..5976e2a9d 100644 --- a/source/globalize-fetch.js +++ b/source/globalize-fetch.js @@ -19,7 +19,7 @@ function json(response) { } // make fetch() calls throw if the server returns a non-200 status code -global.fetch = function(input, opts: {[key: string]: any} = {}) { +global.fetch = function (input, opts: {[key: string]: any} = {}) { if (opts) { opts.headers = opts.headers || new Headers({}) diff --git a/source/lib/cache.js b/source/lib/cache.js index 4cdbe355b..1e4a62cb4 100644 --- a/source/lib/cache.js +++ b/source/lib/cache.js @@ -194,21 +194,15 @@ type BalancesOutputType = { _isCached: boolean, } export async function getBalances(): Promise { - const [ - schillers, - dining, - print, - daily, - weekly, - guestSwipes, - ] = await Promise.all([ - getSchillersBalance(), - getDiningBalance(), - getPrintBalance(), - getDailyMealInfo(), - getWeeklyMealInfo(), - getGuestSwipes(), - ]) + const [schillers, dining, print, daily, weekly, guestSwipes] = + await Promise.all([ + getSchillersBalance(), + getDiningBalance(), + getPrintBalance(), + getDailyMealInfo(), + getWeeklyMealInfo(), + getGuestSwipes(), + ]) const _isExpired = schillers.isExpired || diff --git a/source/lib/courses/parse-courses.js b/source/lib/courses/parse-courses.js index 1c13a2e01..7cdc30bf5 100644 --- a/source/lib/courses/parse-courses.js +++ b/source/lib/courses/parse-courses.js @@ -67,7 +67,8 @@ function rowToCourse(domRow: Object, term: string): CourseType { return result } -const deptNumRegex = /(([A-Z]+)(?=\/)(?:\/)([A-Z]+)|[A-Z]+) *([0-9]{3,}?) *([A-Z]?)/i +const deptNumRegex = + /(([A-Z]+)(?=\/)(?:\/)([A-Z]+)|[A-Z]+) *([0-9]{3,}?) *([A-Z]?)/i // Splits a deptnum string (like "AS/RE 230A") into its components, // like {depts: ['AS', 'RE'], num: 230, sect: 'A'}. diff --git a/source/lib/html.js b/source/lib/html.js index 9f8287359..339f2d91f 100644 --- a/source/lib/html.js +++ b/source/lib/html.js @@ -37,10 +37,7 @@ export function getTextWithSpaces(elem: DOMElement): string { } export function getTrimmedTextWithSpaces(elem: DOMElement): string { - return getTextWithSpaces(elem) - .split(/\s+/) - .join(' ') - .trim() + return getTextWithSpaces(elem).split(/\s+/).join(' ').trim() } export function removeHtmlWithRegex(str: string): string { @@ -48,7 +45,5 @@ export function removeHtmlWithRegex(str: string): string { } export function fastGetTrimmedText(str: string): string { - return removeHtmlWithRegex(str) - .replace(/\s+/g, ' ') - .trim() + return removeHtmlWithRegex(str).replace(/\s+/g, ' ').trim() } diff --git a/source/lib/promise-timeout.js b/source/lib/promise-timeout.js index 3aa285f4a..05d6e5050 100644 --- a/source/lib/promise-timeout.js +++ b/source/lib/promise-timeout.js @@ -4,18 +4,18 @@ export function promiseTimeout( ms: number, promise: Promise, ): Promise { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { // create a timeout to reject promise if not resolved - let timer = setTimeout(function() { + let timer = setTimeout(function () { reject(new Error('promise timeout')) }, ms) promise - .then(function(res) { + .then(function (res) { clearTimeout(timer) resolve(res) }) - .catch(function(err) { + .catch(function (err) { clearTimeout(timer) reject(err) }) diff --git a/source/views/building-hours/detail/toolbar-button.js b/source/views/building-hours/detail/toolbar-button.js index 3682bc761..f4d4b64c5 100644 --- a/source/views/building-hours/detail/toolbar-button.js +++ b/source/views/building-hours/detail/toolbar-button.js @@ -44,6 +44,7 @@ function mapDispatch(dispatch): ReduxDispatchProps { } } -export const ConnectedBuildingFavoriteButton = connect(mapState, mapDispatch)( - BuildingFavoriteButton, -) +export const ConnectedBuildingFavoriteButton = connect( + mapState, + mapDispatch, +)(BuildingFavoriteButton) diff --git a/source/views/building-hours/lib/chapel.js b/source/views/building-hours/lib/chapel.js index c9b9e8cf7..966e63938 100644 --- a/source/views/building-hours/lib/chapel.js +++ b/source/views/building-hours/lib/chapel.js @@ -51,8 +51,5 @@ export function getTimeUntilChapelCloses( let {close} = parseHours(sched, m) - return m - .clone() - .seconds(0) - .to(close) + return m.clone().seconds(0).to(close) } diff --git a/source/views/building-hours/lib/get-schedule-status.js b/source/views/building-hours/lib/get-schedule-status.js index bb5dbc4fe..4d74606e5 100644 --- a/source/views/building-hours/lib/get-schedule-status.js +++ b/source/views/building-hours/lib/get-schedule-status.js @@ -4,17 +4,9 @@ import type {SingleBuildingScheduleType} from '../types' import {parseHours} from './parse-hours' -const in30 = (start, end) => - start - .clone() - .add(30, 'minutes') - .isSameOrAfter(end) - -const timeBetween = (start, end) => - start - .clone() - .seconds(0) - .to(end) +const in30 = (start, end) => start.clone().add(30, 'minutes').isSameOrAfter(end) + +const timeBetween = (start, end) => start.clone().seconds(0).to(end) export function getScheduleStatusAtMoment( schedule: SingleBuildingScheduleType, diff --git a/source/views/building-hours/report/editor.js b/source/views/building-hours/report/editor.js index 3f82d0536..7afe7e819 100644 --- a/source/views/building-hours/report/editor.js +++ b/source/views/building-hours/report/editor.js @@ -62,7 +62,10 @@ export class BuildingHoursScheduleEditorView extends React.PureComponent< onChangeOpen = (newDate: moment) => { this.setState( - state => ({...state, set: {...state.set, from: newDate.format('h:mma')}}), + state => ({ + ...state, + set: {...state.set, from: newDate.format('h:mma')}, + }), () => this.props.navigation.state.params.onEditSet(this.state.set), ) } diff --git a/source/views/building-hours/row.js b/source/views/building-hours/row.js index afa97611b..1734accd8 100644 --- a/source/views/building-hours/row.js +++ b/source/views/building-hours/row.js @@ -144,7 +144,7 @@ export class BuildingRow extends React.Component { status={status} /> - )) + )) : null} diff --git a/source/views/building-hours/stateful-list.js b/source/views/building-hours/stateful-list.js index 9647a810b..5aa37ab29 100644 --- a/source/views/building-hours/stateful-list.js +++ b/source/views/building-hours/stateful-list.js @@ -146,6 +146,5 @@ function mapStateToProps(state: ReduxState): ReduxStateProps { } } -export const ConnectedBuildingHoursView = connect(mapStateToProps)( - BuildingHoursView, -) +export const ConnectedBuildingHoursView = + connect(mapStateToProps)(BuildingHoursView) diff --git a/source/views/components/cells/__tests__/toggle.test.js b/source/views/components/cells/__tests__/toggle.test.js index d45f68c5e..d3400ebe8 100644 --- a/source/views/components/cells/__tests__/toggle.test.js +++ b/source/views/components/cells/__tests__/toggle.test.js @@ -37,10 +37,7 @@ xtest('calls the given function when the Switch is pressed', () => { const tree = shallow() - tree - .find('Cell') - .prop('cellAccessoryView') - .props.onValueChange() + tree.find('Cell').prop('cellAccessoryView').props.onValueChange() expect(cb).toHaveBeenCalled() }) diff --git a/source/views/components/cells/multi-line-left-detail.js b/source/views/components/cells/multi-line-left-detail.js index 738b44598..138b2317a 100644 --- a/source/views/components/cells/multi-line-left-detail.js +++ b/source/views/components/cells/multi-line-left-detail.js @@ -10,9 +10,7 @@ type LeftDetailProps = { title: string, } -export class MultiLineLeftDetailCell extends React.PureComponent< - LeftDetailProps, -> { +export class MultiLineLeftDetailCell extends React.PureComponent { render() { const {detail, title} = this.props const cellContent = ( diff --git a/source/views/components/datepicker/datepicker.android.js b/source/views/components/datepicker/datepicker.android.js index a74cd3877..a7c4acde0 100644 --- a/source/views/components/datepicker/datepicker.android.js +++ b/source/views/components/datepicker/datepicker.android.js @@ -75,19 +75,17 @@ export class DatePicker extends React.PureComponent { }).then(this.onDatetimeTimePicked(year, month, day)) } - onDatetimeTimePicked = (year: number, month: number, day: number) => ({ - action, - hour, - minute, - }: TimePickerResponse) => { - if (action === DatePickerAndroid.dismissedAction) { - return - } + onDatetimeTimePicked = + (year: number, month: number, day: number) => + ({action, hour, minute}: TimePickerResponse) => { + if (action === DatePickerAndroid.dismissedAction) { + return + } - this.props.onDateChange( - moment.tz({year, month, day, hour, minute}, this.props.timezone), - ) - } + this.props.onDateChange( + moment.tz({year, month, day, hour, minute}, this.props.timezone), + ) + } showModal = () => { const {mode, androidMode} = this.props diff --git a/source/views/components/filter/filter-view.js b/source/views/components/filter/filter-view.js index 8dc24d93c..026b05556 100644 --- a/source/views/components/filter/filter-view.js +++ b/source/views/components/filter/filter-view.js @@ -51,8 +51,8 @@ class FilterViewComponent extends React.PureComponent { onFilterChanged = (filter: FilterType) => { const {onChange} = this.props.navigation.state.params // replace the changed filter in the array, maintaining position - let result = this.props.filters.map( - f => (f.key !== filter.key ? f : filter), + let result = this.props.filters.map(f => + f.key !== filter.key ? f : filter, ) onChange(result) } diff --git a/source/views/components/filter/section-list.js b/source/views/components/filter/section-list.js index 338c6c9a3..b43830122 100644 --- a/source/views/components/filter/section-list.js +++ b/source/views/components/filter/section-list.js @@ -81,9 +81,7 @@ export function ListSection({filter, onChange}: PropsType) { image={ spec.showImages ? ( - ) : ( - undefined - ) + ) : undefined } onPress={() => buttonPushed(val)} /> diff --git a/source/views/components/tabbar-icon.js b/source/views/components/tabbar-icon.js index 3f439fd26..5cf257139 100644 --- a/source/views/components/tabbar-icon.js +++ b/source/views/components/tabbar-icon.js @@ -9,15 +9,11 @@ const styles = StyleSheet.create({ }, }) -export const TabBarIcon = (icon: string) => ({ - tintColor, - focused, -}: { - tintColor: string, - focused: boolean, -}) => ( - -) +export const TabBarIcon = + (icon: string) => + ({tintColor, focused}: {tintColor: string, focused: boolean}) => ( + + ) diff --git a/source/views/contacts/detail.js b/source/views/contacts/detail.js index c201d20be..859eceaf1 100644 --- a/source/views/contacts/detail.js +++ b/source/views/contacts/detail.js @@ -56,11 +56,8 @@ export class ContactsDetailView extends React.PureComponent { } onPress = () => { - const { - phoneNumber, - buttonText, - buttonLink, - } = this.props.navigation.state.params.contact + const {phoneNumber, buttonText, buttonLink} = + this.props.navigation.state.params.contact if (buttonLink) { openUrl(buttonLink) } else if (phoneNumber) { diff --git a/source/views/covid/updates-row.js b/source/views/covid/updates-row.js index be4bbda41..3f44ab5cb 100644 --- a/source/views/covid/updates-row.js +++ b/source/views/covid/updates-row.js @@ -24,10 +24,7 @@ export class UpdatesRow extends React.PureComponent { } calculateFromNow = (publishedOffset: moment) => { - const today = moment - .utc() - .tz(TIMEZONE) - .startOf('day') + const today = moment.utc().tz(TIMEZONE).startOf('day') if (today.isAfter(publishedOffset, 'day')) { return moment.duration(publishedOffset - today).humanize(true) diff --git a/source/views/dictionary/list.js b/source/views/dictionary/list.js index 022b45108..b7592f58c 100644 --- a/source/views/dictionary/list.js +++ b/source/views/dictionary/list.js @@ -147,7 +147,7 @@ export class DictionaryView extends React.PureComponent { cell={this.renderRow} cellHeight={ ROW_HEIGHT + - (Platform.OS === 'ios' ? 11 / 12 * StyleSheet.hairlineWidth : 0) + (Platform.OS === 'ios' ? (11 / 12) * StyleSheet.hairlineWidth : 0) } data={groupBy(results, item => item.word[0])} onSearch={this.performSearch} diff --git a/source/views/dictionary/report/__tests__/stringify-entry.test.js b/source/views/dictionary/report/__tests__/stringify-entry.test.js index 020facdbf..64aebbc5a 100644 --- a/source/views/dictionary/report/__tests__/stringify-entry.test.js +++ b/source/views/dictionary/report/__tests__/stringify-entry.test.js @@ -23,8 +23,7 @@ test('handles long definitions', () => { test('handles long words', () => { let def = { - word: - 'Academic Civic Engagement. These are courses that include a component of learning in the community with non-profit or governmental partners.', + word: 'Academic Civic Engagement. These are courses that include a component of learning in the community with non-profit or governmental partners.', definition: 'foo', } expect(stringifyDictionaryEntry(def)).toMatchSnapshot() diff --git a/source/views/home/edit/list.android.js b/source/views/home/edit/list.android.js index 24f5dafc0..e5e205085 100644 --- a/source/views/home/edit/list.android.js +++ b/source/views/home/edit/list.android.js @@ -118,6 +118,7 @@ function mapDispatch(dispatch): ReduxDispatchProps { } } -export const ConnectedEditHomeView = connect(mapState, mapDispatch)( - EditHomeView, -) +export const ConnectedEditHomeView = connect( + mapState, + mapDispatch, +)(EditHomeView) diff --git a/source/views/home/edit/list.ios.js b/source/views/home/edit/list.ios.js index b69170562..8fcdeae42 100644 --- a/source/views/home/edit/list.ios.js +++ b/source/views/home/edit/list.ios.js @@ -105,6 +105,7 @@ function mapDispatch(dispatch): ReduxDispatchProps { } } -export const ConnectedEditHomeView = connect(mapState, mapDispatch)( - EditHomeView, -) +export const ConnectedEditHomeView = connect( + mapState, + mapDispatch, +)(EditHomeView) diff --git a/source/views/map-carls/mapbox.js b/source/views/map-carls/mapbox.js index 01a7ee4dc..31fd23e7e 100644 --- a/source/views/map-carls/mapbox.js +++ b/source/views/map-carls/mapbox.js @@ -144,9 +144,9 @@ export class MapView extends React.Component { const latitude = this.state.overlaySize === 'min' ? // case 1: overlay is collapsed; center in viewport - coordinates[1] + coordinates[1] : // case 2: overlay is open; center above overlay - coordinates[1] - 0.0005 + coordinates[1] - 0.0005 this._map.setCamera({ centerCoordinate: [coordinates[0], latitude], diff --git a/source/views/map-carls/types.js b/source/views/map-carls/types.js index 8a34ca7b5..b005fa067 100644 --- a/source/views/map-carls/types.js +++ b/source/views/map-carls/types.js @@ -14,9 +14,10 @@ export type Category = // "Label " export opaque type LabelLinkString = string -export function parseLinkString( - str: LabelLinkString, -): {label: string, href: string} { +export function parseLinkString(str: LabelLinkString): { + label: string, + href: string, +} { let regex = /^(.*) <(.*)>$/ let matches = regex.exec(str) return {label: matches[1], href: matches[2]} diff --git a/source/views/settings/sections/login-credentials.js b/source/views/settings/sections/login-credentials.js index 78224e00a..4de41a1cb 100644 --- a/source/views/settings/sections/login-credentials.js +++ b/source/views/settings/sections/login-credentials.js @@ -71,7 +71,7 @@ class CredentialsLoginSection extends React.PureComponent { return (
@@ -108,7 +108,7 @@ class CredentialsLoginSection extends React.PureComponent { )} { keyExtractor = (item: string) => item render() { - const { - items, - actionLabel, - onAction, - title, - emptyHeader, - emptyText, - } = this.props + const {items, actionLabel, onAction, title, emptyHeader, emptyText} = + this.props return ( diff --git a/source/views/sis/course-search/search.js b/source/views/sis/course-search/search.js index d45c2f20b..620cbfbc9 100644 --- a/source/views/sis/course-search/search.js +++ b/source/views/sis/course-search/search.js @@ -105,9 +105,7 @@ function executeSearch(args: { (course.instructors || []).some(name => keywordSearch(query, name.toLowerCase()), ) || - deptNum(course) - .toLowerCase() - .startsWith(query) || + deptNum(course).toLowerCase().startsWith(query) || (course.gereqs || []).some(gereq => gereq.toLowerCase().startsWith(query), ), @@ -303,7 +301,7 @@ class CourseSearchView extends React.PureComponent { const selectedFilters = selectedFilterCombo ? resetFilters.map( f => selectedFilterCombo.filters.find(f2 => f2.key === f.key) || f, - ) + ) : resetFilters this.props.onFiltersChange(selectedFilters) this.browseAll() @@ -367,13 +365,8 @@ class CourseSearchView extends React.PureComponent { } render() { - const { - searchActive, - searchPerformed, - searchResults, - query, - browsing, - } = this.state + const {searchActive, searchPerformed, searchResults, query, browsing} = + this.state if (this.state.dataLoading) { return diff --git a/source/views/sis/student-work-carls/list.js b/source/views/sis/student-work-carls/list.js index eb786fca9..27aa70065 100644 --- a/source/views/sis/student-work-carls/list.js +++ b/source/views/sis/student-work-carls/list.js @@ -60,9 +60,8 @@ export class StudentWorkView extends React.Component { job => `${job.duringTerm ? 0 : 1}-${job.name}`, ) // now group them - let grouped = groupBy( - sortedJobs, - job => (job.duringTerm ? 'During Term' : 'During Break'), + let grouped = groupBy(sortedJobs, job => + job.duringTerm ? 'During Term' : 'During Break', ) grouped = toPairs(grouped).map(([title, data]) => ({title, data})) this.setState(() => ({jobs: grouped})) diff --git a/source/views/streaming/streams/list.js b/source/views/streaming/streams/list.js index 3a3e3c138..3d1a6f89e 100644 --- a/source/views/streaming/streams/list.js +++ b/source/views/streaming/streams/list.js @@ -72,10 +72,7 @@ export class StreamListView extends React.PureComponent { getStreams = async (date: moment = moment.tz(CENTRAL_TZ)) => { try { const dateFrom = date.format('YYYY-MM-DD') - const dateTo = date - .clone() - .add(1, 'month') - .format('YYYY-MM-DD') + const dateTo = date.clone().add(1, 'month').format('YYYY-MM-DD') let params = { class: 'current', diff --git a/source/views/student-orgs-carls/list.js b/source/views/student-orgs-carls/list.js index 57b96bdf6..836532d9d 100644 --- a/source/views/student-orgs-carls/list.js +++ b/source/views/student-orgs-carls/list.js @@ -166,7 +166,7 @@ export class StudentOrgsView extends React.PureComponent { cell={this.renderRow} cellHeight={ ROW_HEIGHT + - (Platform.OS === 'ios' ? 11 / 12 * StyleSheet.hairlineWidth : 0) + (Platform.OS === 'ios' ? (11 / 12) * StyleSheet.hairlineWidth : 0) } data={this.state.results} onSearch={this.performSearch} diff --git a/source/views/student-orgs/list.js b/source/views/student-orgs/list.js index 687184627..10ea80d4d 100644 --- a/source/views/student-orgs/list.js +++ b/source/views/student-orgs/list.js @@ -206,7 +206,7 @@ export class StudentOrgsView extends React.PureComponent { cell={this.renderRow} cellHeight={ ROW_HEIGHT + - (Platform.OS === 'ios' ? 11 / 12 * StyleSheet.hairlineWidth : 0) + (Platform.OS === 'ios' ? (11 / 12) * StyleSheet.hairlineWidth : 0) } data={groupedResults} onSearch={this.performSearch} diff --git a/source/views/transportation/bus/components/progress-chunk.js b/source/views/transportation/bus/components/progress-chunk.js index 10d2e5ed6..0eb99318b 100644 --- a/source/views/transportation/bus/components/progress-chunk.js +++ b/source/views/transportation/bus/components/progress-chunk.js @@ -57,13 +57,8 @@ type Props = {| export class ProgressChunk extends React.PureComponent { render() { - const { - stopStatus, - barColor, - currentStopColor, - isFirstChunk, - isLastChunk, - } = this.props + const {stopStatus, barColor, currentStopColor, isFirstChunk, isLastChunk} = + this.props // To draw the bar, we draw a chunk of the bar, then we draw the dot, then // we draw the last chunk of the bar. diff --git a/source/views/transportation/bus/lib/index.js b/source/views/transportation/bus/lib/index.js index 59bb6b6fa..6038afe77 100644 --- a/source/views/transportation/bus/lib/index.js +++ b/source/views/transportation/bus/lib/index.js @@ -4,9 +4,7 @@ export {getScheduleForNow} from './get-schedule-for-now' export {parseTime} from './parse-time' export {processBusLine} from './process-bus-line' export {getCurrentBusIteration} from './get-current-bus-iteration' -export { - findRemainingDeparturesForStop, -} from './find-remaining-departures-for-stop' +export {findRemainingDeparturesForStop} from './find-remaining-departures-for-stop' export {findBusStopStatus} from './find-bus-stop-status' export type {BusStateEnum} from './get-current-bus-iteration' diff --git a/source/views/transportation/bus/lib/parse-time.js b/source/views/transportation/bus/lib/parse-time.js index a07857231..3fa536bd5 100644 --- a/source/views/transportation/bus/lib/parse-time.js +++ b/source/views/transportation/bus/lib/parse-time.js @@ -4,19 +4,19 @@ const TIME_FORMAT = 'h:mma' const TIMEZONE = 'America/Winnipeg' import moment from 'moment-timezone' -export const parseTime = (now: moment) => ( - time: string | false, -): null | moment => { - // either pass `false` through or return a parsed time - if (time === false) { - return null - } +export const parseTime = + (now: moment) => + (time: string | false): null | moment => { + // either pass `false` through or return a parsed time + if (time === false) { + return null + } - // interpret in Central time - let m = moment.tz(time, TIME_FORMAT, true, TIMEZONE) + // interpret in Central time + let m = moment.tz(time, TIME_FORMAT, true, TIMEZONE) - // and set the date to today - m.dayOfYear(now.dayOfYear()) + // and set the date to today + m.dayOfYear(now.dayOfYear()) - return m -} + return m + } diff --git a/source/views/transportation/bus/lib/process-bus-line.js b/source/views/transportation/bus/lib/process-bus-line.js index ddd876634..d14a39da9 100644 --- a/source/views/transportation/bus/lib/process-bus-line.js +++ b/source/views/transportation/bus/lib/process-bus-line.js @@ -10,32 +10,34 @@ import type { import {parseTime} from './parse-time' import type moment from 'moment' -export const processBusSchedule = (now: moment) => ( - scheduleData: UnprocessedBusSchedule, -): BusSchedule => { - const times = scheduleData.times.map(timeList => timeList.map(parseTime(now))) - - const timetable = scheduleData.stops.map((stopName, i) => { - let stop = {} - stop.name = stopName - - if (stopName in scheduleData.coordinates) { - stop.coordinates = scheduleData.coordinates[stopName] +export const processBusSchedule = + (now: moment) => + (scheduleData: UnprocessedBusSchedule): BusSchedule => { + const times = scheduleData.times.map(timeList => + timeList.map(parseTime(now)), + ) + + const timetable = scheduleData.stops.map((stopName, i) => { + let stop = {} + stop.name = stopName + + if (stopName in scheduleData.coordinates) { + stop.coordinates = scheduleData.coordinates[stopName] + } + + stop.departures = times.map(timeList => timeList[i]) + + return stop + }) + + return { + days: scheduleData.days, + coordinates: scheduleData.coordinates, + stops: scheduleData.stops, + times: times, + timetable: timetable, } - - stop.departures = times.map(timeList => timeList[i]) - - return stop - }) - - return { - days: scheduleData.days, - coordinates: scheduleData.coordinates, - stops: scheduleData.stops, - times: times, - timetable: timetable, } -} export function processBusLine( lineData: UnprocessedBusLine,