Skip to content

Commit 9924bc1

Browse files
authored
Merge pull request #130 from ysugimoto/eslint
ESLint integration
2 parents 9108a1a + 07db0a1 commit 9924bc1

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
parser: babel-eslint
2+
13
env:
24
amd: true
35
es6: true
@@ -38,7 +40,7 @@ rules:
3840
# Best Practices
3941
accessor-pairs: 2
4042
block-scoped-var: 0
41-
complexity: [2, 6]
43+
complexity: 2
4244
consistent-return: 0
4345
curly: 0
4446
default-case: 0
@@ -51,7 +53,6 @@ rules:
5153
no-case-declarations: 2
5254
no-div-regex: 2
5355
no-else-return: 0
54-
no-empty-label: 2
5556
no-empty-pattern: 2
5657
no-eq-null: 2
5758
no-eval: 2

.jshintrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/ImageResizer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImageResizer {
3131
return new Promise((resolve, reject) => {
3232
console.log("Resizing to: " + (this.options.directory || "in-place"));
3333

34-
var img = gm(image.data).geometry(this.options.size.toString());
34+
let img = gm(image.data).geometry(this.options.size.toString());
3535
if ( "orientation" in this.options ) {
3636
img = img.autoOrient();
3737
}
@@ -42,7 +42,7 @@ class ImageResizer {
4242
img = img.background(this.options.background).flatten();
4343
}
4444
if ( "crop" in this.options ) {
45-
var cropArgs = this.options.crop.match(cropSpec);
45+
const cropArgs = this.options.crop.match(cropSpec);
4646
const cropWidth = cropArgs[1];
4747
const cropHeight = cropArgs[2];
4848
const cropX = cropArgs[3];

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"test": "nyc ava",
2020
"test-config": "./bin/configtest",
2121
"test-lambda": "claudia test-lambda --profile $npm_package_config_profile --event $npm_config_event_file",
22+
"pretest": "npm run lint",
23+
"lint": "eslint .",
2224
"destroy": "AWS_PROFILE=$npm_package_config_profile claudia destroy --profile $npm_package_config_profile"
2325
},
2426
"keywords": [
@@ -53,9 +55,11 @@
5355
"devDependencies": {
5456
"ava": "^0.18.2",
5557
"aws-sdk-mock": "^1.6.1",
58+
"babel-eslint": "^7.2.1",
5659
"bind-all": "^1.0.0",
5760
"claudia": "^2.9.0",
5861
"coveralls": "^2.12.0",
62+
"eslint": "^3.18.0",
5963
"nyc": "^10.1.2",
6064
"pify": "^2.3.0",
6165
"sinon": "^1.17.7"

test/s3-file-system.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,21 @@ test.before(async t => {
1616
AWS.mock( "S3", "getObject", (params, callback) => {
1717
switch ( params.Key ) {
1818
case "processed.jpg":
19-
callback( null, { Metadata: { "img-processed": "true" }, CacheControl: "cache-control" } );
20-
break;
19+
return callback( null, { Metadata: { "img-processed": "true" }, CacheControl: "cache-control" } );
2120
case "empty-file.jpg":
22-
callback( null, { ContentLength: 0, Metadata: {}, CacheControl: "cache-control" } );
23-
break;
21+
return callback( null, { ContentLength: 0, Metadata: {}, CacheControl: "cache-control" } );
2422
case "network-error.jpg":
25-
callback( "Simulated network error" );
26-
break;
23+
return callback( "Simulated network error" );
2724
default:
28-
callback( null, { Body: fixture, Metadata: {}, CacheControl: "cache-control" } );
25+
return callback( null, { Body: fixture, Metadata: {}, CacheControl: "cache-control" } );
2926
}
3027
});
3128
AWS.mock( "S3", "putObject", (params, callback) => {
3229
switch ( params.Key ) {
3330
case "network-error.jpg":
34-
callback( "Simulated network error" );
35-
break;
31+
return callback( "Simulated network error" );
3632
default:
37-
callback( null );
33+
return callback( null );
3834
}
3935
});
4036

@@ -85,7 +81,7 @@ test("Push valid ImageData object to S3", async t => {
8581

8682
const response = await fileSystem.putObject(image);
8783
t.is(response, "S3 putObject success")
88-
})
84+
});
8985

9086
test("Fail on network error while pushing ImageData object to S3", async t => {
9187
const image = new ImageData("network-error.jpg", "fixture", fixture, {}, "private");
@@ -95,4 +91,4 @@ test("Fail on network error while pushing ImageData object to S3", async t => {
9591
}, (reason) => {
9692
t.is(reason, "Simulated network error")
9793
})
98-
})
94+
});

0 commit comments

Comments
 (0)