Skip to content

Commit bdb9330

Browse files
authored
Merge pull request #1719 from StoDevX/prettier-1.7
Update Prettier to v1.7
2 parents 07277e3 + 0b95b0e commit bdb9330

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+814
-722
lines changed

data/news-styles.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ body {
55
padding: 1em;
66
word-wrap: break-word;
77
}
8-
div, figure {
8+
div,
9+
figure {
910
width: auto !important;
1011
}
1112
img {

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"name": "all-about-olaf",
33
"version": "2.4.0-beta.16",
44
"private": true,
5-
"config": {
6-
"prettier_args": "--single-quote --trailing-comma all --no-bracket-spacing --no-semi"
7-
},
85
"scripts": {
96
"android": "react-native run-android",
107
"android:release": "react-native run-android --variant=release",
@@ -20,9 +17,9 @@
2017
"ios:release": "react-native run-ios --configuration Release",
2118
"ios-simulator": "xcrun instruments -s devices | peco --select-1 --query 'Simulator iPhone' --on-cancel error | sed 's~.*\\[\\(.*\\)\\].*~\\1~' | xargs open -n -a Simulator --args -CurrentDeviceUDID",
2219
"lint": "eslint --cache source/ *.js",
23-
"prettier": "prettier --write $npm_package_config_prettier_args 'source/**/*.js' 'data/**/*.css' '*.js'",
24-
"prettier:changed": "FILES=$(git status -u --porcelain | cut -c4- | grep '\\.js$'); prettier --write $npm_package_config_prettier_args $FILES",
25-
"prettier:since-master": "FILES=$(git diff --name-only master | grep '\\.js$'); prettier --write $npm_package_config_prettier_args $FILES",
20+
"prettier": "prettier --write '{source,scripts}/**/*.js' 'data/**/*.css' '*.js'",
21+
"prettier:changed": "FILES=$(git status -u --porcelain | cut -c4- | grep '\\.js$'); prettier --write $FILES",
22+
"prettier:since-master": "FILES=$(git diff --name-only master | grep '\\.js$'); prettier --write $FILES",
2623
"start": "react-native start",
2724
"test": "jest",
2825
"validate-data": "node scripts/validate-data.js"
@@ -45,6 +42,12 @@
4542
],
4643
"preset": "react-native"
4744
},
45+
"prettier": {
46+
"singleQuote": true,
47+
"trailingComma": "all",
48+
"bracketSpacing": false,
49+
"semi": false
50+
},
4851
"dependencies": {
4952
"buffer": "5.0.7",
5053
"bugsnag-react-native": "2.3.2",
@@ -114,7 +117,7 @@
114117
"marked": "0.3.6",
115118
"minimist": "1.2.0",
116119
"pify": "3.0.0",
117-
"prettier": "1.4.4",
120+
"prettier": "1.7.2",
118121
"react-native-view-shot": "1.12.0",
119122
"react-test-renderer": "16.0.0-alpha.12",
120123
"string-natural-compare": "2.0.2"

scripts/bundle-data-dir.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ if (process.mainModule === module) {
2121
// exported module
2222
module.exports = bundleDataDir
2323
function bundleDataDir({fromDir, toFile}) {
24-
const files = fs.readdirSync(fromDir).filter(junk.not).map(f => path.join(fromDir, f))
24+
const files = fs
25+
.readdirSync(fromDir)
26+
.filter(junk.not)
27+
.map(f => path.join(fromDir, f))
2528
if (!files.length) {
2629
return
2730
}
@@ -37,6 +40,7 @@ function bundleDataDir({fromDir, toFile}) {
3740
const dated = {data: loaded}
3841
const output = JSON.stringify(dated, null, 2) + '\n'
3942

40-
const outStream = toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
43+
const outStream =
44+
toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
4145
outStream.write(output)
4246
}

scripts/bundle-data.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ const convertDataFile = require('./convert-data-file')
88

99
const isDir = pth => fs.statSync(pth).isDirectory()
1010
const isFile = pth => fs.statSync(pth).isFile()
11-
const readDir = pth => fs.readdirSync(pth).filter(junk.not).filter(entry => !entry.startsWith('_'))
12-
const findDirsIn = pth => readDir(pth).filter(entry => isDir(path.join(pth, entry)))
13-
const findFilesIn = pth => readDir(pth).filter(entry => isFile(path.join(pth, entry)))
11+
12+
const readDir = pth =>
13+
fs
14+
.readdirSync(pth)
15+
.filter(junk.not)
16+
.filter(entry => !entry.startsWith('_'))
17+
18+
const findDirsIn = pth =>
19+
readDir(pth).filter(entry => isDir(path.join(pth, entry)))
20+
21+
const findFilesIn = pth =>
22+
readDir(pth).filter(entry => isFile(path.join(pth, entry)))
1423

1524
const args = process.argv.slice(2)
1625
const fromDir = args[0]

scripts/convert-data-file.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (process.mainModule === module) {
1919

2020
// exported module
2121
module.exports = convertDataFile
22-
function convertDataFile({fromFile, toFile, toFileType="json"}) {
22+
function convertDataFile({fromFile, toFile, toFileType = 'json'}) {
2323
const contents = fs.readFileSync(fromFile, 'utf-8')
2424
let output = contents
2525

@@ -32,7 +32,7 @@ function convertDataFile({fromFile, toFile, toFileType="json"}) {
3232
output = processYaml(contents)
3333
break
3434
case 'css':
35-
if (toFileType === "css") {
35+
if (toFileType === 'css') {
3636
output = contents
3737
} else {
3838
output = processCSS(contents)
@@ -46,9 +46,8 @@ function convertDataFile({fromFile, toFile, toFileType="json"}) {
4646

4747
output = output + '\n'
4848

49-
const outStream = toFile === '-'
50-
? process.stdout
51-
: fs.createWriteStream(toFile)
49+
const outStream =
50+
toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
5251
outStream.write(output)
5352
}
5453

scripts/make-icons.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ const spawn = (cmd, ...args) => {
66
childSpawn(cmd, args)
77
}
88

9-
const resize = (img, width, toFile) => spawn('convert', img, '-resize', `${width}x${width}`, toFile)
9+
const resize = (img, width, toFile) =>
10+
spawn('convert', img, '-resize', `${width}x${width}`, toFile)
1011

1112
// iOS app icons
1213
const iosSizes = [[29, 1], [29, 2], [29, 3], [40, 2], [40, 3], [60, 2], [60, 3]]
1314
for (const [width, density] of iosSizes) {
14-
resize(source, width * density, `icons/ios/AppIcon.appiconset/Icon-${width}@${density}x.png`)
15+
resize(
16+
source,
17+
width * density,
18+
`icons/ios/AppIcon.appiconset/Icon-${width}@${density}x.png`,
19+
)
1520
}
1621

1722
// iTunes icons

scripts/validate-data.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ const SCHEMA_BASE = path.join(__dirname, '..', 'data', '_schemas')
1111
const DATA_BASE = path.join(__dirname, '..', 'data')
1212

1313
const isDir = pth => tryBoolean(() => fs.statSync(pth).isDirectory())
14-
const readYaml = pth => JSON.parse(JSON.stringify(yaml.safeLoad(fs.readFileSync(pth, 'utf-8'), {filename: pth})))
15-
const readDir = pth => fs.readdirSync(pth).filter(junk.not).filter(entry => !entry.startsWith('_'))
14+
const readYaml = pth =>
15+
JSON.parse(
16+
JSON.stringify(
17+
yaml.safeLoad(fs.readFileSync(pth, 'utf-8'), {filename: pth}),
18+
),
19+
)
20+
21+
const readDir = pth =>
22+
fs
23+
.readdirSync(pth)
24+
.filter(junk.not)
25+
.filter(entry => !entry.startsWith('_'))
1626

1727
/// MARK: program
1828

@@ -78,20 +88,26 @@ function parseArgs(argv) {
7888
console.error()
7989
console.error('Arguments:')
8090
console.error(' <blank>: validates all schemas and data')
81-
console.error(' [schema-name]+: validates the schema and data for the given schema')
91+
console.error(
92+
' [schema-name]+: validates the schema and data for the given schema',
93+
)
8294
console.error()
8395
console.error('Options:')
8496
console.error(' --no-bail: continue past the first error')
8597
console.error(' -d, --data: use this as the data file (requires --schema)')
8698
console.error(' -s, --schema: use this as the schema (requires --data)')
8799
console.error()
88-
console.error(`By default, the program looks for schema files in ${SCHEMA_BASE}`)
100+
console.error(
101+
`By default, the program looks for schema files in ${SCHEMA_BASE}`,
102+
)
89103
process.exit(1)
90104
}
91105

92106
if ((args.data && !args.schema) || (args.schema && !args.data)) {
93107
console.error('Usage: node validate-compiled-data.js [options] [args]')
94-
console.error('If either --data or --schema are provided, both are required')
108+
console.error(
109+
'If either --data or --schema are provided, both are required',
110+
)
95111
process.exit(1)
96112
}
97113

@@ -145,7 +161,9 @@ function formatError(err, data) {
145161
const dataPath = err.dataPath.replace(/^\./, '')
146162
switch (err.keyword) {
147163
case 'enum': {
148-
contents = `Given value "${get(data, dataPath)}" ${err.message} [${err.params.allowedValues.join(', ')}]`
164+
const value = get(data, dataPath)
165+
const allowed = err.params.allowedValues.join(', ')
166+
contents = `Given value "${value}" ${err.message} [${allowed}]`
149167
break
150168
}
151169
case 'type': {
@@ -156,8 +174,5 @@ function formatError(err, data) {
156174
return JSON.stringify(err, null, 2)
157175
}
158176
}
159-
return [
160-
`Error at ${err.dataPath}:`,
161-
contents,
162-
].join('\n')
177+
return [`Error at ${err.dataPath}:`, contents].join('\n')
163178
}

source/analytics.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import {stringifyFilters} from './views/components/filter'
77

88
import {getAnalyticsOptOut} from './lib/storage'
99

10-
const trackerId = process.env.NODE_ENV === 'development'
11-
? 'UA-90234209-1'
12-
: 'UA-90234209-2'
10+
const trackerId =
11+
process.env.NODE_ENV === 'development' ? 'UA-90234209-1' : 'UA-90234209-2'
1312
export const tracker = new GoogleAnalyticsTracker(trackerId)
1413

1514
function disableIfOptedOut() {

source/lib/courses/parse-courses.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ function parseDeptNum(deptNumString: string): Error | string {
8080
return new Error(`Problem parsing ${deptNumString}: no matches found`)
8181
}
8282

83-
let department = matches[1].indexOf('/') !== -1
84-
? [matches[2], matches[3]]
85-
: [matches[1]]
83+
let department =
84+
matches[1].indexOf('/') !== -1 ? [matches[2], matches[3]] : [matches[1]]
8685
department = department.join('/')
8786

8887
let number = parseInt(matches[4], 10)

0 commit comments

Comments
 (0)