Skip to content

Commit

Permalink
reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkrives committed Dec 11, 2024
1 parent 2f06074 commit 9cfb972
Show file tree
Hide file tree
Showing 40 changed files with 178 additions and 230 deletions.
47 changes: 19 additions & 28 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -389,12 +387,9 @@ import util from 'util'

const execFile = util.promisify(childProcess.execFile)

function fastlaneBuildLogTail(log /*: Array<string>*/, 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(
Expand All @@ -405,11 +400,11 @@ function fastlaneBuildLogTail(log /*: Array<string>*/, message /*: string*/) {
)
}

const h /*: any*/ = new Proxy(
const h = new Proxy(
{},
{
get(_, property) {
return function(...children /*: Array<string>*/) {
return function (...children) {
if (!children.length) {
return `<${property}>`
}
Expand All @@ -420,7 +415,7 @@ const h /*: any*/ = new Proxy(
)

const m = {
code(attrs /*: Object*/, ...children /*: Array<string>*/) {
code(attrs, ...children) {
return (
'\n' +
'```' +
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -470,23 +465,19 @@ 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}
${m.code({language: lang}, log)}`,
)
}

function parseXcodeProject(pbxprojPath /*: string*/) /*: Promise<Object>*/ {
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
Expand All @@ -506,7 +497,7 @@ function parseXcodeProject(pbxprojPath /*: string*/) /*: Promise<Object>*/ {
}

// 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')
Expand All @@ -531,7 +522,7 @@ async function listZip(filepath /*: string*/) {
}
}

function listDirectory(dirpath /*: string*/) {
function listDirectory(dirpath) {
try {
return fs.readdirSync(dirpath)
} catch (err) {
Expand All @@ -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)

Expand All @@ -566,7 +557,7 @@ function listDirectoryTree(dirpath /*: string*/) /*: any*/ {
}
}

async function didNativeDependencyChange() /*: Promise<boolean>*/ {
async function didNativeDependencyChange() {
const diff = await danger.git.JSONDiffForFile('package.json')

if (!diff.dependencies && !diff.devDependencies) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"arrowParens": "avoid",
"semi": false
},
"dependencies": {
Expand Down
20 changes: 10 additions & 10 deletions scripts/bundle-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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}`)
Expand All @@ -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')
Expand Down
16 changes: 14 additions & 2 deletions scripts/make-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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`)
}
Expand Down
2 changes: 1 addition & 1 deletion source/globalize-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({})

Expand Down
24 changes: 9 additions & 15 deletions source/lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,15 @@ type BalancesOutputType = {
_isCached: boolean,
}
export async function getBalances(): Promise<BalancesOutputType> {
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 ||
Expand Down
3 changes: 2 additions & 1 deletion source/lib/courses/parse-courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}.
Expand Down
9 changes: 2 additions & 7 deletions source/lib/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,13 @@ 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 {
return str.replace(/<[^>]*>/g, ' ')
}

export function fastGetTrimmedText(str: string): string {
return removeHtmlWithRegex(str)
.replace(/\s+/g, ' ')
.trim()
return removeHtmlWithRegex(str).replace(/\s+/g, ' ').trim()
}
8 changes: 4 additions & 4 deletions source/lib/promise-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ export function promiseTimeout(
ms: number,
promise: Promise<any>,
): Promise<any> {
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)
})
Expand Down
7 changes: 4 additions & 3 deletions source/views/building-hours/detail/toolbar-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function mapDispatch(dispatch): ReduxDispatchProps {
}
}

export const ConnectedBuildingFavoriteButton = connect(mapState, mapDispatch)(
BuildingFavoriteButton,
)
export const ConnectedBuildingFavoriteButton = connect(
mapState,
mapDispatch,
)(BuildingFavoriteButton)
5 changes: 1 addition & 4 deletions source/views/building-hours/lib/chapel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
14 changes: 3 additions & 11 deletions source/views/building-hours/lib/get-schedule-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion source/views/building-hours/report/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}
Expand Down
2 changes: 1 addition & 1 deletion source/views/building-hours/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class BuildingRow extends React.Component<Props, State> {
status={status}
/>
</Detail>
))
))
: null}
</View>
</ListRow>
Expand Down
5 changes: 2 additions & 3 deletions source/views/building-hours/stateful-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,5 @@ function mapStateToProps(state: ReduxState): ReduxStateProps {
}
}

export const ConnectedBuildingHoursView = connect(mapStateToProps)(
BuildingHoursView,
)
export const ConnectedBuildingHoursView =
connect(mapStateToProps)(BuildingHoursView)
Loading

0 comments on commit 9cfb972

Please sign in to comment.