Skip to content

Commit

Permalink
style: Upgrade "prettier" to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jan 4, 2021
1 parent 14db2ec commit cf7b25e
Show file tree
Hide file tree
Showing 300 changed files with 1,395 additions and 1,612 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ In 2020, the Serverless Framework began introducing advanced functionality for s
| [![serverless framework fullstack application](https://s3.amazonaws.com/assets.github.serverless/components/ad-components-fullstack.png)](https://github.com/serverless-components/fullstack-app) | [![serverless framework express.js](https://s3.amazonaws.com/public.assets.serverless.com/images/ads/ad-components-express.png)](https://github.com/serverless-components/express) | [![serverless framework website](https://s3.amazonaws.com/public.assets.serverless.com/images/ads/ad-components-website.png)](https://github.com/serverless-components/website) | [![serverless framework dynamodb](https://s3.amazonaws.com/public.assets.serverless.com/images/ads/ad-components-dynamodb.png)](https://github.com/serverless-components/aws-dynamodb) |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |


## Contents

<img align="right" width="400" src="https://s3-us-west-2.amazonaws.com/assets.site.serverless.com/email/sls-getting-started.gif" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $ npm i --save express # 安装express
const express = require('express');
const app = express();

app.get('/', function(req, res) {
app.get('/', function (req, res) {
res.send('Hello Express');
});

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/sdk/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ And to import it instead, import with
```javascript
const { captureError } = require('./serverless_sdk');

module.exports.hello = async event => {
module.exports.hello = async (event) => {
try {
// do some real stuff but it throws an error, oh no!
throw new Error('aa');
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/aws/events/apigateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ functions:

'use strict';

module.exports.hello = function(event, context, callback) {
module.exports.hello = function (event, context, callback) {
console.log(event); // Contains incoming request data (e.g., query params, headers and more)

const response = {
Expand Down Expand Up @@ -351,7 +351,7 @@ If you want to use CORS with the lambda-proxy integration, remember to include t

'use strict';

module.exports.hello = function(event, context, callback) {
module.exports.hello = function (event, context, callback) {
const response = {
statusCode: 200,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/aws/examples/hello-world/node/handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// Your function handler
module.exports.helloWorldHandler = function(event, context, callback) {
module.exports.helloWorldHandler = function (event, context, callback) {
const message = {
message: 'Hello World',
event,
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/aws/guide/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The `handler` property points to the file and module containing the code you wan

```javascript
// handler.js
module.exports.functionOne = function(event, context, callback) {};
module.exports.functionOne = function (event, context, callback) {};
```

You can add as many functions as you want within this property.
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/aws/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports.saveUser = (event, context, callback) => {
created_at: Date.now(),
};

db.saveUser(user, function(err) {
db.saveUser(user, function (err) {
if (err) {
callback(err);
} else {
Expand Down Expand Up @@ -73,7 +73,7 @@ class Users {
created_at: Date.now(),
};

this.db.saveUser(user, function(err) {
this.db.saveUser(user, function (err) {
if (err) {
callback(err);
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/aws/guide/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ module.exports.rate = 'rate(10 minutes)';

```js
// config.js
module.exports = serverless => {
module.exports = (serverless) => {
serverless.cli.consoleLog('You can access Serverless config and methods as well!');

return {
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/events/blobstorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ functions:

'use strict';

module.exports.hello = function(context, item) {
module.exports.hello = function (context, item) {
context.log('Received item: ${item}');
context.done();
};
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/events/cosmosdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ functions:
'use strict';
const uuidv4 = require('uuid/v4');

module.exports.write = async function(context, req) {
module.exports.write = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');

const input = req.body;
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/events/eventhubs.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ functions:

'use strict';

module.exports.hello = function(context, item) {
module.exports.hello = function (context, item) {
context.log('Received item: ${item}');
context.done();
};
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/azure/events/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ URL paths for the serverless functions are prefixed with "api" by default, e.g.

'use strict';

module.exports.hello = function(context, req) {
module.exports.hello = function (context, req) {
context.res = {
body: 'Hello world!',
};
Expand All @@ -78,7 +78,7 @@ In Node.js, the request object looks like an express request object.

'use strict';

module.exports.hello = function(context, req) {
module.exports.hello = function (context, req) {
const query = req.query; // dictionary of query strings
const body = req.body; // Parsed body based on content-type
const method = req.method; // HTTP Method (GET, POST, PUT, etc.)
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/events/queuestorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ functions:

'use strict';

module.exports.hello = function(context, item) {
module.exports.hello = function (context, item) {
context.log('Received item: ${item}');
context.done();
};
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/azure/events/servicebus.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ functions:

'use strict';

module.exports.hello = function(context, item) {
module.exports.hello = function (context, item) {
context.log('Received item: ${item}');
context.done();
};
Expand Down Expand Up @@ -76,7 +76,7 @@ functions:

'use strict';

module.exports.hello = function(context, item) {
module.exports.hello = function (context, item) {
context.log('Received item: ${item}');
context.done();
};
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/events/timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ functions:

'use strict';

module.exports.hello = function(context, timerObj) {
module.exports.hello = function (context, timerObj) {
context.log('Timer ran');
context.done();
};
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/azure/guide/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module containing the code you want to run in your function.

```javascript
// handler.js
exports.handler = function(params) {};
exports.handler = function (params) {};
```

You can add as many functions as you want within this property.
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/azure/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports.saveUser = (context, req) => {
created_at: Date.now(),
};

db.saveUser(user, function(err) {
db.saveUser(user, function (err) {
if (err) {
reject(err);
} else {
Expand Down Expand Up @@ -77,7 +77,7 @@ class Users {
created_at: Date.now(),
};

this.db.saveUser(user, function(err) {
this.db.saveUser(user, function (err) {
if (err) {
reject(err);
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/cloudflare/guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ How can we debug errors in our Cloudflare Workers functions?
Let's imagine that we have deployed the following code as a Cloudflare Worker function using Serverless:

```javascript
addEventListener('fetch', event => {
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
Expand Down
2 changes: 1 addition & 1 deletion docs/providers/cloudflare/guide/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The `script` property points to the file containing your Cloudflare Worker.
```javascript
// helloWorld.js

addEventListener('fetch', event => {
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});

Expand Down
2 changes: 1 addition & 1 deletion docs/providers/fn/guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Let's imagine that we have deployed the following Nodejs code as a Fn function u
```javascript
const fdk = require('@fnproject/fdk');

fdk.handle(input => {
fdk.handle((input) => {
input = JSON.parse(input);
let name = 'World';
if (input.name) {
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/openwhisk/events/apigateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ URL paths for the serverless functions are prefixed with the function name, e.g.

'use strict';

module.exports.hello = function(params) {
module.exports.hello = function (params) {
// Your function handler
return { payload: 'Hello world!' };
};
Expand Down Expand Up @@ -86,7 +86,7 @@ functions:

'use strict';

module.exports.handler = function(params) {
module.exports.handler = function (params) {
const name = params.name || 'stranger';
// Your function handler
return { payload: `Hello ${name}!` };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// Your function handler
module.exports.helloWorldHandler = function(params) {
module.exports.helloWorldHandler = function (params) {
const name = params.name || 'World';
return { payload: `Hello, ${name}!` };
};
2 changes: 1 addition & 1 deletion docs/providers/openwhisk/guide/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The `handler` property points to the file and module containing the code you wan

```javascript
// handler.js
exports.handler = function(params) {};
exports.handler = function (params) {};
```

You can add as many functions as you want within this property.
Expand Down
8 changes: 4 additions & 4 deletions docs/providers/openwhisk/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ Here is an example in Node.js of how to follow the practices above. The job this
const db = require('db').connect();
const mailer = require('mailer');

module.exports.saveUser = params => {
module.exports.saveUser = (params) => {
return Promise((resolve, reject) => {
const user = {
email: params.email,
created_at: Date.now(),
};

db.saveUser(user, function(err) {
db.saveUser(user, function (err) {
if (err) {
reject(err);
} else {
Expand Down Expand Up @@ -76,7 +76,7 @@ class Users {
created_at: Date.now(),
};

this.db.saveUser(user, function(err) {
this.db.saveUser(user, function (err) {
if (err) {
reject(err);
} else {
Expand All @@ -98,7 +98,7 @@ const Users = require('users');

let users = new Users(db, mailer);

module.exports.saveUser = params => {
module.exports.saveUser = (params) => {
return users.save(params.email);
};
```
Expand Down
28 changes: 13 additions & 15 deletions lib/classes/CLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CLI {

// Make "log" no-op to suppress warnings.
// But preserve "consoleLog" which "print" command use to print config.
this.log = function() {};
this.log = function () {};
}

isHelpRequest(processedInput) {
Expand Down Expand Up @@ -233,31 +233,31 @@ class CLI {
this.consoleLog('');

const internalCommands = Object.values(this.loadedCommands).filter(
command => command && !command.isExternal
(command) => command && !command.isExternal
);
const sortedInternalCommands = internalCommands.sort((command1, command2) =>
command1.key.localeCompare(command2.key)
);
sortedInternalCommands.forEach(command => {
sortedInternalCommands.forEach((command) => {
this.displayCommandUsage(command, command.key);
});

this.consoleLog('');

const externalPlugins = this.loadedPlugins
.filter(plugin => this.serverless.pluginManager.externalPlugins.has(plugin))
.filter((plugin) => this.serverless.pluginManager.externalPlugins.has(plugin))
.sort((plugin1, plugin2) => plugin1.constructor.name.localeCompare(plugin2.constructor.name));

if (externalPlugins.length) {
// print all the installed plugins
this.consoleLog(chalk.yellow.underline('Plugins'));

this.consoleLog(externalPlugins.map(plugin => plugin.constructor.name).join(', '));
this.consoleLog(externalPlugins.map((plugin) => plugin.constructor.name).join(', '));

let pluginCommands = {};

// add commands to pluginCommands based on command's plugin
const addToPluginCommands = cmd => {
const addToPluginCommands = (cmd) => {
const pcmd = _.clone(cmd);

// remove subcommand from clone
Expand All @@ -273,24 +273,21 @@ class CLI {

// check for subcommands
if ('commands' in cmd) {
Object.values(cmd.commands).forEach(d => {
Object.values(cmd.commands).forEach((d) => {
addToPluginCommands(d);
});
}
};

// fill up pluginCommands with commands in loadedCommands
Object.values(this.loadedCommands).forEach(details => {
Object.values(this.loadedCommands).forEach((details) => {
if (details.isExternal) {
addToPluginCommands(details);
}
});

// sort plugins alphabetically
pluginCommands = _(Object.entries(pluginCommands))
.sortBy(0)
.fromPairs()
.value();
pluginCommands = _(Object.entries(pluginCommands)).sortBy(0).fromPairs().value();

if (!_.isEmpty(pluginCommands)) {
this.consoleLog('');
Expand All @@ -299,7 +296,7 @@ class CLI {

Object.entries(pluginCommands).forEach(([plugin, details]) => {
this.consoleLog(plugin);
details.forEach(cmd => {
details.forEach((cmd) => {
// display command usage with single(1) indent
this.displayCommandUsage(cmd, cmd.key.split(':').join(' '), 1);
});
Expand All @@ -317,8 +314,9 @@ class CLI {
functionalities related to given service or current environment.`
)
);
const command = this.loadedPlugins.find(plugin => plugin.constructor.name === 'InteractiveCli')
.commands.interactiveCli;
const command = this.loadedPlugins.find(
(plugin) => plugin.constructor.name === 'InteractiveCli'
).commands.interactiveCli;

this.displayCommandOptions(command);
}
Expand Down

0 comments on commit cf7b25e

Please sign in to comment.