Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions aws-node-recursive-function/handler.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* eslint-disable */
/* aws-sdk automatically included in lambda context */
const aws = require('aws-sdk');
const aws = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies

// eslint-disable-next-line no-unused-vars
module.exports.recursiveLambda = (event, context, callback) => {
const lambda = new aws.Lambda();
console.log('received', event);
/* if numberOfCalls still has value, continue recursive operation */
if (event.numberOfCalls > 0) {
console.log('recursive call');
/* decrement numberOfCalls so we don't infinitely loop */
event.numberOfCalls = event.numberOfCalls - 1;
event.numberOfCalls -= 1; // eslint-disable-line no-param-reassign
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to read for me =)

Can we keep the original?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serverless/examples/aws-node-recursive-function/handler.js
 11:5  error  Assignment can be replaced with operator assignment  operator-assignment

This is coming from the airbnb coding style rules:
https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js#L313-L315

I like the shorthand version better, but this is just personal preference.

If you prefer the long version, let's change the config to prevent this:

'operator-assignment': ['never']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried, and it seems that generate-readme.js is making use of the shorthand version in a couple of places, using md += '...' to concatenate strings.

We could of course also turn the rule off entirely.

const params = {
FunctionName: context.functionName,
InvocationType: 'Event',
Payload: JSON.stringify(event),
Qualifier: context.functionVersion
Qualifier: context.functionVersion,
};
lambda.invoke(params, context.done);
} else {
Expand Down