Skip to content

Commit

Permalink
refactor (all): use trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 22, 2019
1 parent e3619dc commit aba3a1d
Show file tree
Hide file tree
Showing 72 changed files with 231 additions and 229 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
],
"import/order": [2, { "newlines-between": "always" }],
"no-process-exit": 0,
"require-atomic-updates": 0
"require-atomic-updates": 0,
"comma-dangle": [2, "always-multiline"]
},
"overrides": [
{
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"singleQuote": true,
"printWidth": 120,
"endOfLine": "lf",
"proseWrap": "always"
"proseWrap": "always",
"trailingComma": "all"
}
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
init: () => {
console.log('Do thing on init step')
}
},
}
}
```
Expand Down Expand Up @@ -224,7 +224,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
getCache: () => {
console.log('Do thing on getCache step')
}
},
}
}
```
Expand Down Expand Up @@ -268,7 +268,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
install: () => {
console.log('Do thing on install step')
}
},
}
}
```
Expand Down Expand Up @@ -312,7 +312,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
preBuild: () => {
console.log('Do thing on preBuild step')
}
},
}
}
```
Expand Down Expand Up @@ -356,7 +356,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
functionsBuild: () => {
console.log('Do thing on functionsBuild step')
}
},
}
}
```
Expand Down Expand Up @@ -400,7 +400,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
build: () => {
console.log('Do thing on build step')
}
},
}
}
```
Expand Down Expand Up @@ -444,7 +444,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
postBuild: () => {
console.log('Do thing on postBuild step')
}
},
}
}
```
Expand Down Expand Up @@ -488,7 +488,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
package: () => {
console.log('Do thing on package step')
}
},
}
}
```
Expand Down Expand Up @@ -532,7 +532,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
preDeploy: () => {
console.log('Do thing on preDeploy step')
}
},
}
}
```
Expand Down Expand Up @@ -576,7 +576,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
saveCache: () => {
console.log('Do thing on saveCache step')
}
},
}
}
```
Expand Down Expand Up @@ -620,7 +620,7 @@ module.exports = function myPlugin(pluginConfig) {
return {
finally: () => {
console.log('Do thing on finally step')
}
},
}
}
```
Expand Down Expand Up @@ -730,7 +730,7 @@ module.exports = function exampleOne(config) {
},
finally: () => {
console.log('Run custom logic at the end of the build')
}
},
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions examples/backwards-compat/functions/one.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exports.handler = (event, context, callback) => {
return callback(null, {
statusCode: 200,
body: JSON.stringify({
hello: 'from function one'
})
hello: 'from function one',
}),
})
}
4 changes: 2 additions & 2 deletions examples/example-one/functions/one.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exports.handler = (event, context, callback) => {
return callback(null, {
statusCode: 200,
body: JSON.stringify({
hello: 'from function one'
})
hello: 'from function one',
}),
})
}
2 changes: 1 addition & 1 deletion examples/example-one/plugins/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ module.exports = function netlifyPlugin(config) {
},
finally: () => {
console.log('Hi from finally')
}
},
}
}
2 changes: 1 addition & 1 deletion examples/example-two/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function exampleNetlifyPlugin(config) {
// Hook into `postBuild` lifecycle
postBuild: () => {
console.log('Build finished. Do custom thing')
}
},
// ... etc
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/example-two/functions/myFuncName.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.handler = (event, context, callback) => {
return callback(null, {
statusCode: 200,
body: JSON.stringify({
hello: 'there'
})
hello: 'there',
}),
})
}
4 changes: 2 additions & 2 deletions examples/example-two/functions/whatever.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exports.handler = (event, context, callback) => {
return callback(null, {
statusCode: 200,
body: JSON.stringify({
hello: 'hi'
})
hello: 'hi',
}),
})
}
2 changes: 1 addition & 1 deletion examples/example-two/plugins/dynamic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = function dynamicPlugin(conf) {
return {
[`${hook}`]: () => {
console.log('do the stuff')
}
},
}
}
2 changes: 1 addition & 1 deletion examples/example-two/plugins/plugin-one/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = function exampleOne(conf) {
return {
[`${hook}`]: () => {
console.log('do the stuff')
}
},
}
}
2 changes: 1 addition & 1 deletion examples/example-two/plugins/plugin-two/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = function pluginTwo() {
},
postBuild: () => {
console.log('this is run after site build')
}
},
}
}
10 changes: 5 additions & 5 deletions packages/build/src/cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ async function cacheArtifacts(cwd, cacheDir) {
bower_components: 'bower components',
node_modules: 'node modules',
'.venv': 'python virtualenv',
wapm_packages: 'wapm packages'
wapm_packages: 'wapm packages',
},
cwd,
cacheDir
cacheDir,
)

const cacheHomeDir = cacheDeps(
Expand All @@ -35,10 +35,10 @@ async function cacheArtifacts(cwd, cacheDir) {
'.m2': 'maven dependencies',
'.boot': 'boot dependencies',
'.composer': 'composer dependencies',
'.wasmer/cache': 'wasmer cache'
'.wasmer/cache': 'wasmer cache',
},
HOME,
cacheDir
cacheDir,
)

await Promise.all(cacheCwd.concat(cacheHomeDir))
Expand Down Expand Up @@ -80,7 +80,7 @@ async function cacheArtifacts(cwd, cacheDir) {
await moveCache(
path.join(RVM_DIR, 'rubies', `ruby-${RUBY_VERSION}`),
path.join(cacheDir, 'ruby_version'),
'ruby deps'
'ruby deps',
)
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions packages/build/src/core/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ const OPTIONS = {
string: true,
describe: `Path to the configuration file.
Defaults to any netlify.yml, netlify.toml, netlify.json or netlify.js file in
the current directory or any parent directory`
the current directory or any parent directory`,
},
token: {
string: true,
describe: `Netlify API token for authentication.
The NETLIFY_TOKEN environment variable can be used as well.`
The NETLIFY_TOKEN environment variable can be used as well.`,
},
context: {
string: true,
describe: `Build context.
Default: 'production'`
Default: 'production'`,
},
dry: {
boolean: true,
describe: `Run in dry mode, i.e. printing commands without
executing them.
Default: false`
Default: false`,
},
verbose: {
boolean: true,
describe: `Print messages and errors verbosely.
Default: false`
}
Default: false`,
},
}

const USAGE = `$0 [OPTIONS...]
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/core/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { dirname } = require('path')
const {
env: { NETLIFY_TOKEN }
env: { NETLIFY_TOKEN },
} = require('process')

const resolveConfig = require('@netlify/config')
Expand Down
12 changes: 6 additions & 6 deletions packages/build/src/core/instructions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const getHookInstructions = function({
pluginsHooks: { [hook]: pluginHooks = [] },
config: {
build: {
lifecycle: { [hook]: commands }
}
}
lifecycle: { [hook]: commands },
},
},
}) {
if (commands === undefined) {
return pluginHooks
Expand All @@ -48,10 +48,10 @@ const runInstructions = async function(instructions, { config, configPath, token
configPath,
token,
baseDir,
error
error,
})
},
{}
{},
)
return manifest
}
Expand Down Expand Up @@ -107,7 +107,7 @@ const execCommand = async function({ hook, command, baseDir }) {
// Fire a plugin hook method
const firePluginHook = async function(
{ type, hook, pluginPath, pluginConfig, hookName, constants },
{ config, token, baseDir, error }
{ config, token, baseDir, error },
) {
try {
await executePlugin('run', { pluginPath, pluginConfig, hookName, config, token, error, constants }, { baseDir })
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/core/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const LIFECYCLE = [
*/
'finally',
// Todo onError is not part of lifecycle. Its a special handler
'onError'
'onError',
]

module.exports = { LIFECYCLE }
2 changes: 1 addition & 1 deletion packages/build/src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {
logManifest,
logBuildError,
logBuildSuccess,
logBuildEnd
logBuildEnd,
} = require('../log/main')
const { startTimer, endTimer } = require('../log/timer')
const isNetlifyCI = require('../utils/is-netlify-ci')
Expand Down
8 changes: 4 additions & 4 deletions packages/build/src/heuristics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = async function getHeuristics({ pkgPath, configPath }) {
acc['steps'] = acc['steps'].concat({
name: null,
raw: c,
parsed: c
parsed: c,
})
acc['raw'] = acc['raw'].concat(c)
acc['combined'] = acc['raw'].join(' && ')
Expand All @@ -72,8 +72,8 @@ module.exports = async function getHeuristics({ pkgPath, configPath }) {
command: '',
steps: [],
raw: [],
combined: ''
}
combined: '',
},
)
// console.log('vals', vals)
// console.log('combined', buildInfo)
Expand All @@ -96,7 +96,7 @@ module.exports = async function getHeuristics({ pkgPath, configPath }) {
// Resolved buildcommand info
build: buildInfo,
// Best guess of project type
projectType: typeofBuild
projectType: typeofBuild,
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/build/src/heuristics/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const getHeuristics = require('../index')

getHeuristics({
pkgPath: path.join(__dirname, 'package.json'),
configPath: path.join(__dirname, 'netlify.toml')
configPath: path.join(__dirname, 'netlify.toml'),
}).then(info => {
console.log(
util.inspect(info, {
showHidden: false,
depth: null,
colors: true
})
colors: true,
}),
)
})
Loading

0 comments on commit aba3a1d

Please sign in to comment.