[AAE-7101] - Introduced Eslint to ACA and added some fix to avoid errors (#2424)

* Conversion to ESlint

* Fixed ESLINT for ACA

* [AAE-6638] - typo in eslint file

* [AAE-6638] - attempt to fix problem on linting

* Check caching to improve lint speed

* Improved eslint for content-app

* Added new cache

* Remove cache file

* Removed eslintcache

* Attempt to make eslint run on travis

* Slow ng lint on travis

* Fixed eslint error
This commit is contained in:
Vito
2022-02-09 08:40:04 +00:00
committed by GitHub
parent fde64be498
commit 23262d0949
72 changed files with 3979 additions and 702 deletions

117
e2e/.eslintrc.json Normal file
View File

@@ -0,0 +1,117 @@
{
"extends": "../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-react",
"eslint-plugin-rxjs",
"eslint-plugin-unicorn"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": [
"app",
"aca",
"adf"
],
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "aca",
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/type-annotation-spacing": "off",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"eol-last": "off",
"id-blacklist": "off",
"id-match": "off",
"linebreak-style": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-duplicate-imports": "error",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-return-await": "error",
"no-underscore-dangle": "off",
"quote-props": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -132,6 +132,4 @@ export async function checkViewerActions(item: string, expectedToolbarPrimary: s
const toRemove = ['Close', 'Previous File', 'Next File', 'View details'];
function removeClosePreviousNextOldInfo(actions: string[]): string[] {
return actions.filter((elem) => !toRemove.includes(elem));
}
const removeClosePreviousNextOldInfo = (actions: string[]): string[] => actions.filter((elem) => !toRemove.includes(elem));

View File

@@ -477,7 +477,7 @@ describe('Copy content', () => {
}));
});
async function copyFile(fileName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -497,7 +497,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName} not present in ${destination} folder`);
}
async function copyFolderWithContent(folderName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyFolderWithContent(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -521,7 +521,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(fileInFolder)).toBe(true, `${fileInFolder} is not present in ${folderName} folder in ${destination}`);
}
async function copyMultipleItems(items: string[], location: string = '', destination: string, doBefore?: Function) {
async function copyMultipleItems(items: string[], location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -543,7 +543,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(items[1])).toBe(true, `${items[1]} not present in ${destination} folder`);
}
async function copyFileWithNameThatAlreadyExists(fileName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyFileWithNameThatAlreadyExists(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -563,7 +563,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName}.txt not present in ${destination} folder`);
}
async function copyFolderWithNameThatAlreadyExists(folderName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyFolderWithNameThatAlreadyExists(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -586,7 +586,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(file3InFolder)).toBe(true, `${file3InFolder} not present in ${destination} folder in ${folderName}`);
}
async function copyItemsIntoLibrary(items: string[], location: string = '', destination: string, doBefore?: Function) {
async function copyItemsIntoLibrary(items: string[], location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -616,7 +616,7 @@ describe('Copy content', () => {
}
}
async function copyLockedFile(fileName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyLockedFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -639,7 +639,7 @@ describe('Copy content', () => {
expect(await apis.user.nodes.isFileLockedByName(fileName, destinationId)).toBe(false, `${fileName} is locked in ${destination}`);
}
async function copyFolderThatContainsLockedFile(folderName: string, location: string = '', destination: string, doBefore?: Function) {
async function copyFolderThatContainsLockedFile(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -671,7 +671,7 @@ describe('Copy content', () => {
).toBe(false, `${fileLockedInFolder} is locked in ${destination}`);
}
async function undoCopyFile(fileName: string, location: string = '', destination: string, doBefore?: Function) {
async function undoCopyFile(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -694,7 +694,7 @@ describe('Copy content', () => {
expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
}
async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore?: Function) {
async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -717,7 +717,7 @@ describe('Copy content', () => {
expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
}
async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore?: Function) {
async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}
@@ -744,7 +744,7 @@ describe('Copy content', () => {
expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
}
async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore?: Function) {
async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore?: () => void) {
if (doBefore) {
await doBefore();
}

View File

@@ -124,7 +124,8 @@ describe('Move content', () => {
const existingFile = `existing-${Utils.random()}`;
const existingFolder = `existing-${Utils.random()}`;
let existingId1, existingId2;
let existingId1;
let existingId2;
const file2InFolder = `file2InFolder-${Utils.random()}.txt`;
const file3InFolder = `file3InFolder-${Utils.random()}.txt`;
@@ -551,7 +552,8 @@ describe('Move content', () => {
let existingFileId;
const existingFolder = `existing-${Utils.random()}`;
let existingId1, existingId2;
let existingId1;
let existingId2;
const file2InFolder = `file2InFolder-${Utils.random()}.txt`;
const file3InFolder = `file3InFolder-${Utils.random()}.txt`;

View File

@@ -32,25 +32,25 @@ describe('Extensions - Info Drawer', () => {
const file = `file-${Utils.random()}.txt`;
let fileId: string;
const properties_tab = {
const PROPERTIES_TAB = {
order: 1,
title: 'MY PROPERTIES'
};
const custom_tab = {
const CUSTOM_TAB = {
order: 2,
icon: 'mood',
title: 'MY CUSTOM TITLE',
component: 'app.toolbar.toggleFavorite'
};
const no_title_tab = {
const NO_TITLE_TAB = {
order: 3,
icon: 'check_circle',
title: ''
};
const comments_tab = {
const COMMENTS_TAB = {
title: 'COMMENTS'
};
@@ -94,9 +94,9 @@ describe('Extensions - Info Drawer', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
const val = await infoDrawer.getTabTitle(custom_tab.order);
expect(await infoDrawer.isTabPresent(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not present`);
expect(val.trim()).toEqual(`${custom_tab.icon}\n${custom_tab.title}`.trim());
const val = await infoDrawer.getTabTitle(CUSTOM_TAB.order);
expect(await infoDrawer.isTabPresent(CUSTOM_TAB.title)).toBe(true, `${CUSTOM_TAB.title} tab is not present`);
expect(val.trim()).toEqual(`${CUSTOM_TAB.icon}\n${CUSTOM_TAB.title}`.trim());
});
it('[C284647] Remove existing tab', async () => {
@@ -104,7 +104,7 @@ describe('Extensions - Info Drawer', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.isTabPresent(comments_tab.title)).toBe(false, `${comments_tab.title} tab should not be present!`);
expect(await infoDrawer.isTabPresent(COMMENTS_TAB.title)).toBe(false, `${COMMENTS_TAB.title} tab should not be present!`);
});
it('[C284648] Change tab title', async () => {
@@ -112,8 +112,8 @@ describe('Extensions - Info Drawer', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.isTabPresent(properties_tab.title)).toBe(true, `${properties_tab.title} tab is not present`);
expect(await infoDrawer.getTabTitle(properties_tab.order)).toEqual(properties_tab.title);
expect(await infoDrawer.isTabPresent(PROPERTIES_TAB.title)).toBe(true, `${PROPERTIES_TAB.title} tab is not present`);
expect(await infoDrawer.getTabTitle(PROPERTIES_TAB.order)).toEqual(PROPERTIES_TAB.title);
});
it('[C284649] Tab with icon and no title', async () => {
@@ -121,8 +121,8 @@ describe('Extensions - Info Drawer', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.isTabPresent(no_title_tab.title)).toBe(true, `${no_title_tab.title} tab is not present`);
expect((await infoDrawer.getTabTitle(no_title_tab.order)).trim()).toEqual(`${no_title_tab.icon}`.trim());
expect(await infoDrawer.isTabPresent(NO_TITLE_TAB.title)).toBe(true, `${NO_TITLE_TAB.title} tab is not present`);
expect((await infoDrawer.getTabTitle(NO_TITLE_TAB.order)).trim()).toEqual(`${NO_TITLE_TAB.icon}`.trim());
});
it('[C284651] Insert new component in tab', async () => {
@@ -130,9 +130,9 @@ describe('Extensions - Info Drawer', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
expect(await infoDrawer.isTabDisplayed(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not displayed`);
await infoDrawer.clickTab(custom_tab.title);
expect(await infoDrawer.getComponentIdOfTab()).toEqual(custom_tab.component);
expect(await infoDrawer.isTabDisplayed(CUSTOM_TAB.title)).toBe(true, `${CUSTOM_TAB.title} tab is not displayed`);
await infoDrawer.clickTab(CUSTOM_TAB.title);
expect(await infoDrawer.getComponentIdOfTab()).toEqual(CUSTOM_TAB.component);
});
});

View File

@@ -42,7 +42,7 @@ describe('Extensions - Metadata presets', () => {
let fileId: string;
const properties_tab = {
const PROPERTIES_TAB = {
title: 'Properties',
component: 'app.components.tabs.metadata'
};
@@ -91,7 +91,7 @@ describe('Extensions - Metadata presets', () => {
await BrowserActions.click(page.toolbar.viewDetailsButton);
await infoDrawer.waitForInfoDrawerToOpen();
await infoDrawer.clickTab(properties_tab.title);
await infoDrawer.clickTab(PROPERTIES_TAB.title);
await BrowserActions.click(metadataCard.expandButton);
await metadataCard.waitForFirstExpansionPanel();

View File

@@ -30,13 +30,13 @@ describe('Extensions - Viewer', () => {
const username = `user-${Utils.random()}`;
const pdfFile = {
file_name: FILES.pdfFile,
fileName: FILES.pdfFile,
component: 'app.components.tabs.metadata'
};
let pdfFileId: string;
const docxFile = {
file_name: FILES.docxFile,
fileName: FILES.docxFile,
component: 'app.components.tabs.comments'
};
let docxFileId: string;
@@ -76,8 +76,8 @@ describe('Extensions - Viewer', () => {
beforeAll(async (done) => {
await adminApiActions.createUser({ username });
pdfFileId = (await apis.user.upload.uploadFile(pdfFile.file_name)).entry.id;
docxFileId = (await apis.user.upload.uploadFile(docxFile.file_name)).entry.id;
pdfFileId = (await apis.user.upload.uploadFile(pdfFile.fileName)).entry.id;
docxFileId = (await apis.user.upload.uploadFile(docxFile.fileName)).entry.id;
await loginPage.load();
await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.VIEWER);
@@ -102,13 +102,13 @@ describe('Extensions - Viewer', () => {
describe('content', () => {
it('[C284659] Insert new component in a content viewer', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
expect(await viewer.getComponentIdOfView()).toEqual(pdfFile.component);
await BrowserActions.click(viewer.closeButton);
await page.dataTable.doubleClickOnRowByName(docxFile.file_name);
await page.dataTable.doubleClickOnRowByName(docxFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
expect(await viewer.getComponentIdOfView()).toEqual(docxFile.component);
@@ -117,7 +117,7 @@ describe('Extensions - Viewer', () => {
describe('toolbar actions', () => {
it('[C286416] Add a new action in the toolbar', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await toolbar.isButtonPresent(customAction.title)).toBe(true, 'Custom action is not present');
@@ -126,14 +126,14 @@ describe('Extensions - Viewer', () => {
});
it('[C286417] Modify title of action from toolbar', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await BrowserActions.getAttribute(toolbar.getButtonById(downloadButton.id), 'title')).toEqual(downloadButton.title);
});
it('[C286419] Remove action from toolbar', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await toolbar.isPrintPresent()).toBe(false, 'Print button is still displayed');
@@ -142,7 +142,7 @@ describe('Extensions - Viewer', () => {
describe('toolbar More actions menu', () => {
it('[C286420] Add a new action', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
await toolbar.openMoreMenu();
@@ -152,7 +152,7 @@ describe('Extensions - Viewer', () => {
});
it('[C286421] Modify title of action from More actions menu', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
await toolbar.openMoreMenu();
@@ -160,7 +160,7 @@ describe('Extensions - Viewer', () => {
});
it('[C286423] Remove action from More actions menu', async () => {
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
await page.dataTable.doubleClickOnRowByName(pdfFile.fileName);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
await toolbar.openMoreMenu();