Skip to content

Commit 4fe8908

Browse files
author
Arthur Cinader
authored
Add lint to project. (#34)
* Add lint to project. * pr comment that prevents me from breaking the world
1 parent fa27701 commit 4fe8908

File tree

8 files changed

+83
-26
lines changed

8 files changed

+83
-26
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage/*

.eslintrc.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"root": true,
3+
"extends": "eslint:recommended",
4+
"env": {
5+
"node": true,
6+
"es6": true
7+
},
8+
"parserOptions": {
9+
"ecmaVersion": 6,
10+
"sourceType": "module"
11+
},
12+
"rules": {
13+
"indent": ["error", 2],
14+
"linebreak-style": ["error", "unix"],
15+
"no-trailing-spaces": 2,
16+
"eol-last": 2,
17+
"space-in-parens": ["error", "never"],
18+
"no-multiple-empty-lines": 1
19+
}
20+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ node_modules
3434

3535
# Webstorm
3636
.idea/
37+
38+
.eslintcache

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ S3Adapter.prototype.createBucket = function() {
4343
if (this._hasBucket) {
4444
promise = Promise.resolve();
4545
} else {
46-
promise = new Promise((resolve, reject) => {
46+
promise = new Promise((resolve) => {
4747
this._s3Client.createBucket(() => {
4848
this._hasBucket = true;
4949
resolve();

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"description": "AWS S3 adapter for parse-server",
55
"main": "index.js",
66
"scripts": {
7-
"test": "NODE_ENV=test NODE_CONFIG_DIR=./spec/config istanbul cover -x **/spec/** jasmine --captureExceptions"
7+
"pretest": "npm run lint",
8+
"test": "NODE_ENV=test NODE_CONFIG_DIR=./spec/config istanbul cover -x **/spec/** jasmine --captureExceptions",
9+
"lint": "eslint --cache ./"
810
},
911
"repository": {
1012
"type": "git",
@@ -27,6 +29,7 @@
2729
"devDependencies": {
2830
"codecov": "^1.0.1",
2931
"config": "^1.24.0",
32+
"eslint": "^3.11.1",
3033
"istanbul": "^0.4.2",
3134
"jasmine": "^2.4.1",
3235
"parse-server-conformance-tests": "^1.0.0"

spec/.eslintrc.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"env": {
3+
"jasmine": true
4+
},
5+
"globals": {
6+
"Parse": true,
7+
"reconfigureServer": true,
8+
"createTestUser": true,
9+
"jfail": true,
10+
"ok": true,
11+
"strictEqual": true,
12+
"TestObject": true,
13+
"Item": true,
14+
"Container": true,
15+
"equal": true,
16+
"notEqual": true,
17+
"it_exclude_dbs": true,
18+
"describe_only_db": true,
19+
"on_db": true,
20+
"defaultConfiguration": true,
21+
"expectSuccess": true,
22+
"range": true,
23+
"expectError": true,
24+
"jequal": true,
25+
"create": true,
26+
"arrayContains": true
27+
},
28+
"rules": {
29+
"no-console": [0]
30+
}
31+
}

spec/config/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ module.exports = {
77
},
88
bucket: 'bucket',
99
objectWithBucket: {
10-
bucket: 'bucket',
10+
bucket: 'bucket',
1111
},
1212
emptyObject: {},
1313
paramsObjectWBucket: {
14-
params: {
15-
Bucket: 'bucket',
16-
},
14+
params: {
15+
Bucket: 'bucket',
16+
},
1717
},
1818
};

spec/test.spec.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ describe('S3Adapter tests', () => {
1111
delete process.env.S3_REGION;
1212
});
1313

14-
it('should throw when not initialized properly', () => {
15-
expect(() => {
16-
var s3 = new S3Adapter();
14+
it('should throw when not initialized properly', () => {
15+
expect(() => {
16+
new S3Adapter();
1717
}).toThrow("S3Adapter requires option 'bucket' or env. variable S3_BUCKET");
1818

19-
expect(() =>  {
20-
var s3 = new S3Adapter('accessKey', 'secretKey', {});
19+
expect(() => {
20+
new S3Adapter('accessKey', 'secretKey', {});
2121
}).toThrow(new Error('Failed to configure S3Adapter. Arguments don\'t make sense'));
2222

23-
expect(() => {
24-
var s3 = new S3Adapter({ accessKey: 'accessKey' , secretKey: 'secretKey'});
23+
expect(() => {
24+
new S3Adapter({ accessKey: 'accessKey' , secretKey: 'secretKey'});
2525
}).toThrow("S3Adapter requires option 'bucket' or env. variable S3_BUCKET")
2626
})
2727

28-
it('should not throw when initialized properly', () => {
29-
expect(() => {
30-
var s3 = new S3Adapter('bucket');
28+
it('should not throw when initialized properly', () => {
29+
expect(() => {
30+
new S3Adapter('bucket');
3131
}).not.toThrow()
3232

33-
expect(() => {
34-
var s3 = new S3Adapter({ bucket: 'bucket'});
33+
expect(() => {
34+
new S3Adapter({ bucket: 'bucket'});
3535
}).not.toThrow()
3636

3737
expect(() => {
38-
var s3 = new S3Adapter({}, { params:{ Bucket: 'bucket'}});
38+
new S3Adapter({}, { params:{ Bucket: 'bucket'}});
3939
}).not.toThrow()
4040
});
4141

@@ -50,34 +50,34 @@ describe('S3Adapter tests', () => {
5050
describe('not initialized properly', () => {
5151
it('should fail with two string arguments', () => {
5252
expect(() => {
53-
var s3 = new S3Adapter(config.get('accessKey'), config.get('secretKey'), {});
53+
new S3Adapter(config.get('accessKey'), config.get('secretKey'), {});
5454
}).toThrow(new Error('Failed to configure S3Adapter. Arguments don\'t make sense'));
5555
});
5656

5757
it('should fail when passed an object without a bucket', () => {
5858
expect(() => {
59-
var s3 = new S3Adapter(config.get('insufficientOptions'));
59+
new S3Adapter(config.get('insufficientOptions'));
6060
}).toThrow("S3Adapter requires option 'bucket' or env. variable S3_BUCKET")
6161
});
6262
});
6363

6464

6565
describe('should not throw when initialized properly', () => {
6666
it('should accept a string bucket', () => {
67-
expect(() => {
68-
var s3 = new S3Adapter(config.get('bucket'));
67+
expect(() => {
68+
new S3Adapter(config.get('bucket'));
6969
}).not.toThrow()
7070
});
7171

7272
it('should accept an object with a bucket', () => {
73-
expect(() =>  {
74-
var s3 = new S3Adapter(config.get('objectWithBucket'));
73+
expect(() => {
74+
new S3Adapter(config.get('objectWithBucket'));
7575
}).not.toThrow()
7676
});
7777

7878
it('should accept a second argument of object with a params object with a bucket', () => {
7979
expect(() => {
80-
var s3 = new S3Adapter(config.get('emptyObject'), config.get('paramsObjectWBucket'));
80+
new S3Adapter(config.get('emptyObject'), config.get('paramsObjectWBucket'));
8181
}).not.toThrow()
8282
});
8383

0 commit comments

Comments
 (0)