Skip to content

Commit 2c29756

Browse files
authored
refactor: Add a few lint rules to test files in /spec (#9815)
1 parent 207d241 commit 2c29756

9 files changed

+57
-49
lines changed

spec/Adapters/Auth/gcenter.spec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ describe('GameCenterAuth Adapter', function () {
1212
const gcProd4 = fs.readFileSync(path.resolve(__dirname, '../../support/cert/gc-prod-4.cer'));
1313
const digicertPem = fs.readFileSync(path.resolve(__dirname, '../../support/cert/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem')).toString();
1414

15-
mockFetch([
16-
{
17-
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
18-
method: 'GET',
19-
response: {
20-
ok: true,
21-
headers: new Map(),
22-
arrayBuffer: () => Promise.resolve(
23-
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
24-
),
15+
mockFetch([
16+
{
17+
url: 'https://static.gc.apple.com/public-key/gc-prod-4.cer',
18+
method: 'GET',
19+
response: {
20+
ok: true,
21+
headers: new Map(),
22+
arrayBuffer: () => Promise.resolve(
23+
gcProd4.buffer.slice(gcProd4.byteOffset, gcProd4.byteOffset + gcProd4.length)
24+
),
25+
},
2526
},
26-
},
27-
{
28-
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
29-
method: 'GET',
30-
response: {
31-
ok: true,
32-
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
33-
text: () => Promise.resolve(digicertPem),
34-
},
35-
}
36-
]);
27+
{
28+
url: 'https://cacerts.digicert.com/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crt.pem',
29+
method: 'GET',
30+
response: {
31+
ok: true,
32+
headers: new Map([['content-type', 'application/x-pem-file'], ['content-length', digicertPem.length.toString()]]),
33+
text: () => Promise.resolve(digicertPem),
34+
},
35+
}
36+
]);
3737
});
3838

3939
describe('Test config failing due to missing params or wrong types', function () {

spec/CloudCode.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,9 +3502,9 @@ describe('afterLogin hook', () => {
35023502
'X-Parse-REST-API-Key': 'rest',
35033503
'X-Parse-Cloud-Context': '{"a":"a"}',
35043504
},
3505-
body: JSON.stringify({_context: { hello: 'world' }}),
3505+
body: JSON.stringify({ _context: { hello: 'world' } }),
35063506
});
3507-
3507+
35083508
});
35093509

35103510
it('should have access to context when saving a new object', async () => {
@@ -3929,7 +3929,7 @@ describe('saveFile hooks', () => {
39293929
});
39303930
});
39313931

3932-
describe('Parse.File hooks', () => {
3932+
describe('Parse.File hooks', () => {
39333933
it('find hooks should run', async () => {
39343934
const file = new Parse.File('popeye.txt', [1, 2, 3], 'text/plain');
39353935
await file.save({ useMasterKey: true });
@@ -4047,7 +4047,7 @@ describe('Parse.File hooks', () => {
40474047
});
40484048
expect(response.headers['content-disposition']).toBe(`attachment;filename=${file._name}`);
40494049
});
4050-
});
4050+
});
40514051

40524052
describe('Cloud Config hooks', () => {
40534053
function testConfig() {

spec/EmailVerificationToken.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ describe('Email Verification Token Expiration:', () => {
647647

648648
it_id('b6c87f35-d887-477d-bc86-a9217a424f53')(it)('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', async () => {
649649
const user = new Parse.User();
650-
let userBeforeEmailReset;
651650

652651
let sendEmailOptions;
653652
const sendPromise = resolvingPromise();
@@ -680,7 +679,7 @@ describe('Email Verification Token Expiration:', () => {
680679
return results[0];
681680
});
682681
expect(typeof userFromDb).toBe('object');
683-
userBeforeEmailReset = userFromDb;
682+
const userBeforeEmailReset = userFromDb;
684683

685684
// trigger another token generation by setting the email
686685
user.set('email', '[email protected]');
@@ -713,7 +712,6 @@ describe('Email Verification Token Expiration:', () => {
713712
const user = new Parse.User();
714713
let sendEmailOptions;
715714
let sendVerificationEmailCallCount = 0;
716-
let userBeforeRequest;
717715
const promise1 = resolvingPromise();
718716
const promise2 = resolvingPromise();
719717
const emailAdapter = {
@@ -748,7 +746,7 @@ describe('Email Verification Token Expiration:', () => {
748746
return results[0];
749747
});
750748
// store this user before we make our email request
751-
userBeforeRequest = newUser;
749+
const userBeforeRequest = newUser;
752750

753751
expect(sendVerificationEmailCallCount).toBe(1);
754752

@@ -1011,7 +1009,7 @@ describe('Email Verification Token Expiration:', () => {
10111009
})
10121010
.then(fail)
10131011
.catch(response => response);
1014-
1012+
10151013
expect(response.status).toBe(400);
10161014
expect(sendVerificationEmailCallCount).toBe(0);
10171015
expect(sendEmailOptions).not.toBeDefined();

spec/ParseGraphQLServer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ describe('ParseGraphQLServer', () => {
456456
}
457457

458458
beforeEach(async () => {
459-
await createGQLFromParseServer(parseServer);
459+
await createGQLFromParseServer(parseServer);
460460

461461
const subscriptionClient = new SubscriptionClient(
462462
'ws://localhost:13377/subscriptions',

spec/ParseLiveQuery.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ describe('ParseLiveQuery', function () {
11821182
await sleep(100);
11831183
expect(server.liveQueryServer.server.address()).toBeNull();
11841184
expect(server.liveQueryServer.subscriber.isOpen).toBeFalse();
1185-
1185+
11861186
liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server);
11871187
expect(liveQueryConnectionCount).toBe(0);
11881188
});

spec/ParseQuery.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5312,7 +5312,7 @@ describe('Parse.Query testing', () => {
53125312
const child = new Parse.Object('Child');
53135313
child.set('key', 'value');
53145314
await child.save();
5315-
5315+
53165316
const parent = new Parse.Object('Parent');
53175317
parent.set('some', {
53185318
nested: {
@@ -5322,19 +5322,19 @@ describe('Parse.Query testing', () => {
53225322
},
53235323
});
53245324
await parent.save();
5325-
5325+
53265326
const query1 = await new Parse.Query('Parent')
53275327
.equalTo('some.nested.key.child', child)
53285328
.find();
5329-
5329+
53305330
expect(query1.length).toEqual(1);
53315331
});
5332-
5332+
53335333
it('queries nested key using containedIn', async () => {
53345334
const child = new Parse.Object('Child');
53355335
child.set('key', 'value');
53365336
await child.save();
5337-
5337+
53385338
const parent = new Parse.Object('Parent');
53395339
parent.set('some', {
53405340
nested: {
@@ -5344,19 +5344,19 @@ describe('Parse.Query testing', () => {
53445344
},
53455345
});
53465346
await parent.save();
5347-
5347+
53485348
const query1 = await new Parse.Query('Parent')
53495349
.containedIn('some.nested.key.child', [child])
53505350
.find();
5351-
5351+
53525352
expect(query1.length).toEqual(1);
53535353
});
5354-
5354+
53555355
it('queries nested key using matchesQuery', async () => {
53565356
const child = new Parse.Object('Child');
53575357
child.set('key', 'value');
53585358
await child.save();
5359-
5359+
53605360
const parent = new Parse.Object('Parent');
53615361
parent.set('some', {
53625362
nested: {
@@ -5366,11 +5366,11 @@ describe('Parse.Query testing', () => {
53665366
},
53675367
});
53685368
await parent.save();
5369-
5369+
53705370
const query1 = await new Parse.Query('Parent')
53715371
.matchesQuery('some.nested.key.child', new Parse.Query('Child').equalTo('key', 'value'))
53725372
.find();
5373-
5373+
53745374
expect(query1.length).toEqual(1);
53755375
});
53765376
});

spec/Utils.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('Utils', () => {
88
]
99
for (const value of values) {
1010
expect(Utils.encodeForUrl(value.input)).toBe(value.output);
11-
}
11+
}
1212
});
1313
});
1414

spec/eslint.config.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ module.exports = [
4848
},
4949
},
5050
rules: {
51-
"no-console": "off",
52-
"no-var": "error",
53-
"no-unused-vars": "off",
51+
indent: ["error", 2, { SwitchCase: 1 }],
52+
"linebreak-style": ["error", "unix"],
53+
"no-trailing-spaces": "error",
54+
"eol-last": "error",
55+
"space-in-parens": ["error", "never"],
56+
"no-multiple-empty-lines": "warn",
57+
"prefer-const": "error",
58+
"space-infix-ops": "error",
5459
"no-useless-escape": "off",
55-
}
60+
"require-atomic-updates": "off",
61+
"object-curly-spacing": ["error", "always"],
62+
curly: ["error", "all"],
63+
"block-spacing": ["error", "always"],
64+
"no-unused-vars": "off",
65+
},
5666
},
5767
];

spec/support/CurrentSpecReporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ global.retryFlakyTests = function() {
114114
};
115115
}
116116

117-
module.exports = CurrentSpecReporter;
117+
module.exports = CurrentSpecReporter;

0 commit comments

Comments
 (0)