[AAE-7100] migrate ADF projects to eslint (#7483)

* migrate content services to eslint

* migrate insights to eslint

* migrate extensions to eslint

* migrate testing lib to eslint

* migrate CLI to eslint

* migrate process-services to eslint

* migrate process-services-cloud to eslint

* remove cli analytics [ci:force]
This commit is contained in:
Denys Vuika
2022-02-03 11:01:54 +00:00
committed by GitHub
parent b8bb234410
commit 8dc736e8f0
233 changed files with 1496 additions and 725 deletions

View File

@@ -0,0 +1,101 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"lib/process-services/tsconfig.lib.json",
"lib/process-services/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-unicorn",
"eslint-plugin-rxjs"
],
"rules": {
"jsdoc/newline-after-description": "warn",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": "warn",
"no-shadow": "warn",
"quote-props": "warn",
"object-shorthand": "warn",
"prefer-const": "warn",
"arrow-body-style": "warn",
"@angular-eslint/no-output-native": "warn",
"space-before-function-paren": "warn",
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "adf",
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "adf",
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@angular-eslint/no-input-prefix": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-var-requires": "error",
"brace-style": [
"error",
"1tbs"
],
"comma-dangle": "error",
"default-case": "error",
"import/order": "off",
"max-len": [
"error",
{
"code": 240
}
],
"no-bitwise": "off",
"no-duplicate-imports": "error",
"no-multiple-empty-lines": "error",
"no-redeclare": "error",
"no-return-await": "error",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -29,5 +29,5 @@ export interface AttachFileWidgetDialogComponentData {
showFilesInResult?: boolean;
loginOnly?: boolean;
accountIdentifier?: string;
registerExternalHost?: Function;
registerExternalHost?: (...args) => void;
}

View File

@@ -27,7 +27,7 @@ import { switchMap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
// tslint:disable-next-line: directive-class-suffix
// eslint-disable-next-line @angular-eslint/directive-class-suffix
export class AttachFileWidgetDialogService {
private externalApis: { [key: string]: AlfrescoApiService } = {};

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
/* tslint:disable:component-selector */
/* eslint-disable @angular-eslint/component-selector */
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
/* tslint:disable:component-selector*/
/* eslint-disable @angular-eslint/component-selector */
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import {

View File

@@ -42,6 +42,7 @@ describe('FormComponent', () => {
selector: 'adf-custom-widget',
template: '<div></div>'
})
// eslint-disable-next-line @angular-eslint/component-class-suffix
class CustomWidget {
typeId = 'CustomWidget';
}

View File

@@ -60,8 +60,12 @@ describe('StartFormComponent', () => {
processDefinitionName: 'my:process'
}));
spyOn(translate, 'instant').and.callFake((key) => { return key; });
spyOn(translate, 'get').and.callFake((key) => { return of(key); });
spyOn(translate, 'instant').and.callFake((key) => {
return key;
});
spyOn(translate, 'get').and.callFake((key) => {
return of(key);
});
});
afterEach(() => {

View File

@@ -59,7 +59,7 @@ export class PeopleSelectorComponent {
this.defaultPlaceholder = this.translationService.instant(DEFAULT_ASSIGNEE_PLACEHOLDER);
}
searchUser(searchWord: string): Observable<{} | UserProcessModel[]> {
searchUser(searchWord: string): Observable<any | UserProcessModel[]> {
return this.peopleProcessService.getWorkflowUsers(undefined, searchWord)
.pipe(
catchError(this.onSearchUserError.bind(this))

View File

@@ -20,6 +20,6 @@ import { Directive } from '@angular/core';
/**
* Directive selectors without adf- prefix will be deprecated on 3.0.0
*/
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
@Directive({ selector: 'adf-people-search-action-label, people-search-action-label' })
export class PeopleSearchActionLabelDirective { }

View File

@@ -20,6 +20,6 @@ import { Directive } from '@angular/core';
/**
* Directive selectors without adf- prefix will be deprecated on 3.0.0
*/
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
@Directive({ selector: '[adf-people-search-title]' })
export class PeopleSearchTitleDirective { }

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
/* tslint:disable:no-input-rename */
/* eslint-disable @angular-eslint/no-input-rename */
import { DownloadService } from '@alfresco/adf-core';
import { Directive, EventEmitter, Input, OnChanges, Output } from '@angular/core';
@@ -25,7 +25,7 @@ const JSON_FORMAT: string = 'json';
const PDF_FORMAT: string = 'pdf';
@Directive({
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'button[adf-process-audit]',
host: {
'role': 'button',

View File

@@ -94,8 +94,8 @@ describe('ProcessService', () => {
});
describe('start process instance', () => {
const processDefId = '1234', processName = 'My process instance';
const processDefId = '1234';
const processName = 'My process instance';
let startNewProcessInstance: jasmine.Spy;
beforeEach(() => {

View File

@@ -27,7 +27,7 @@ import { TaskDetailsComponent } from './task-details.component';
* Directive selectors without adf- prefix will be deprecated on 3.0.0
*/
@Directive({
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'adf-no-task-details-template, no-task-details-template'
})
export class NoTaskDetailsTemplateDirective implements AfterContentInit {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
/* tslint:disable:no-input-rename */
/* eslint-disable @angular-eslint/no-input-rename */
import { ContentService } from '@alfresco/adf-core';
import { Directive, EventEmitter, Input, OnChanges, Output } from '@angular/core';
@@ -25,7 +25,7 @@ const JSON_FORMAT: string = 'json';
const PDF_FORMAT: string = 'pdf';
@Directive({
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'button[adf-task-audit]',
host: {
'role': 'button',

View File

@@ -39,19 +39,19 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/** Emitted when a filter is being clicked from the UI. */
@Output()
filterClicked: EventEmitter<FilterRepresentationModel> = new EventEmitter<FilterRepresentationModel>();
filterClicked = new EventEmitter<FilterRepresentationModel>();
/** Emitted when a filter is being selected based on the filterParam input. */
@Output()
filterSelected: EventEmitter<FilterRepresentationModel> = new EventEmitter<FilterRepresentationModel>();
filterSelected = new EventEmitter<FilterRepresentationModel>();
/** Emitted when the list is loaded. */
@Output()
success: EventEmitter<any> = new EventEmitter<any>();
success = new EventEmitter<any>();
/** Emitted when an error occurs during loading. */
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
error = new EventEmitter<any>();
/** Display filters available to the current user for the application with the specified ID. */
@Input()
@@ -97,15 +97,21 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Return the task list filtered by appId or by appName
*
* @param appId
* @param appName
*/
getFilters(appId?: number, appName?: string) {
appName ? this.getFiltersByAppName(appName) : this.getFiltersByAppId(appId);
if (appName) {
this.getFiltersByAppName(appName);
} else {
this.getFiltersByAppId(appId);
}
}
/**
* Return the filter list filtered by appId
*
* @param appId - optional
*/
getFiltersByAppId(appId?: number) {
@@ -128,6 +134,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Return the filter list filtered by appName
*
* @param appName
*/
getFiltersByAppName(appName: string) {
@@ -142,6 +149,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Create default filters by appId
*
* @param appId
*/
createFiltersByAppId(appId?: number) {
@@ -160,6 +168,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Pass the selected filter as next
*
* @param newFilter
*/
public selectFilter(newFilter: FilterParamsModel) {
@@ -188,6 +197,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Select filter with task
*
* @param taskId
*/
public selectFilterWithTask(taskId: string) {
@@ -209,7 +219,6 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
/**
* Select as default task filter the first in the list
* @param filteredFilterList
*/
public selectDefaultTaskFilter() {
if (!this.isFilterListEmpty()) {

View File

@@ -20,27 +20,28 @@ import {
Input,
Output,
EventEmitter,
HostListener
HostListener,
OnInit
} from '@angular/core';
import { TaskListService } from '../../services/tasklist.service';
import { LogService } from '@alfresco/adf-core';
@Directive({
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
selector: '[adf-claim-task]'
})
export class ClaimTaskDirective {
export class ClaimTaskDirective implements OnInit {
/** (Required) The id of the task. */
@Input()
taskId: string;
/** Emitted when the task is claimed. */
@Output()
success: EventEmitter<any> = new EventEmitter<any>();
success = new EventEmitter<any>();
/** Emitted when the task cannot be claimed. */
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
error = new EventEmitter<any>();
invalidParams: string[] = [];
@@ -69,16 +70,16 @@ export class ClaimTaskDirective {
}
@HostListener('click')
async onClick() {
onClick() {
try {
await this.claimTask();
this.claimTask();
} catch (error) {
this.error.emit(error);
}
}
private async claimTask() {
await this.taskListService.claimTask(this.taskId).subscribe(
private claimTask() {
this.taskListService.claimTask(this.taskId).subscribe(
() => {
this.logService.info('Task claimed');
this.success.emit(this.taskId);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges, ViewEncapsulation, OnChanges } from '@angular/core';
import {
FormModel,
ContentLinkModel,
@@ -36,7 +36,7 @@ import { Observable } from 'rxjs';
styleUrls: ['./task-form.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class TaskFormComponent implements OnInit {
export class TaskFormComponent implements OnInit, OnChanges {
/** (**required**) The id of the task whose details we are asking for. */
@Input()

View File

@@ -20,16 +20,17 @@ import {
HostListener,
Input,
Output,
EventEmitter
EventEmitter,
OnInit
} from '@angular/core';
import { TaskListService } from '../../services/tasklist.service';
import { LogService } from '@alfresco/adf-core';
@Directive({
// tslint:disable-next-line: directive-selector
// eslint-disable-next-line @angular-eslint/directive-selector
selector: '[adf-unclaim-task]'
})
export class UnclaimTaskDirective {
export class UnclaimTaskDirective implements OnInit {
/** (Required) The id of the task. */
@Input()
taskId: string;
@@ -68,16 +69,16 @@ export class UnclaimTaskDirective {
}
@HostListener('click')
async onClick() {
onClick() {
try {
await this.unclaimTask();
this.unclaimTask();
} catch (error) {
this.error.emit(error);
}
}
private async unclaimTask() {
await this.taskListService.unclaimTask(this.taskId).subscribe(
private unclaimTask() {
this.taskListService.unclaimTask(this.taskId).subscribe(
() => {
this.logService.info('Task unclaimed');
this.success.emit(this.taskId);

View File

@@ -1,17 +0,0 @@
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"adf",
"camelCase"
],
"component-selector": [
true,
"element",
"adf",
"kebab-case"
]
}
}