Skip to content

Commit 799c1dd

Browse files
committed
added updated eslint rules.
1 parent 5adeb4b commit 799c1dd

File tree

6 files changed

+42
-38
lines changed

6 files changed

+42
-38
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
},
1515
rules: {
1616
// Bad Practices
17-
'@typescript-eslint/camelcase': 'on',
1817
'@typescript-eslint/no-explicit-any': 'off',
1918
'curly': 'error',
2019
'no-await-in-loop': 'error',

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"scripts": {
88
"prepublish": "npm run build",
99
"build": "tsc",
10-
"test": "ts-mocha -p tsconfig.json test/**/*.spec.ts"
10+
"test": "ts-mocha -p tsconfig.json test/**/*.spec.ts",
11+
"lint": "eslint --ext *.ts src/*.ts test/*.ts"
1112
},
1213
"keywords": [
1314
"json",

src/trivialperms.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class TPManager
1515
{
1616
groups : Map<string, TPGroup> = new Map();
1717

18-
_userHasPerm(user : TPUser, perm : string) : boolean
18+
//------------------------------------------------------------------------------------------------------------------
19+
// Internal
20+
//------------------------------------------------------------------------------------------------------------------
21+
22+
private _userHasPerm(user : TPUser, perm : string) : boolean
1923
{
2024
return checkPerm(user.permissions ?? [], perm);
2125
}
@@ -37,7 +41,7 @@ class TPManager
3741
}
3842

3943
const group = new TPGroup(groupDef.name, groupDef.permissions);
40-
this.groups.set(groupDef.name, group);
44+
this.groups.set(groupDef.name, group);
4145

4246
return group;
4347
}
@@ -76,7 +80,7 @@ class TPManager
7680
{
7781
if(group)
7882
{
79-
return group.hasPerm(perm)
83+
return group.hasPerm(perm);
8084
}
8185

8286
return false;

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export function checkPerm(permissions : string[], perm : string) : boolean
1212
return permissions.some((permission) =>
1313
{
1414
return permission === '*'
15-
|| permission === '*/*' // Legacy form
16-
|| permission === `*/${ perm }` // Legacy form
17-
|| permission === perm
15+
|| permission === '*/*' // Legacy form
16+
|| permission === `*/${ perm }` // Legacy form
17+
|| permission === perm;
1818
});
1919
}
2020

test/group.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { TPGroup } from '../src/group';
99

1010
describe('TPGroup', () =>
1111
{
12-
let groupInst, god, godLegacy;
12+
let groupInst; let god; let godLegacy;
1313
beforeEach(() =>
1414
{
1515
groupInst = new TPGroup('test', [

test/trivialperms.spec.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,59 @@ import { TPGroupDef } from '../src/interfaces/group';
1010

1111
describe('TrivialPermissions', () =>
1212
{
13-
let batman, stark, mel, leo, azira, crowley;
13+
let batman; let stark; let mel; let leo; let azira; let crowley;
1414
beforeEach(() =>
1515
{
1616
batman = {
1717
name: 'batman',
18-
groups: ['Administrators']
18+
groups: [ 'Administrators' ]
1919
};
2020

2121
stark = {
2222
name: 'tstark',
23-
permissions: ['*'],
24-
groups: ['Users']
23+
permissions: [ '*' ],
24+
groups: [ 'Users' ]
2525
};
2626

2727
leo = {
2828
name: 'lblume',
29-
groups: ['Users']
29+
groups: [ 'Users' ]
3030
};
3131

3232
mel = {
3333
name: 'projektMelody',
34-
groups: ['Users', 'Authors']
34+
groups: [ 'Users', 'Authors' ]
3535
};
3636

3737
azira = {
3838
name: 'aziraphale',
39-
permissions: ['*/canView']
40-
}
39+
permissions: [ '*/canView' ]
40+
};
4141

4242
crowley = {
4343
name: 'bentleyLover666',
44-
permissions: ['*/*']
45-
}
44+
permissions: [ '*/*' ]
45+
};
4646

4747
tp.loadGroups([
4848
{
49-
name: "Administrators",
49+
name: 'Administrators',
5050
permissions: [
51-
"*"
51+
'*'
5252
]
5353
},
5454
{
55-
name: "Authors",
55+
name: 'Authors',
5656
permissions: [
57-
"canViewPosts",
58-
"canAddPosts",
59-
"canEditPosts"
57+
'canViewPosts',
58+
'canAddPosts',
59+
'canEditPosts'
6060
]
6161
},
6262
{
63-
name: "Users",
63+
name: 'Users',
6464
permissions: [
65-
"canViewPosts"
65+
'canViewPosts'
6666
]
6767
}
6868
]);
@@ -79,7 +79,7 @@ describe('TrivialPermissions', () =>
7979
it('can define a group', () =>
8080
{
8181
tp.defineGroup({
82-
name: "Test",
82+
name: 'Test',
8383
permissions: []
8484
});
8585

@@ -88,7 +88,7 @@ describe('TrivialPermissions', () =>
8888

8989
it('throws an error if your group does not have a `name` property', () =>
9090
{
91-
function define()
91+
function define() : void
9292
{
9393
// WE ARE INTENTIONALLY BREAKING TYPESCRIPT TO TEST THIS
9494
tp.defineGroup({} as unknown as TPGroupDef);
@@ -101,23 +101,23 @@ describe('TrivialPermissions', () =>
101101
{
102102
tp.loadGroups([
103103
{
104-
name: "Test1",
104+
name: 'Test1',
105105
permissions: [
106-
"*"
106+
'*'
107107
]
108108
},
109109
{
110-
name: "Test2",
110+
name: 'Test2',
111111
permissions: [
112-
"canView",
113-
"canAdd",
114-
"canEdit"
112+
'canView',
113+
'canAdd',
114+
'canEdit'
115115
]
116116
},
117117
{
118-
name: "Test3",
118+
name: 'Test3',
119119
permissions: [
120-
"canView"
120+
'canView'
121121
]
122122
}
123123
]);
@@ -149,7 +149,7 @@ describe('TrivialPermissions', () =>
149149
it('returns false when checking the groups of a user if the group is not registered', () =>
150150
{
151151
const user = {
152-
groups: ['Users', 'Fakes']
152+
groups: [ 'Users', 'Fakes' ]
153153
};
154154

155155
expect(tp.hasGroup(user, 'Fakes')).to.equal(false);

0 commit comments

Comments
 (0)