Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit e499d2e

Browse files
authored
Merge pull request #13 from netlify/prettier
Set up and run prettier
2 parents 977f977 + 4416a12 commit e499d2e

File tree

8 files changed

+75
-17
lines changed

8 files changed

+75
-17
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "oclif"
2+
"extends": ["oclif", "plugin:prettier/recommended"],
3+
"rules": {
4+
"prettier/prettier": "error"
5+
}
36
}

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"printWidth": 120
5+
}

package-lock.json

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

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
"chai": "^4",
2525
"eslint": "^5.5",
2626
"eslint-config-oclif": "^3.1",
27+
"eslint-config-prettier": "^4.1.0",
28+
"eslint-plugin-prettier": "^3.0.1",
2729
"globby": "^8",
2830
"mocha": "^5",
29-
"nyc": "^13"
31+
"nyc": "^13",
32+
"prettier": "^1.16.4"
3033
},
3134
"engines": {
3235
"node": ">=8.0.0"
@@ -55,6 +58,8 @@
5558
"posttest": "eslint .",
5659
"prepack": "oclif-dev manifest && oclif-dev readme",
5760
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
61+
"format": "npm run format:prettier -- --write",
62+
"format:prettier": "prettier \"{{src,test}/**/,}*.js\"",
5863
"version": "oclif-dev readme && git add README.md"
5964
}
6065
}

src/commands/functions/build.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const fs = require('fs')
2-
const {flags} = require('@oclif/command')
2+
const { flags } = require('@oclif/command')
33
const Command = require('@netlify/cli-utils')
4-
const {zipFunctions} = require('@netlify/zip-it-and-ship-it')
4+
const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
55

66
class FunctionsBuildCommand extends Command {
77
async run() {
8-
const {flags, args} = this.parse(FunctionsBuildCommand)
9-
const {config} = this.netlify
8+
const { flags, args } = this.parse(FunctionsBuildCommand)
9+
const { config } = this.netlify
1010

1111
const src = flags.src || config.build.functionsSource
1212
const dst = flags.functions || config.build.functions
@@ -26,10 +26,10 @@ class FunctionsBuildCommand extends Command {
2626
process.exit(1)
2727
}
2828

29-
fs.mkdirSync(dst, {recursive: true})
29+
fs.mkdirSync(dst, { recursive: true })
3030

3131
this.log('Building functions')
32-
zipFunctions(src, dst, {skipGo: true})
32+
zipFunctions(src, dst, { skipGo: true })
3333
this.log('Functions buildt to ', dst)
3434
}
3535
}
@@ -40,12 +40,12 @@ FunctionsBuildCommand.description = `build functions locally
4040
FunctionsBuildCommand.flags = {
4141
functions: flags.string({
4242
char: 'f',
43-
description: 'Specify a functions folder to build to',
43+
description: 'Specify a functions folder to build to'
4444
}),
4545
src: flags.string({
4646
char: 's',
47-
description: 'Specify the source folder for the functions',
48-
}),
47+
description: 'Specify the source folder for the functions'
48+
})
4949
}
5050

5151
module.exports = FunctionsBuildCommand

src/commands/functions/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const chalk = require('chalk')
2-
const {Command} = require('@oclif/command')
2+
const { Command } = require('@oclif/command')
33

44
function showHelp(command) {
5-
execSync(`netlify ${command} --help`, {stdio: [0, 1, 2]})
5+
execSync(`netlify ${command} --help`, { stdio: [0, 1, 2] })
66
}
77

88
function isEmptyCommand(flags, args) {
@@ -22,7 +22,7 @@ function hasArgs(args) {
2222

2323
class FunctionsCommand extends Command {
2424
async run() {
25-
const {flags, args} = this.parse(FunctionsCommand)
25+
const { flags, args } = this.parse(FunctionsCommand)
2626
// run help command if no args passed
2727
if (isEmptyCommand(flags, args)) {
2828
showHelp(this.id)
@@ -38,7 +38,7 @@ The ${name} command will help you manage the functions in this site
3838
`
3939
FunctionsCommand.examples = [
4040
'netlify functions:create --name function-xyz --runtime nodejs',
41-
'netlify functions:update --name function-abc --timeout 30s',
41+
'netlify functions:update --name function-abc --timeout 30s'
4242
]
4343

4444
// TODO make visible once implementation complete

src/commands/functions/serve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Extra documentation goes here
1212
`
1313

1414
FunctionsServeCommand.flags = {
15-
name: flags.string({char: 'n', description: 'name to print'}),
15+
name: flags.string({ char: 'n', description: 'name to print' })
1616
}
1717

1818
// TODO make visible once implementation complete

src/commands/functions/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Extra documentation goes here
1212
`
1313

1414
FunctionsUpdateCommand.flags = {
15-
name: flags.string({char: 'n', description: 'name to print'}),
15+
name: flags.string({ char: 'n', description: 'name to print' })
1616
}
1717

1818
// TODO make visible once implementation complete

0 commit comments

Comments
 (0)