Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Improved ESLint setup (#1509)
Browse files Browse the repository at this point in the history
* improved ESLint setup

* enable prefer-const rule for tests

* force "explicit-module-boundary-types" for tests

* disable warnings for auto-generated content
  • Loading branch information
DenysVuika committed Feb 3, 2023
1 parent 26bbe4e commit 41e3184
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 85 deletions.
32 changes: 0 additions & 32 deletions .eslintrc.js

This file was deleted.

32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"root": true,
"env": {
"node": true,
"browser": true
},
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
// TODO: consider removing these rules and improving the source code
"rules": {
"prefer-const": "off",
"no-useless-escape": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": 1,
"@typescript-eslint/ban-types": 1,
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": 1
}
}
12 changes: 12 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["../.eslintrc.json"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"prefer-const": "error",
"@typescript-eslint/explicit-module-boundary-types": "error"
}
}
]
}
24 changes: 12 additions & 12 deletions test/alfrescoContent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ describe('AlfrescoContent', () => {
});

it('outputs content url', () => {
let contentUrl = contentApi.getContentUrl(nodeId);
const contentUrl = contentApi.getContentUrl(nodeId);

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/content?attachment=false' +
'&alf_ticket=TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
});

it('outputs content url as attachment', () => {
let contentUrl = contentApi.getContentUrl(nodeId, true);
const contentUrl = contentApi.getContentUrl(nodeId, true);

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/content?attachment=true' +
'&alf_ticket=TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
});

it('outputs content url with custom ticket', () => {
let contentUrl = contentApi.getContentUrl(nodeId, true, 'custom_ticket');
const contentUrl = contentApi.getContentUrl(nodeId, true, 'custom_ticket');

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/content?attachment=true' +
Expand All @@ -102,7 +102,7 @@ describe('AlfrescoContent', () => {

it('outputs rendition url', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getRenditionUrl(nodeId, encoding);
const contentUrl = contentApi.getRenditionUrl(nodeId, encoding);

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/renditions/' + encoding +
Expand All @@ -112,7 +112,7 @@ describe('AlfrescoContent', () => {

it('outputs rendition url as attachment', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getRenditionUrl(nodeId, encoding, true);
const contentUrl = contentApi.getRenditionUrl(nodeId, encoding, true);

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/renditions/' + encoding +
Expand All @@ -122,7 +122,7 @@ describe('AlfrescoContent', () => {

it('outputs rendition url with custom ticket', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getRenditionUrl(nodeId, encoding, true, 'custom_ticket');
const contentUrl = contentApi.getRenditionUrl(nodeId, encoding, true, 'custom_ticket');

expect(contentUrl).to.be.equal(nodesUrl + nodeId +
'/renditions/' + encoding +
Expand All @@ -132,7 +132,7 @@ describe('AlfrescoContent', () => {

it('outputs version rendition url', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding);
const contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding);

expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/renditions/' + encoding +
Expand All @@ -142,7 +142,7 @@ describe('AlfrescoContent', () => {

it('outputs version rendition url as attachment', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding, true);
const contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding, true);

expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/renditions/' + encoding +
Expand All @@ -152,7 +152,7 @@ describe('AlfrescoContent', () => {

it('outputs version rendition url with custom ticket', () => {
const encoding = 'pdf';
let contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding, true, 'custom_ticket');
const contentUrl = contentApi.getVersionRenditionUrl(nodeId, versionId, encoding, true, 'custom_ticket');

expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/renditions/' + encoding +
Expand All @@ -161,23 +161,23 @@ describe('AlfrescoContent', () => {
});

it('outputs version content url', () => {
let contentUrl = contentApi.getVersionContentUrl(nodeId, versionId);
const contentUrl = contentApi.getVersionContentUrl(nodeId, versionId);

expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/content?attachment=false' +
'&alf_ticket=TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
});

it('outputs version content url as attachment', () => {
let contentUrl = contentApi.getVersionContentUrl(nodeId, versionId, true);
const contentUrl = contentApi.getVersionContentUrl(nodeId, versionId, true);

expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/content?attachment=true' +
'&alf_ticket=TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
});

it('outputs version content url with custom ticket', () => {
let contentUrl = contentApi.getVersionContentUrl(nodeId, versionId, true, 'custom_ticket');
const contentUrl = contentApi.getVersionContentUrl(nodeId, versionId, true, 'custom_ticket');
expect(contentUrl).to.be.equal(nodesUrl + nodeId + '/versions/' + versionId +
'/content?attachment=true' +
'&alf_ticket=custom_ticket');
Expand Down
9 changes: 0 additions & 9 deletions test/content-services/versionsApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ describe('Versions', () => {
expect(entries.length).to.be.equal(6);
expect(data.list.entries[0].entry.id).to.be.equal('avatar');
done();
},
(err: any) => {
throw new Error(err);
}
);
});
Expand All @@ -48,9 +45,6 @@ describe('Versions', () => {
versionsApi.createVersionRendition(nodeId, versionId, {id: 'pdf'}).then(
() => {
done();
},
(err: any) => {
throw new Error(err);
}
);
});
Expand All @@ -62,9 +56,6 @@ describe('Versions', () => {
(data) => {
expect(data.entry.id).to.be.equal('pdf');
done();
},
(err: any) => {
throw new Error(err);
}
);
});
Expand Down
14 changes: 7 additions & 7 deletions test/governance-services/authorityClearanceApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Authority Clearance API test', () => {
let authResponseMock: EcmAuthMock;
let authorityClearanceMock: AuthorityClearanceMock;
let authorityClearanceApi: AuthorityClearanceApi;
let nodeSecurityMarkBodyList: Array<NodeSecurityMarkBody> = [
const nodeSecurityMarkBodyList: Array<NodeSecurityMarkBody> = [
{
groupId: 'securityGroupFruits',
op: 'ADD',
Expand All @@ -30,7 +30,7 @@ describe('Authority Clearance API test', () => {
id: 'fruitMarkId1',
}
];
let nodeSecurityMarkBodySingle: Array<NodeSecurityMarkBody> = [
const nodeSecurityMarkBodySingle: Array<NodeSecurityMarkBody> = [
{
groupId: 'securityGroupFruits',
op: 'ADD',
Expand All @@ -51,7 +51,7 @@ describe('Authority Clearance API test', () => {
});

it('get authority clearances for an authority', async () => {
let nodeId = 'testAuthorityId';
const nodeId = 'testAuthorityId';
authorityClearanceMock.get200AuthorityClearanceForAuthority(nodeId);
await authorityClearanceApi.getAuthorityClearanceForAuthority(nodeId, DEFAULT_OPTS).then((response: AuthorityClearanceGroupPaging) => {
expect(response.list.entries[0].entry.id).equal('securityGroupFruits');
Expand All @@ -62,21 +62,21 @@ describe('Authority Clearance API test', () => {
});

it('add single security marks to an authority', async () => {
let nodeId = 'testAuthorityId';
const nodeId = 'testAuthorityId';
authorityClearanceMock.post200AuthorityClearanceWithSingleItem(nodeId);
await authorityClearanceApi.updateAuthorityClearance(nodeId, nodeSecurityMarkBodySingle).then((data: SecurityMarkEntry | SecurityMarkPaging) => {
let response: SecurityMarkEntry = data as SecurityMarkEntry;
const response = data as SecurityMarkEntry;
expect(response.entry.id).equal('fruitMarkId1');
expect(response.entry.name).equal('APPLES');
expect(response.entry.groupId).equal('securityGroupFruits');
});
});

it('add multiple security marks on an authority', async () => {
let nodeId = 'testAuthorityId';
const nodeId = 'testAuthorityId';
authorityClearanceMock.post200AuthorityClearanceWithList(nodeId);
await authorityClearanceApi.updateAuthorityClearance(nodeId, nodeSecurityMarkBodyList).then((data: SecurityMarkEntry | SecurityMarkPaging) => {
let response: SecurityMarkPaging = data as SecurityMarkPaging;
const response: SecurityMarkPaging = data as SecurityMarkPaging;
expect(response.list.entries[0].entry.id).equal('fruitMarkId1');
expect(response.list.entries[0].entry.name).equal('APPLES');
expect(response.list.entries[0].entry.groupId).equal('securityGroupFruits');
Expand Down
8 changes: 4 additions & 4 deletions test/governance-services/nodeSecurityMarksApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Node Security Mark API test', () => {
let authResponseMock: EcmAuthMock;
let nodeSecurityMarksMock: NodeSecurityMarksApiMock;
let nodeSecurityMarksApi: NodeSecurityMarksApi;
let nodeSecurityMarkBody: Array<NodeSecurityMarkBody> = [
const nodeSecurityMarkBody: Array<NodeSecurityMarkBody> = [
{
groupId: 'securityGroupId1',
op: 'ADD',
Expand All @@ -36,7 +36,7 @@ describe('Node Security Mark API test', () => {
});

it('add or remove security marks on a node', async () => {
let nodeId = 'h3bdk2knw2kn';
const nodeId = 'h3bdk2knw2kn';
nodeSecurityMarksMock.post200manageSecurityMarkOnNode(nodeId);
await nodeSecurityMarksApi.manageSecurityMarksOnNode(nodeId, nodeSecurityMarkBody).then((data) => {
expect(data.list.entries[0].entry.groupId).equal('securityGroupId1');
Expand All @@ -46,8 +46,8 @@ describe('Node Security Mark API test', () => {
});

it('get security marks on a node', async () => {
let nodeId = 'h3bdk2knw2kn';
let DEFAULT_INCLUDE = 'inUse';
const nodeId = 'h3bdk2knw2kn';
const DEFAULT_INCLUDE = 'inUse';
nodeSecurityMarksMock.get200SecurityMarkOnNode(nodeId);
await nodeSecurityMarksApi.getSecurityMarksOnNode(nodeId, {DEFAULT_INCLUDE}).then((data) => {
expect(data.list.entries[1].entry.groupId).equal('securityGroupId2');
Expand Down
4 changes: 2 additions & 2 deletions test/governance-services/securityGroupApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Security Group API test', () => {
let authResponseMock: EcmAuthMock;
let securityGroupMock: SecurityGroupApiMock
let securityGroupApi: SecurityGroupsApi;
let securityGroupBody: SecurityGroupBody = {
const securityGroupBody: SecurityGroupBody = {
"groupName": "Alfresco",
"groupType": "HIERARCHICAL"
}
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('Security Group API test', () => {

it('update Security Group', async () => {
securityGroupMock.updateSecurityGroup200Response(securityGroupId);
let updatedSecurityGroupBody: SecurityGroupBody = {
const updatedSecurityGroupBody: SecurityGroupBody = {
"groupName": "Nasa",
}
await securityGroupApi.updateSecurityGroup(securityGroupId,updatedSecurityGroupBody,['inUse'])
Expand Down
8 changes: 4 additions & 4 deletions test/governance-services/securityMarksApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ describe('Security Mark API test', () => {
let securityMarksApi: SecurityMarksApi;
let securityGroupId: string;
let securityMarkId: string;
let securityMarksBodySingle: SecurityMarksBody =[
const securityMarksBodySingle: SecurityMarksBody = [
{
name: 'SecurityMarkTest',
}
];
let securityGroupBody: SecurityGroupBody = {
const securityGroupBody: SecurityGroupBody = {
groupName: 'Alfresco',
groupType: 'HIERARCHICAL',
};
let securityMarksBody: SecurityMarksBody = [
const securityMarksBody: SecurityMarksBody = [
{
name: 'SecurityMark3',
},
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Security Mark API test', () => {
});

it('update Security Mark', async () => {
let updatedSecurityMarkBody: SecurityMarkBody = {
const updatedSecurityMarkBody: SecurityMarkBody = {
name: 'AlfrescoSecurityMark',
};
securityMarkApiMock.put200UpdateSecurityMarkResponse(securityGroupId, securityMarkId);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test-node/login-bpmn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { AlfrescoApi } from '@alfresco/js-api';

let program = require('commander');
const program = require('commander');

async function main() {

Expand All @@ -28,7 +28,7 @@ async function main() {
.option('-u, --username [type]', 'username ')
.parse(process.argv);

let alfrescoApi: AlfrescoApi = new AlfrescoApi();
const alfrescoApi = new AlfrescoApi();

alfrescoApi.setConfig({
provider: 'BPM',
Expand Down
6 changes: 3 additions & 3 deletions test/integration/test-node/login-ecm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { AlfrescoApi, DiscoveryApi } from '@alfresco/js-api';

let program = require('commander');
const program = require('commander');

async function main() {

Expand All @@ -28,7 +28,7 @@ async function main() {
.option('-u, --username [type]', 'username ')
.parse(process.argv);

let alfrescoApi: AlfrescoApi = new AlfrescoApi();
const alfrescoApi = new AlfrescoApi();

alfrescoApi.setConfig({
provider: 'ECM',
Expand All @@ -38,7 +38,7 @@ async function main() {
});

alfrescoApi.login(program.username, program.password).then(() => {
let discovery = new DiscoveryApi(alfrescoApi);
const discovery = new DiscoveryApi(alfrescoApi);
discovery.getRepositoryInformation().then(
(ecmVers) => {
console.log('ecmVers' + JSON.stringify(ecmVers));
Expand Down

0 comments on commit 41e3184

Please sign in to comment.