Skip to content

Commit

Permalink
Fix lint issues after prettification
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jun 26, 2019
1 parent 4944f47 commit e6ae898
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 44 deletions.
3 changes: 1 addition & 2 deletions lib/classes/Error.js
Expand Up @@ -85,8 +85,7 @@ module.exports.logError = e => {
process.exit(1);
}
// report error to sentry.
errorReporter.captureException(e, (sendErr, eventId) => {
// eslint-disable-line
errorReporter.captureException(e, () => {
// process.exit(1) for CI systems to correctly fail
process.exit(1);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Service.js
Expand Up @@ -174,7 +174,7 @@ class Service {
_.forEach(this.functions, (functionObj, functionName) => {
if (!_.isArray(functionObj.events)) {
throw new ServerlessError(
`Events for "${functionName}" must be an array,` + ` not an ${typeof functionObj.events}`
`Events for "${functionName}" must be an array, not an ${typeof functionObj.events}`
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Variables.js
Expand Up @@ -488,7 +488,7 @@ class Variables {
// A sentinel to rid rejected Promises, so any of resolved value can be used as fallback.
const FAIL_TOKEN = {};
const variableValues = variableStrings.map(variableString =>
this.getValueFromSource(variableString, propertyString).catch(unused => FAIL_TOKEN)
this.getValueFromSource(variableString, propertyString).catch(() => FAIL_TOKEN)
); // eslint-disable-line no-unused-vars

const validValue = value =>
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/package/compile/functions/index.js
Expand Up @@ -334,7 +334,6 @@ class AwsCompileFunctions {

let invalidEnvVar = null;
_.forEach(_.keys(newFunction.Properties.Environment.Variables), key => {
// eslint-disable-line consistent-return
// taken from the bash man pages
if (!key.match(/^[A-Za-z_][a-zA-Z0-9_]*$/)) {
invalidEnvVar = `Invalid characters in environment variable ${key}`;
Expand All @@ -349,6 +348,7 @@ class AwsCompileFunctions {
return false;
}
}
return true;
});

if (invalidEnvVar) {
Expand Down
73 changes: 35 additions & 38 deletions lib/plugins/aws/package/compile/functions/index.test.js
Expand Up @@ -1921,46 +1921,43 @@ describe('AwsCompileFunctions', () => {
});
});

it(
'should consider the providers runtime and memorySize ' + 'when creating a function resource',
() => {
const s3Folder = awsCompileFunctions.serverless.service.package.artifactDirectoryName;
const s3FileName = awsCompileFunctions.serverless.service.package.artifact
.split(path.sep)
.pop();
awsCompileFunctions.serverless.service.provider.runtime = 'python2.7';
awsCompileFunctions.serverless.service.provider.memorySize = 128;
awsCompileFunctions.serverless.service.functions = {
func: {
handler: 'func.function.handler',
name: 'new-service-dev-func',
},
};
const compiledFunction = {
Type: 'AWS::Lambda::Function',
DependsOn: ['FuncLogGroup', 'IamRoleLambdaExecution'],
Properties: {
Code: {
S3Key: `${s3Folder}/${s3FileName}`,
S3Bucket: { Ref: 'ServerlessDeploymentBucket' },
},
FunctionName: 'new-service-dev-func',
Handler: 'func.function.handler',
MemorySize: 128,
Role: { 'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn'] },
Runtime: 'python2.7',
Timeout: 6,
it('should consider the providers runtime and memorySize when creating a function resource', () => {
const s3Folder = awsCompileFunctions.serverless.service.package.artifactDirectoryName;
const s3FileName = awsCompileFunctions.serverless.service.package.artifact
.split(path.sep)
.pop();
awsCompileFunctions.serverless.service.provider.runtime = 'python2.7';
awsCompileFunctions.serverless.service.provider.memorySize = 128;
awsCompileFunctions.serverless.service.functions = {
func: {
handler: 'func.function.handler',
name: 'new-service-dev-func',
},
};
const compiledFunction = {
Type: 'AWS::Lambda::Function',
DependsOn: ['FuncLogGroup', 'IamRoleLambdaExecution'],
Properties: {
Code: {
S3Key: `${s3Folder}/${s3FileName}`,
S3Bucket: { Ref: 'ServerlessDeploymentBucket' },
},
};
FunctionName: 'new-service-dev-func',
Handler: 'func.function.handler',
MemorySize: 128,
Role: { 'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn'] },
Runtime: 'python2.7',
Timeout: 6,
},
};

return expect(awsCompileFunctions.compileFunctions()).to.be.fulfilled.then(() => {
expect(
awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources
.FuncLambdaFunction
).to.deep.equal(compiledFunction);
});
}
);
return expect(awsCompileFunctions.compileFunctions()).to.be.fulfilled.then(() => {
expect(
awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources
.FuncLambdaFunction
).to.deep.equal(compiledFunction);
});
});

it('should use a custom bucket if specified', () => {
const s3Folder = awsCompileFunctions.serverless.service.package.artifactDirectoryName;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/yamlAstParser.test.js
Expand Up @@ -309,7 +309,7 @@ describe('#yamlAstParser', () => {
});

it('should remove when with inline declaration of the array', () => {
const yamlContent = 'toplevel:\n' + ' second: ["foo2", "bar"]';
const yamlContent = 'toplevel:\n second: ["foo2", "bar"]';
const expectedResult = {
toplevel: {
second: ['foo2'],
Expand Down

0 comments on commit e6ae898

Please sign in to comment.