Skip to content

Commit

Permalink
Replace TSLint with ESLint #2041
Browse files Browse the repository at this point in the history
Automatically fixed minor linter errors.
  • Loading branch information
edloidas committed Jul 22, 2021
1 parent c387bd9 commit ec8e67f
Show file tree
Hide file tree
Showing 41 changed files with 68 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/main/resources/assets/admin/common/js/BrowserHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class BrowserHelper {

static isSafari(): boolean {
return navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
navigator.userAgent && !navigator.userAgent.match('CriOS');
navigator.userAgent && !(/CriOS/.exec(navigator.userAgent));
}

static isAndroid(): boolean {
Expand All @@ -76,7 +76,7 @@ export class BrowserHelper {
}

private static init() {
let M = navigator.userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
let M = (/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i.exec(navigator.userAgent)) || [];
BrowserHelper.BROWSER_NAME = (<any>BrowserName)[M[1].toLocaleUpperCase()];
BrowserHelper.BROWSER_VERSION = M[2];

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/admin/common/js/ClassHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ClassHelper {

static findPath(obj: Object, constructor: Function, nestLevel: number = 1): string {
let value;
let path;
let path: string;

// don't search in current package if nest level is to big
if (nestLevel > ClassHelper.MAX_NEST_LEVEL) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/admin/common/js/ObjectHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ObjectHelper {
* @returns {Object}
*/
static create(constructor: Function, ..._args: any[]) {
// eslint-disable-next-line prefer-spread, prefer-rest-params
let factory = constructor.bind.apply(constructor, arguments);
return new factory();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import {BucketWrapperJson} from './BucketWrapperJson';
import {Bucket} from './Bucket';
import {DateRangeBucketJson} from './DateRangeBucketJson';
import {BucketJson} from './BucketJson';
import {DateRangeBucket} from './DateRangeBucket';

export class BucketFactory {

public static createFromJson(json: BucketWrapperJson): Bucket {

if (json.DateRangeBucket) {
return DateRangeBucket.fromDateRangeJson(<DateRangeBucketJson>json.DateRangeBucket);
return DateRangeBucket.fromDateRangeJson(json.DateRangeBucket);
} else if (json.BucketJson) {
return Bucket.fromJson(<BucketJson>json.BucketJson);
return Bucket.fromJson(json.BucketJson);
} else {
throw new Error('Bucket-type not recognized: ' + json);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BrowseFilterPanel<T>
});

this.clearFilter = new ClearFilterButton();
this.clearFilter.onClicked(() => this.reset());
this.clearFilter.onClicked(() => void this.reset());

this.hitsCounterEl = new SpanEl('hits-counter');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {AutosizeTextInput} from '../../ui/text/AutosizeTextInput';
import {ValueChangedEvent} from '../../ValueChangedEvent';
import {StringHelper} from '../../util/StringHelper';
import {NamePrettyfier} from '../../NamePrettyfier';
import {DisplayNameGenerator} from './DisplayNameGenerator';
import {WizardHeader} from './WizardHeader';
import {Name} from '../../Name';
import {DivEl} from '../../dom/DivEl';
Expand Down Expand Up @@ -232,7 +231,7 @@ export class WizardHeaderWithDisplayNameAndName
/* TODO: DEPRECATE METHODS BELOW IN 4.0 */

disableNameInput() {
console.warn(`WizardHeaderWithDisplayNameAndName.disableNameInput() is deprecated and will be removed in lib-admin-ui 4.0.0`);
console.warn('WizardHeaderWithDisplayNameAndName.disableNameInput() is deprecated and will be removed in lib-admin-ui 4.0.0');
this.toggleNameInput(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ export class ApplicationKey
}

isSystemReserved(): boolean {
for (let key in ApplicationKey.SYSTEM_RESERVED_APPLICATION_KEYS) {
if (ApplicationKey.SYSTEM_RESERVED_APPLICATION_KEYS[key].equals(this)) {
return true;
}
}
return false;
return ApplicationKey.SYSTEM_RESERVED_APPLICATION_KEYS.some(key => key.equals(this));
}

toString(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ export class ApplicationLoader
}

load(): Q.Promise<Application[]> {
let me = this;
me.notifyLoadingData();
this.notifyLoadingData();

return me.sendRequest()
return this.sendRequest()
.then((applications: Application[]) => {
if (me.filterObject) {
applications = applications.filter(me.filterResults, me);
if (this.filterObject) {
applications = applications.filter(this.filterResults, this);
}
me.notifyLoadedData(applications);
this.notifyLoadedData(applications);

return applications;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ export class PropertyArray

private checkType(type: ValueType) {
if (!this.type.equals(type)) {
throw new Error(`This PropertyArray expects only properties with value of type '${this.type}', got: ${type}`);
const msg = `This PropertyArray expects only properties with value of type '${this.type.toString()}', got: ${type.toString()}`;
throw new Error(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class PropertyTree
}

/**
* @returns {PropertySet} Returns the root [[PropertySet]] of this tree.
* @returns {PropertySet} Returns the root [[PropertySet]] of this tree.
*/
public getRoot(): PropertySet {
return this.root;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/admin/common/js/dom/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class Element {

static fromSelector(s: string, loadExistingChildren: boolean = true): Element[] {
return $(s).map((_index, elem) => {
let htmlEl = <HTMLElement>elem;
let htmlEl = elem;
let parentEl;
if (htmlEl && htmlEl.parentElement) {
parentEl = Element.fromHtmlElement(htmlEl.parentElement);
Expand Down Expand Up @@ -1302,6 +1302,7 @@ export class Element {
}

private getFirstNonEmptyAncestor(): Element {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let el: Element = this;

while (!!el && el.isEmptyElement()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ElementHelper {

getParent(): ElementHelper {
let parent = this.el.parentElement;
return parent ? new ElementHelper(<HTMLElement>parent) : null;
return parent ? new ElementHelper(parent) : null;
}

setDisabled(value: boolean): ElementHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ImgHelper
}

static create(): ElementHelper {
return new ImgHelper(<HTMLImageElement>document.createElement('img'));
return new ImgHelper(document.createElement('img'));
}

getHTMLElement(): HTMLImageElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class EventBus {

static polyfillCustomEvent(contextWindow: Window) {
const customEventFn = (event: string, params: any) => {
params = params || { bubbles: false, cancelable: false, detail: undefined };
params = params || {bubbles: false, cancelable: false, detail: undefined};
const evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export class FormItemOccurrences<V extends FormItemOccurrenceView> {
const promises: Q.Promise<any>[] = [];
const totalItemsNeeded: number = this.getTotalOccurrencesNeeded();

const extraItemsToRemove: V[] = this.occurrenceViews.filter((item: V, index: number) => index >= totalItemsNeeded );
const extraItemsToRemove: V[] = this.occurrenceViews.filter((item: V, index: number) => index >= totalItemsNeeded);
extraItemsToRemove.forEach((item: V) => this.removeOccurrenceView(item));

this.occurrenceViews.forEach((view: V) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class ApplicationConfiguratorDialog

private findComboboxes(element: Element): ComboBox<any>[] {
if (element instanceof ComboBox) {
return [<ComboBox<any>>element];
return [element];
}

return ArrayHelper.flatten(element.getChildren().map(child => this.findComboboxes(child)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export abstract class BaseInputTypeNotManagingAdd

handleDnDStart(ui: JQueryUI.SortableUIParams): void {

let draggedElement = Element.fromHtmlElement(<HTMLElement>ui.item[0]);
let draggedElement = Element.fromHtmlElement(ui.item[0]);
this.draggingIndex = draggedElement.getSiblingIndex();

ui.placeholder.text('Drop form item set here');
Expand All @@ -67,7 +67,7 @@ export abstract class BaseInputTypeNotManagingAdd
handleDnDUpdate(ui: JQueryUI.SortableUIParams) {

if (this.draggingIndex >= 0) {
let draggedElement = Element.fromHtmlElement(<HTMLElement>ui.item[0]);
let draggedElement = Element.fromHtmlElement(ui.item[0]);
let draggedToIndex = draggedElement.getSiblingIndex();
this.inputOccurrences.moveOccurrence(this.draggingIndex, draggedToIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
validate(silent: boolean = true, viewToSkipValidation: FormItemOccurrenceView = null): ValidationRecording {

if (!this.formItemOccurrences) {
throw new Error(`Can't validate before layout is done`);
throw new Error('Can\'t validate before layout is done');
}

const validationRecordingPath = this.resolveValidationRecordingPath();
Expand Down Expand Up @@ -429,7 +429,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
}

protected handleDnDStart(ui: JQueryUI.SortableUIParams): void {
const draggedElement = Element.fromHtmlElement(<HTMLElement>ui.item[0]);
const draggedElement = Element.fromHtmlElement(ui.item[0]);
assert(draggedElement.hasClass(this.classPrefix + '-occurrence-view'));
this.draggingIndex = draggedElement.getSiblingIndex();

Expand All @@ -439,7 +439,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>

protected handleDnDUpdate(ui: JQueryUI.SortableUIParams) {
if (this.draggingIndex >= 0) {
const draggedElement = Element.fromHtmlElement(<HTMLElement>ui.item[0]);
const draggedElement = Element.fromHtmlElement(ui.item[0]);
assert(draggedElement.hasClass(this.classPrefix + '-occurrence-view'));
const draggedToIndex = draggedElement.getSiblingIndex();

Expand All @@ -458,7 +458,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
return; // everything is already have been handled in update
}

const draggedElement = Element.fromHtmlElement(<HTMLElement>ui.item[0]);
const draggedElement = Element.fromHtmlElement(ui.item[0]);
assert(draggedElement.hasClass(this.classPrefix + '-occurrence-view'));
const draggedToIndex = draggedElement.getSiblingIndex();
this.formItemOccurrences.refreshOccurence(draggedToIndex);
Expand Down Expand Up @@ -537,7 +537,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
const views = this.formItemOccurrences.getOccurrenceViews();
const occurrenceCount = views.length;
const anyExpandable = occurrenceCount > 0 && views.some(view => view.isExpandable());
const isCollapsed = (<FormSetOccurrences<V>>this.formItemOccurrences).isCollapsed();
const isCollapsed = (this.formItemOccurrences).isCollapsed();

const caption = occurrenceCount > 1 ?
(isCollapsed ? i18n('button.expandall') : i18n('button.collapseall')) :
Expand All @@ -549,7 +549,7 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
private makeCollapseButton(): AEl {
const collapseButton = new AEl('collapse-button');
collapseButton.onClicked((event: MouseEvent) => {
const isCollapsed = (<FormSetOccurrences<V>>this.formItemOccurrences).isCollapsed();
const isCollapsed = (this.formItemOccurrences).isCollapsed();
this.toggleOccurrencesVisibility(isCollapsed);
return false;
});
Expand Down Expand Up @@ -585,9 +585,9 @@ export abstract class FormSetView<V extends FormSetOccurrenceView>
item.setContainerVisible(true);
const processFormItemView = (formItemView: FormItemView) => {
if (formItemView instanceof FormSetView) {
(<FormSetView<any>>formItemView).expandRecursively();
(formItemView).expandRecursively();
} else if (formItemView instanceof FormOptionSetOptionView) {
(<FormOptionSetOptionView>formItemView).getFormItemViews().forEach(processFormItemView);
(formItemView).getFormItemViews().forEach(processFormItemView);
}
};
item.getFormItemViews().forEach(processFormItemView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export abstract class FormOptionSetOccurrenceView
super.subscribeOnItemEvents();

this.formItemViews.forEach((formItemView: FormOptionSetOptionView) => {
formItemView.onSelectionChanged(() => this.handleSelectionChanged(<FormOptionSetOptionView>formItemView));
formItemView.onSelectionChanged(() => this.handleSelectionChanged(formItemView));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class FulltextSearchExpression {
}

static escapeString(value: string): string {
return value.replace(/((\&\&)|(\|\|)|[+-=><!(){}\[\]^"~*?:\\/])/g, `\\$1`);
return value.replace(/((\&\&)|(\|\|)|[+-=><!(){}\[\]^"~*?:\\/])/g, '\\$1');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {Expression} from './Expression';

export interface ConstraintExpr
extends Expression {
}
export type ConstraintExpr = Expression;
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ValueExpr
}

private quoteString(value: string): string {
if (value.indexOf(`'`) > -1) {
if (value.indexOf('\'') > -1) {
return `"${value}"`;
} else {
return `'${value}'`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ContentTypeName
static IMAGE: ContentTypeName = ContentTypeName.from(ApplicationKey.MEDIA, 'image');

constructor(name: string) {
assertNotNull(name, `Content type name can't be null`);
assertNotNull(name, 'Content type name can\'t be null');
let parts = name.split(ApplicationBasedName.SEPARATOR);
super(ApplicationKey.fromString(parts[0]), parts[1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class MixinName
extends ApplicationBasedName {

constructor(name: string) {
assertNotNull(name, `Mixin name can't be null`);
assertNotNull(name, 'Mixin name can\'t be null');
let parts = name.split(ApplicationBasedName.SEPARATOR);
super(ApplicationKey.fromString(parts[0]), parts[1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class IsAuthenticatedRequest
}

sendAndParse(): Q.Promise<LoginResult> {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
IsAuthenticatedRequest.cachedRequestPromise = IsAuthenticatedRequest.cachedRequestPromise || super.sendAndParse();
return IsAuthenticatedRequest.cachedRequestPromise;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ProgressBarManager {
this.managingElement = config.managingElement;
this.processHandler = config.processHandler;
this.processingLabel = config.processingLabel;
this.unlockControlsHandler = config.unlockControlsHandler || (() => {/*empty*/
this.unlockControlsHandler = config.unlockControlsHandler || (() => { /*empty*/
});
this.createProcessingMessage = config.createProcessingMessage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class FormItemBuilder {

constructor(input: FormItemEl) {
if (!input) {
throw new Error(`Input can't be null.`);
throw new Error('Input can\'t be null.');
}
this.input = input;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/admin/common/js/ui/grid/Grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ export class Grid<T extends Slick.SlickData>

subscribeBeforeMoveRows(callback: (e: any, args: any) => void) {
if (this.rowManagerPlugin) {
(<Slick.Event<Slick.OnMoveRowsEventData>>this.rowManagerPlugin.onBeforeMoveRows).subscribe(callback);
(this.rowManagerPlugin.onBeforeMoveRows).subscribe(callback);
}
}

subscribeMoveRows(callback: (e: any, args: any) => void) {
if (this.rowManagerPlugin) {
(<Slick.Event<Slick.OnMoveRowsEventData>>this.rowManagerPlugin.onMoveRows).subscribe(callback);
(this.rowManagerPlugin.onMoveRows).subscribe(callback);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export class PrincipalSelectedOptionsView
let key = PrincipalKey.fromString(id);

return Option.create<Principal>()
.setValue(id)
.setDisplayValue(<Principal>Principal.create().setKey(key).setDisplayName(key.getId()).build())
.setValue(id)
.setDisplayValue(Principal.create().setKey(key).setDisplayName(key.getId()).build())
.setEmpty(true)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class BaseRichComboBox<OPTION_DATA_TYPE, LOADER_DATA_TYPE>
this.comboBox.setLoader(loader);

this.comboBox.onOptionFilterInputValueChanged((event: OptionFilterInputValueChangedEvent) => {
return this.reload(event.getNewValue());
this.reload(event.getNewValue());
});

this.loader.onLoadingData((event: LoadingDataEvent) => {
Expand Down
Loading

0 comments on commit ec8e67f

Please sign in to comment.