Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix linting errors

Benjamin Bädorf51dbe6d6c49e
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
index 72f41374c4c..744637820d2 100644
--- a/frontend/.eslintrc.js
+++ b/frontend/.eslintrc.js
@@ -62,6 +62,9 @@ module.exports = {
},
],
+ // Sometimes we need to shush the TypeScript compiler
+ "no-unused-vars": ["error", { "varsIgnorePattern": "^_" }],
+
// Who cares about line length
"max-len": "off",
diff --git a/frontend/src/app/shared/components/project-include/project-list.component.ts b/frontend/src/app/shared/components/project-include/project-list.component.ts
index 009383fdcff..7ac3155370b 100644
--- a/frontend/src/app/shared/components/project-include/project-list.component.ts
+++ b/frontend/src/app/shared/components/project-include/project-list.component.ts
@@ -27,7 +27,7 @@ export class OpProjectListComponent {
@Input() selected:string[] = [];
- @Input() query:string = '';
+ @Input() query = '';
public get currentProjectHref():string|null {
return this.currentProjectService.apiv3Path;
diff --git a/frontend/src/app/shared/directives/search-highlight.directive.ts b/frontend/src/app/shared/directives/search-highlight.directive.ts
index 31f6ed8e367..2e5d558a414 100644
--- a/frontend/src/app/shared/directives/search-highlight.directive.ts
+++ b/frontend/src/app/shared/directives/search-highlight.directive.ts
@@ -13,13 +13,14 @@ export class OpSearchHighlightDirective implements AfterViewChecked {
constructor(readonly elementRef:ElementRef) { }
- ngAfterViewChecked() {
+ ngAfterViewChecked():void {
if (!this.query) {
return;
}
+ const el = this.elementRef.nativeElement as HTMLElement;
- const textNode = Array.from(this.elementRef.nativeElement.childNodes).find((n:Node) => n.nodeType === n.TEXT_NODE) as Node|undefined;
+ const textNode = Array.from(el.childNodes).find((n:Node) => n.nodeType === n.TEXT_NODE) as Node;
const content = textNode?.textContent || '';
if (!content) {
return;
@@ -32,11 +33,11 @@ export class OpSearchHighlightDirective implements AfterViewChecked {
}
const start = content.slice(0, startIndex);
- const result = content.slice(startIndex, startIndex + query.length);
+ const result = content.slice(startIndex, startIndex + query.length);
const end = content.slice(startIndex + query.length);
const newNode = document.createElement('span');
newNode.innerHTML = `${start}<span class="op-search-highlight">${result}</span>${end}`;
- this.elementRef.nativeElement.replaceChild(newNode, textNode);
+ el.replaceChild(newNode, textNode);
}
}
diff --git a/frontend/src/app/spot/components/checkbox/checkbox.component.ts b/frontend/src/app/spot/components/checkbox/checkbox.component.ts
index d641a35aa9f..c7765cfd979 100644
--- a/frontend/src/app/spot/components/checkbox/checkbox.component.ts
+++ b/frontend/src/app/spot/components/checkbox/checkbox.component.ts
@@ -63,11 +63,11 @@ export class SpotCheckboxComponent implements ControlValueAccessor {
onTouched = (_:SpotCheckboxState):void => {};
- registerOnChange(fn:any):void {
+ registerOnChange(fn:(_:SpotCheckboxState) => void):void {
this.onChange = fn;
}
- registerOnTouched(fn:any):void {
+ registerOnTouched(fn:(_:SpotCheckboxState) => void):void {
this.onTouched = fn;
}
}
diff --git a/frontend/src/app/spot/components/chip-field/chip-field.component.ts b/frontend/src/app/spot/components/chip-field/chip-field.component.ts
index 0c72a467bb5..758234a20c1 100644
--- a/frontend/src/app/spot/components/chip-field/chip-field.component.ts
+++ b/frontend/src/app/spot/components/chip-field/chip-field.component.ts
@@ -88,11 +88,11 @@ export class SpotChipFieldComponent implements ControlValueAccessor {
onTouched = (_:string[]):void => {};
- registerOnChange(fn:any):void {
+ registerOnChange(fn:(_:string[]) => void):void {
this.onChange = fn;
}
- registerOnTouched(fn:any):void {
+ registerOnTouched(fn:(_:string[]) => void):void {
this.onTouched = fn;
}
}
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
index a52ebe24b85..b6d05dd6276 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
@@ -29,7 +29,7 @@ export class SpotDropModalComponent implements OnDestroy {
@Output() closed = new EventEmitter<void>();
- @Input('alignment') public alignment:SpotDropModalAlignmentOption = SpotDropModalAlignmentOption.BottomLeft;
+ @Input() public alignment:SpotDropModalAlignmentOption = SpotDropModalAlignmentOption.BottomLeft;
@Input('open')
set open(value:boolean) {
@@ -80,7 +80,7 @@ export class SpotDropModalComponent implements OnDestroy {
document.body.removeEventListener('click', this.escapeListener);
}
- private closeEventListener = this.close.bind(this);
+ private closeEventListener = this.close.bind(this) as () => void;
private onEscape = (evt:KeyboardEvent) => {
if (evt.keyCode === KeyCodes.ESCAPE) {
@@ -88,5 +88,5 @@ export class SpotDropModalComponent implements OnDestroy {
}
};
- private escapeListener = this.onEscape.bind(this);
+ private escapeListener = this.onEscape.bind(this) as () => void;
}
diff --git a/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts b/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
index 528b7251da3..3fabaf10892 100644
--- a/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
+++ b/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
@@ -17,6 +17,7 @@ export class SpotFilterChipComponent {
@Input() removable = true;
@Input() title = '';
+
@Input() icon = '';
@Output() remove = new EventEmitter<void>();
@@ -25,11 +26,11 @@ export class SpotFilterChipComponent {
remove: this.i18n.t('js.spot.filter_chip.remove'),
};
- public get iconClasses() {
+ public get iconClasses():string[] {
return [
'spot-icon',
`spot-icon_${this.icon}`,
- ];
+ ];
}
constructor(readonly i18n:I18nService) {}
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.ts b/frontend/src/app/spot/components/text-field/text-field.component.ts
index 9ffecb5abb4..bf5a41ad05f 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.ts
+++ b/frontend/src/app/spot/components/text-field/text-field.component.ts
@@ -53,11 +53,11 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
onTouched = (_:string):void => {};
- registerOnChange(fn:any):void {
+ registerOnChange(fn:(_:string) => void):void {
this.onChange = fn;
}
- registerOnTouched(fn:any):void {
+ registerOnTouched(fn:(_:string) => void):void {
this.onTouched = fn;
}
}
diff --git a/frontend/src/app/spot/components/toggle/toggle.component.ts b/frontend/src/app/spot/components/toggle/toggle.component.ts
index 907b41993f7..38823f76f3b 100644
--- a/frontend/src/app/spot/components/toggle/toggle.component.ts
+++ b/frontend/src/app/spot/components/toggle/toggle.component.ts
@@ -51,11 +51,11 @@ export class SpotToggleComponent<T> implements ControlValueAccessor {
onTouched = (_:T):void => {};
- registerOnChange(fn:any):void {
+ registerOnChange(fn:(_:T) => void):void {
this.onChange = fn;
}
- registerOnTouched(fn:any):void {
+ registerOnTouched(fn:(_:T) => void):void {
this.onTouched = fn;
}
}
diff --git a/frontend/src/app/spot/icon-font/generate.js b/frontend/src/app/spot/icon-font/generate.js
index 7ab418bd934..e5008228d4e 100644
--- a/frontend/src/app/spot/icon-font/generate.js
+++ b/frontend/src/app/spot/icon-font/generate.js
@@ -2,7 +2,6 @@
const webfontsGenerator = require('webfonts-generator');
const path = require('path');
-const fs = require('fs');
const glob = require("glob")
const TEMPLATE_DIR = path.resolve(process.argv[2]);