Skip to content

Commit dfd5a8e

Browse files
authored
ci: Add lint rule for mandatory curly braces (#9348)
1 parent 714acaa commit dfd5a8e

22 files changed

+145
-137
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
"space-infix-ops": "error",
2626
"no-useless-escape": "off",
2727
"require-atomic-updates": "off",
28-
"object-curly-spacing": ["error", "always"]
28+
"object-curly-spacing": ["error", "always"],
29+
"curly": ["error", "all"],
30+
"block-spacing": ["error", "always"]
2931
},
3032
"globals": {
3133
"Parse": true

spec/support/MockLdapServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function newServer(port, dn, provokeSearchError = false, ssl = false) {
1111

1212
server.bind('o=example', function (req, res, next) {
1313
if (req.dn.toString() !== dn || req.credentials !== 'secret')
14-
return next(new ldapjs.InvalidCredentialsError());
14+
{ return next(new ldapjs.InvalidCredentialsError()); }
1515
res.end();
1616
return next();
1717
});

src/Adapters/Auth/OAuth1Client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ OAuth.nonce = function () {
122122
var text = '';
123123
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
124124

125-
for (var i = 0; i < 30; i++) text += possible.charAt(Math.floor(Math.random() * possible.length));
125+
for (var i = 0; i < 30; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); }
126126

127127
return text;
128128
};

src/Adapters/Auth/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ module.exports = function (authOptions = {}, enableAnonymousUsers = true) {
215215
return { validator: undefined };
216216
}
217217
const authAdapter = loadAuthAdapter(provider, authOptions);
218-
if (!authAdapter) return;
218+
if (!authAdapter) { return; }
219219
const { adapter, appIds, providerOptions } = authAdapter;
220220
return { validator: authDataValidator(provider, adapter, appIds, providerOptions), adapter };
221221
};

src/Adapters/Auth/keycloak.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ const { Parse } = require('parse/node');
3737
const httpsRequest = require('./httpsRequest');
3838

3939
const arraysEqual = (_arr1, _arr2) => {
40-
if (!Array.isArray(_arr1) || !Array.isArray(_arr2) || _arr1.length !== _arr2.length) return false;
40+
if (!Array.isArray(_arr1) || !Array.isArray(_arr2) || _arr1.length !== _arr2.length) { return false; }
4141

4242
var arr1 = _arr1.concat().sort();
4343
var arr2 = _arr2.concat().sort();
4444

4545
for (var i = 0; i < arr1.length; i++) {
46-
if (arr1[i] !== arr2[i]) return false;
46+
if (arr1[i] !== arr2[i]) { return false; }
4747
}
4848

4949
return true;

src/Auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ const findUsersWithAuthData = (config, authData) => {
434434
};
435435

436436
const hasMutatedAuthData = (authData, userAuthData) => {
437-
if (!userAuthData) return { hasMutatedAuthData: true, mutatedAuthData: authData };
437+
if (!userAuthData) { return { hasMutatedAuthData: true, mutatedAuthData: authData }; }
438438
const mutatedAuthData = {};
439439
Object.keys(authData).forEach(provider => {
440440
// Anonymous provider is not handled this way
441-
if (provider === 'anonymous') return;
441+
if (provider === 'anonymous') { return; }
442442
const providerData = authData[provider];
443443
const userProviderAuthData = userAuthData[provider];
444444
if (!isDeepStrictEqual(providerData, userProviderAuthData)) {

src/Config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class Config {
139139
}
140140

141141
static validateCustomPages(customPages) {
142-
if (!customPages) return;
142+
if (!customPages) { return; }
143143

144144
if (Object.prototype.toString.call(customPages) !== '[object Object]') {
145145
throw Error('Parse Server option customPages must be an object.');
@@ -209,7 +209,7 @@ export class Config {
209209
}
210210

211211
static validateSchemaOptions(schema: SchemaOptions) {
212-
if (!schema) return;
212+
if (!schema) { return; }
213213
if (Object.prototype.toString.call(schema) !== '[object Object]') {
214214
throw 'Parse Server option schema must be an object.';
215215
}

src/Controllers/DatabaseController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const filterSensitiveData = (
142142
object: any
143143
) => {
144144
let userId = null;
145-
if (auth && auth.user) userId = auth.user.id;
145+
if (auth && auth.user) { userId = auth.user.id; }
146146

147147
// replace protectedFields when using pointer-permissions
148148
const perms =
@@ -1592,12 +1592,12 @@ class DatabaseController {
15921592
schema && schema.getClassLevelPermissions
15931593
? schema.getClassLevelPermissions(className)
15941594
: schema;
1595-
if (!perms) return null;
1595+
if (!perms) { return null; }
15961596

15971597
const protectedFields = perms.protectedFields;
1598-
if (!protectedFields) return null;
1598+
if (!protectedFields) { return null; }
15991599

1600-
if (aclGroup.indexOf(query.objectId) > -1) return null;
1600+
if (aclGroup.indexOf(query.objectId) > -1) { return null; }
16011601

16021602
// for queries where "keys" are set and do not include all 'userField':{field},
16031603
// we have to transparently include it, and then remove before returning to client

src/Controllers/SchemaController.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,10 @@ const VolatileClassesSchemas = [
666666
];
667667

668668
const dbTypeMatchesObjectType = (dbType: SchemaField | string, objectType: SchemaField) => {
669-
if (dbType.type !== objectType.type) return false;
670-
if (dbType.targetClass !== objectType.targetClass) return false;
671-
if (dbType === objectType.type) return true;
672-
if (dbType.type === objectType.type) return true;
669+
if (dbType.type !== objectType.type) { return false; }
670+
if (dbType.targetClass !== objectType.targetClass) { return false; }
671+
if (dbType === objectType.type) { return true; }
672+
if (dbType.type === objectType.type) { return true; }
673673
return false;
674674
};
675675

@@ -1020,7 +1020,7 @@ export default class SchemaController {
10201020
}
10211021
const fieldType = fields[fieldName];
10221022
const error = fieldTypeIsInvalid(fieldType);
1023-
if (error) return { code: error.code, error: error.message };
1023+
if (error) { return { code: error.code, error: error.message }; }
10241024
if (fieldType.defaultValue !== undefined) {
10251025
let defaultValueType = getType(fieldType.defaultValue);
10261026
if (typeof defaultValueType === 'string') {

src/Controllers/UserController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class UserController extends AdaptableController {
122122
if (expiresDate && expiresDate.__type == 'Date') {
123123
expiresDate = new Date(expiresDate.iso);
124124
}
125-
if (expiresDate < new Date()) throw 'The password reset link has expired';
125+
if (expiresDate < new Date()) { throw 'The password reset link has expired'; }
126126
}
127127
return results[0];
128128
});

0 commit comments

Comments
 (0)