Skip to content

Commit 2c9281a

Browse files
committed
chore(core): eslint config updates
1 parent cd05a4a commit 2c9281a

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
},
1414
"rules": {
1515
"standard/no-callback-literal": 0, // enable after error handing refactor
16-
"node/exports-style": ["error", "module.exports"],
16+
"node/exports-style": 0,
17+
"n/no-callback-literal": 0,
1718
"new-cap": 0,
1819
"no-console": "off",
1920
"complexity": ["error", 20]

src/client/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
},
1717
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:import/errors", "plugin:import/warnings"],
1818
"rules": {
19-
"node/no-unsupported-features/es-syntax": 0
19+
"node/no-unsupported-features/es-syntax": 0,
20+
"node/exports-style": 0
2021
},
2122
"settings": {
2223
"import/resolver": ["node", "webpack"]

src/permissions/index.js

+36-36
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
* Copyright (c) 2014-2019. All rights reserved.
1313
*/
1414

15-
var _ = require('lodash')
16-
var winston = require('../logger')
17-
var roleSchema = require('../models/role')
18-
var roleOrder = require('../models/roleorder')
15+
const _ = require('lodash')
16+
const winston = require('../logger')
17+
const roleSchema = require('../models/role')
18+
const roleOrder = require('../models/roleorder')
1919

20-
var register = function (callback) {
20+
const register = function (callback) {
2121
// Register Roles
2222
roleSchema.getRolesLean(function (err, roles) {
2323
if (err) return callback(err)
@@ -42,23 +42,23 @@ var register = function (callback) {
4242
* @returns {boolean}
4343
*/
4444

45-
var canThis = function (role, a, adminOverride = false) {
45+
const canThis = function (role, a, adminOverride = false) {
4646
if (_.isUndefined(role)) return false
4747
if (adminOverride === true && role.isAdmin) return true
4848

49-
var roles = global.roles
49+
const roles = global.roles
5050
if (_.isUndefined(roles)) return false
5151
if (_.hasIn(role, '_id')) role = role._id
52-
var rolePerm = _.find(roles, { _id: role })
52+
const rolePerm = _.find(roles, { _id: role })
5353
if (_.isUndefined(rolePerm)) return false
5454
if (_.indexOf(rolePerm.grants, '*') !== -1) return true
5555

56-
var actionType = a.split(':')[0]
57-
var action = a.split(':')[1]
56+
const actionType = a.split(':')[0]
57+
const action = a.split(':')[1]
5858

5959
if (_.isUndefined(actionType) || _.isUndefined(action)) return false
6060

61-
var result = _.filter(rolePerm.grants, function (value) {
61+
const result = _.filter(rolePerm.grants, function (value) {
6262
if (_.startsWith(value, actionType + ':')) return value
6363
})
6464

@@ -67,32 +67,32 @@ var canThis = function (role, a, adminOverride = false) {
6767
if (result[0] === '*') return true
6868
}
6969

70-
var typePerm = result[0].split(':')[1].split(' ')
70+
let typePerm = result[0].split(':')[1].split(' ')
7171
typePerm = _.uniq(typePerm)
7272

7373
if (_.indexOf(typePerm, '*') !== -1) return true
7474

7575
return _.indexOf(typePerm, action) !== -1
7676
}
7777

78-
var getRoles = function (action) {
78+
const getRoles = function (action) {
7979
if (_.isUndefined(action)) return false
8080

81-
var rolesWithAction = []
82-
var roles = global.roles
81+
let rolesWithAction = []
82+
const roles = global.roles
8383
if (_.isUndefined(roles)) return []
8484

8585
_.each(roles, function (role) {
86-
var actionType = action.split(':')[0]
87-
var theAction = action.split(':')[1]
86+
const actionType = action.split(':')[0]
87+
const theAction = action.split(':')[1]
8888

8989
if (_.isUndefined(actionType) || _.isUndefined(theAction)) return
9090
if (_.indexOf(role.grants, '*') !== -1) {
9191
rolesWithAction.push(role)
9292
return
9393
}
9494

95-
var result = _.filter(role.grants, function (value) {
95+
const result = _.filter(role.grants, function (value) {
9696
if (_.startsWith(value, actionType + ':')) return value
9797
})
9898

@@ -104,7 +104,7 @@ var getRoles = function (action) {
104104
}
105105
}
106106

107-
var typePerm = result[0].split(':')[1].split(' ')
107+
let typePerm = result[0].split(':')[1].split(' ')
108108
typePerm = _.uniq(typePerm)
109109

110110
if (_.indexOf(typePerm, '*') !== -1) {
@@ -123,17 +123,17 @@ var getRoles = function (action) {
123123
}
124124

125125
function hasHierarchyEnabled (roleId) {
126-
var role = _.find(global.roles, function (o) {
126+
const role = _.find(global.roles, function (o) {
127127
return o._id.toString() === roleId.toString()
128128
})
129129
if (_.isUndefined(role) || _.isUndefined(role.hierarchy)) return true
130130
return role.hierarchy
131131
}
132132

133133
function parseRoleHierarchy (roleId) {
134-
var roleOrder = global.roleOrder.order
134+
const roleOrder = global.roleOrder.order
135135

136-
var idx = _.findIndex(roleOrder, function (i) {
136+
const idx = _.findIndex(roleOrder, function (i) {
137137
return i.toString() === roleId.toString()
138138
})
139139
if (idx === -1) return []
@@ -142,9 +142,9 @@ function parseRoleHierarchy (roleId) {
142142
}
143143

144144
function hasPermOverRole (ownRole, extRole) {
145-
var roles = parseRoleHierarchy(extRole)
145+
const roles = parseRoleHierarchy(extRole)
146146

147-
var i = _.find(roles, function (o) {
147+
const i = _.find(roles, function (o) {
148148
return o.toString() === ownRole.toString()
149149
})
150150

@@ -160,9 +160,9 @@ function isAdmin (roleId, callback) {
160160
}
161161

162162
function isAdminSync (roleId) {
163-
var roles = global.roles
163+
const roles = global.roles
164164
if (!roles) return false
165-
var role = _.find(roles, function (r) {
165+
const role = _.find(roles, function (r) {
166166
return r._id.toString() === roleId.toString()
167167
})
168168

@@ -178,15 +178,15 @@ function buildGrants (obj) {
178178
}
179179

180180
module.exports = {
181-
register: register,
181+
register,
182182
flushRoles: register,
183-
canThis: canThis,
184-
hasHierarchyEnabled: hasHierarchyEnabled,
185-
parseRoleHierarchy: parseRoleHierarchy,
186-
hasPermOverRole: hasPermOverRole,
187-
188-
getRoles: getRoles,
189-
isAdmin: isAdmin,
190-
isAdminSync: isAdminSync,
191-
buildGrants: buildGrants
183+
canThis,
184+
hasHierarchyEnabled,
185+
parseRoleHierarchy,
186+
hasPermOverRole,
187+
188+
getRoles,
189+
isAdmin,
190+
isAdminSync,
191+
buildGrants
192192
}

src/public/js/vendor/uikit/js/uikit_combined.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)