Skip to content

Commit e6ac3b6

Browse files
authored
fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders. Set max line length to be 100
1 parent c2f2281 commit e6ac3b6

File tree

178 files changed

+5573
-10676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+5573
-10676
lines changed

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
semi: true
22
trailingComma: "es5"
33
singleQuote: true
4-
arrowParens: "avoid"
4+
arrowParens: "avoid"
5+
printWidth: 100

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"posttest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=4.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=mmapv1} mongodb-runner stop",
106106
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=4.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=mmapv1} TESTING=1 nyc jasmine",
107107
"start": "node ./bin/parse-server",
108-
"prettier": "prettier --write {src,spec}/**/*.js",
108+
"prettier": "prettier --write {src,spec}/{**/*,*}.js",
109109
"prepare": "npm run build",
110110
"postinstall": "node -p 'require(\"./postinstall.js\")()'"
111111
},
@@ -133,7 +133,7 @@
133133
}
134134
},
135135
"lint-staged": {
136-
"{src,spec}/**/*.js": [
136+
"{src,spec}/{**/*,*}.js": [
137137
"prettier --write",
138138
"eslint --fix --cache",
139139
"git add"

spec/AccountLockoutPolicy.spec.js

+26-83
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const Config = require('../lib/Config');
44

5-
const loginWithWrongCredentialsShouldFail = function(username, password) {
5+
const loginWithWrongCredentialsShouldFail = function (username, password) {
66
return new Promise((resolve, reject) => {
77
Parse.User.logIn(username, password)
88
.then(() => reject('login should have failed'))
@@ -16,7 +16,7 @@ const loginWithWrongCredentialsShouldFail = function(username, password) {
1616
});
1717
};
1818

19-
const isAccountLockoutError = function(username, password, duration, waitTime) {
19+
const isAccountLockoutError = function (username, password, duration, waitTime) {
2020
return new Promise((resolve, reject) => {
2121
setTimeout(() => {
2222
Parse.User.logIn(username, password)
@@ -50,28 +50,17 @@ describe('Account Lockout Policy: ', () => {
5050
return user.signUp(null);
5151
})
5252
.then(() => {
53-
return loginWithWrongCredentialsShouldFail(
54-
'username1',
55-
'incorrect password 1'
56-
);
53+
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 1');
5754
})
5855
.then(() => {
59-
return loginWithWrongCredentialsShouldFail(
60-
'username1',
61-
'incorrect password 2'
62-
);
56+
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 2');
6357
})
6458
.then(() => {
65-
return loginWithWrongCredentialsShouldFail(
66-
'username1',
67-
'incorrect password 3'
68-
);
59+
return loginWithWrongCredentialsShouldFail('username1', 'incorrect password 3');
6960
})
7061
.then(() => done())
7162
.catch(err => {
72-
fail(
73-
'allow unlimited failed login attempts failed: ' + JSON.stringify(err)
74-
);
63+
fail('allow unlimited failed login attempts failed: ' + JSON.stringify(err));
7564
done();
7665
});
7766
});
@@ -93,15 +82,11 @@ describe('Account Lockout Policy: ', () => {
9382
.catch(err => {
9483
if (
9584
err &&
96-
err ===
97-
'Account lockout duration should be greater than 0 and less than 100000'
85+
err === 'Account lockout duration should be greater than 0 and less than 100000'
9886
) {
9987
done();
10088
} else {
101-
fail(
102-
'set duration to an invalid number test failed: ' +
103-
JSON.stringify(err)
104-
);
89+
fail('set duration to an invalid number test failed: ' + JSON.stringify(err));
10590
done();
10691
}
10792
});
@@ -124,15 +109,11 @@ describe('Account Lockout Policy: ', () => {
124109
.catch(err => {
125110
if (
126111
err &&
127-
err ===
128-
'Account lockout threshold should be an integer greater than 0 and less than 1000'
112+
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
129113
) {
130114
done();
131115
} else {
132-
fail(
133-
'set threshold to an invalid number test failed: ' +
134-
JSON.stringify(err)
135-
);
116+
fail('set threshold to an invalid number test failed: ' + JSON.stringify(err));
136117
done();
137118
}
138119
});
@@ -155,14 +136,11 @@ describe('Account Lockout Policy: ', () => {
155136
.catch(err => {
156137
if (
157138
err &&
158-
err ===
159-
'Account lockout threshold should be an integer greater than 0 and less than 1000'
139+
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
160140
) {
161141
done();
162142
} else {
163-
fail(
164-
'threshold value < 1 is invalid test failed: ' + JSON.stringify(err)
165-
);
143+
fail('threshold value < 1 is invalid test failed: ' + JSON.stringify(err));
166144
done();
167145
}
168146
});
@@ -185,15 +163,11 @@ describe('Account Lockout Policy: ', () => {
185163
.catch(err => {
186164
if (
187165
err &&
188-
err ===
189-
'Account lockout threshold should be an integer greater than 0 and less than 1000'
166+
err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
190167
) {
191168
done();
192169
} else {
193-
fail(
194-
'threshold value > 999 is invalid test failed: ' +
195-
JSON.stringify(err)
196-
);
170+
fail('threshold value > 999 is invalid test failed: ' + JSON.stringify(err));
197171
done();
198172
}
199173
});
@@ -216,14 +190,11 @@ describe('Account Lockout Policy: ', () => {
216190
.catch(err => {
217191
if (
218192
err &&
219-
err ===
220-
'Account lockout duration should be greater than 0 and less than 100000'
193+
err === 'Account lockout duration should be greater than 0 and less than 100000'
221194
) {
222195
done();
223196
} else {
224-
fail(
225-
'duration value < 1 is invalid test failed: ' + JSON.stringify(err)
226-
);
197+
fail('duration value < 1 is invalid test failed: ' + JSON.stringify(err));
227198
done();
228199
}
229200
});
@@ -246,15 +217,11 @@ describe('Account Lockout Policy: ', () => {
246217
.catch(err => {
247218
if (
248219
err &&
249-
err ===
250-
'Account lockout duration should be greater than 0 and less than 100000'
220+
err === 'Account lockout duration should be greater than 0 and less than 100000'
251221
) {
252222
done();
253223
} else {
254-
fail(
255-
'duration value > 99999 is invalid test failed: ' +
256-
JSON.stringify(err)
257-
);
224+
fail('duration value > 99999 is invalid test failed: ' + JSON.stringify(err));
258225
done();
259226
}
260227
});
@@ -276,16 +243,10 @@ describe('Account Lockout Policy: ', () => {
276243
return user.signUp();
277244
})
278245
.then(() => {
279-
return loginWithWrongCredentialsShouldFail(
280-
'username2',
281-
'wrong password'
282-
);
246+
return loginWithWrongCredentialsShouldFail('username2', 'wrong password');
283247
})
284248
.then(() => {
285-
return loginWithWrongCredentialsShouldFail(
286-
'username2',
287-
'wrong password'
288-
);
249+
return loginWithWrongCredentialsShouldFail('username2', 'wrong password');
289250
})
290251
.then(() => {
291252
return isAccountLockoutError('username2', 'wrong password', 1, 1);
@@ -294,10 +255,7 @@ describe('Account Lockout Policy: ', () => {
294255
done();
295256
})
296257
.catch(err => {
297-
fail(
298-
'lock account after failed login attempts test failed: ' +
299-
JSON.stringify(err)
300-
);
258+
fail('lock account after failed login attempts test failed: ' + JSON.stringify(err));
301259
done();
302260
});
303261
});
@@ -318,16 +276,10 @@ describe('Account Lockout Policy: ', () => {
318276
return user.signUp();
319277
})
320278
.then(() => {
321-
return loginWithWrongCredentialsShouldFail(
322-
'username3',
323-
'wrong password'
324-
);
279+
return loginWithWrongCredentialsShouldFail('username3', 'wrong password');
325280
})
326281
.then(() => {
327-
return loginWithWrongCredentialsShouldFail(
328-
'username3',
329-
'wrong password'
330-
);
282+
return loginWithWrongCredentialsShouldFail('username3', 'wrong password');
331283
})
332284
.then(() => {
333285
return isAccountLockoutError('username3', 'wrong password', 0.05, 1);
@@ -340,10 +292,7 @@ describe('Account Lockout Policy: ', () => {
340292
done();
341293
})
342294
.catch(err => {
343-
fail(
344-
'account should be locked for duration mins test failed: ' +
345-
JSON.stringify(err)
346-
);
295+
fail('account should be locked for duration mins test failed: ' + JSON.stringify(err));
347296
done();
348297
});
349298
});
@@ -364,16 +313,10 @@ describe('Account Lockout Policy: ', () => {
364313
return user.signUp();
365314
})
366315
.then(() => {
367-
return loginWithWrongCredentialsShouldFail(
368-
'username4',
369-
'wrong password'
370-
);
316+
return loginWithWrongCredentialsShouldFail('username4', 'wrong password');
371317
})
372318
.then(() => {
373-
return loginWithWrongCredentialsShouldFail(
374-
'username4',
375-
'wrong password'
376-
);
319+
return loginWithWrongCredentialsShouldFail('username4', 'wrong password');
377320
})
378321
.then(() => {
379322
// allow locked user to login after 3 seconds with a valid userid and password

spec/AdaptableController.spec.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
const AdaptableController = require('../lib/Controllers/AdaptableController')
2-
.AdaptableController;
1+
const AdaptableController = require('../lib/Controllers/AdaptableController').AdaptableController;
32
const FilesAdapter = require('../lib/Adapters/Files/FilesAdapter').default;
4-
const FilesController = require('../lib/Controllers/FilesController')
5-
.FilesController;
3+
const FilesController = require('../lib/Controllers/FilesController').FilesController;
64

7-
const MockController = function(options) {
5+
const MockController = function (options) {
86
AdaptableController.call(this, options);
97
};
108
MockController.prototype = Object.create(AdaptableController.prototype);
@@ -60,11 +58,11 @@ describe('AdaptableController', () => {
6058

6159
it('should accept an object adapter', done => {
6260
const adapter = {
63-
createFile: function() {},
64-
deleteFile: function() {},
65-
getFileData: function() {},
66-
getFileLocation: function() {},
67-
validateFilename: function() {},
61+
createFile: function () {},
62+
deleteFile: function () {},
63+
getFileData: function () {},
64+
getFileLocation: function () {},
65+
validateFilename: function () {},
6866
};
6967
expect(() => {
7068
new FilesController(adapter);
@@ -74,11 +72,11 @@ describe('AdaptableController', () => {
7472

7573
it('should accept an prototype based object adapter', done => {
7674
function AGoodAdapter() {}
77-
AGoodAdapter.prototype.createFile = function() {};
78-
AGoodAdapter.prototype.deleteFile = function() {};
79-
AGoodAdapter.prototype.getFileData = function() {};
80-
AGoodAdapter.prototype.getFileLocation = function() {};
81-
AGoodAdapter.prototype.validateFilename = function() {};
75+
AGoodAdapter.prototype.createFile = function () {};
76+
AGoodAdapter.prototype.deleteFile = function () {};
77+
AGoodAdapter.prototype.getFileData = function () {};
78+
AGoodAdapter.prototype.getFileLocation = function () {};
79+
AGoodAdapter.prototype.validateFilename = function () {};
8280

8381
const adapter = new AGoodAdapter();
8482
expect(() => {

spec/AdapterLoader.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ describe('AdapterLoader', () => {
3131
});
3232

3333
it('should instantiate an adapter from string that is module', done => {
34-
const adapterPath = require('path').resolve(
35-
'./lib/Adapters/Files/FilesAdapter'
36-
);
34+
const adapterPath = require('path').resolve('./lib/Adapters/Files/FilesAdapter');
3735
const adapter = loadAdapter({
3836
adapter: adapterPath,
3937
});
@@ -88,14 +86,14 @@ describe('AdapterLoader', () => {
8886
});
8987

9088
it('should fail loading an improperly configured adapter', done => {
91-
const Adapter = function(options) {
89+
const Adapter = function (options) {
9290
if (!options.foo) {
9391
throw 'foo is required for that adapter';
9492
}
9593
};
9694
const adapterOptions = {
9795
param: 'key',
98-
doSomething: function() {},
96+
doSomething: function () {},
9997
};
10098

10199
expect(() => {

spec/AggregateRouter.spec.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const AggregateRouter = require('../lib/Routers/AggregateRouter')
2-
.AggregateRouter;
1+
const AggregateRouter = require('../lib/Routers/AggregateRouter').AggregateRouter;
32

43
describe('AggregateRouter', () => {
54
it('get pipeline from Array', () => {
@@ -56,9 +55,7 @@ describe('AggregateRouter', () => {
5655
try {
5756
AggregateRouter.getPipeline(body);
5857
} catch (e) {
59-
expect(e.message).toBe(
60-
'Pipeline stages should only have one key found group, match'
61-
);
58+
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
6259
}
6360
});
6461

@@ -74,9 +71,7 @@ describe('AggregateRouter', () => {
7471
try {
7572
AggregateRouter.getPipeline(body);
7673
} catch (e) {
77-
expect(e.message).toBe(
78-
'Pipeline stages should only have one key found group, match'
79-
);
74+
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
8075
}
8176
});
8277
});

spec/Analytics.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const analyticsAdapter = {
2-
appOpened: function() {},
3-
trackEvent: function() {},
2+
appOpened: function () {},
3+
trackEvent: function () {},
44
};
55

66
describe('AnalyticsController', () => {

0 commit comments

Comments
 (0)