Skip to content

Commit

Permalink
UI: update eslint rules and refactor types (#2676)
Browse files Browse the repository at this point in the history
* fix: ban Object, Function types
* fix: snip always option in eol-last. because this is default.
* fix: snip always option in semi. because this is default.
cf. https://eslint.style/rules/default/semi
* fix: reorder eslint rules to clear rule category

1. eslint native rules
2. unused-imports
3. typescript-eslint
4. angular-eslint
5. stylistic
  • Loading branch information
miettal authored Jun 26, 2024
1 parent 89db028 commit f130325
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
24 changes: 8 additions & 16 deletions ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"curly": "error",
"unused-imports/no-unused-imports": "error",
"@stylistic/semi": [
"error",
"always"
],
"@stylistic/quote-props": [
"warn",
"consistent"
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
Expand Down Expand Up @@ -67,15 +60,16 @@
"style": "camelCase"
}
],
"curly": "error",
"@stylistic/semi": "error",
"@stylistic/quote-props": [
"warn",
"consistent"
],
"@stylistic/comma-dangle": [
"error",
"always-multiline"
],
"@stylistic/eol-last": [
"error",
"always"
],
"@stylistic/eol-last": "error",
"@stylistic/no-trailing-spaces": "error",
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -90,9 +84,7 @@
{
"extendDefaults": true,
"types": {
"{}": false,
"Object": false,
"Function": false
"{}": false
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/edge/settings/system/maintenance/maintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MaintenanceComponent implements OnInit {
protected systemRestartState: BehaviorSubject<{ key: Type, state: SystemRestartState }> = new BehaviorSubject({ key: null, state: SystemRestartState.INITIAL });
protected spinnerId: string = MaintenanceComponent.SELECTOR;
protected readonly SystemRestartState = SystemRestartState;
protected confirmationAlert: Function = (type: Type) => presentAlert(this.alertCtrl, this.translate, {
protected confirmationAlert: (type: Type) => void = (type: Type) => presentAlert(this.alertCtrl, this.translate, {
message: this.translate.instant('SETTINGS.SYSTEM_UPDATE.RESTART_WARNING', { system: environment.edgeShortName }),
subHeader: this.translate.instant('SETTINGS.SYSTEM_UPDATE.RESTART_CONFIRMATION', { system: environment.edgeShortName }),
buttons: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class OeSystemUpdateComponent implements OnInit, OnDestroy {

protected executeUpdate: ExecuteSystemUpdate = null;
protected isWaiting: boolean;
protected confirmationAlert: Function = () => presentAlert(this.alertCtrl, this.translate, {
protected confirmationAlert: () => void = () => presentAlert(this.alertCtrl, this.translate, {
message: this.translate.instant('SETTINGS.SYSTEM_UPDATE.WARNING', { system: environment.edgeShortName }),
subHeader: this.translate.instant('SETTINGS.SYSTEM_UPDATE.SUB_HEADER'),
buttons: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export type ButtonLabel = {
value: string;
/** Icons for Button, displayed above the corresponding name */
icons?: Icon;
callback?: Function;
callback?: () => void;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormlyFieldConfig } from "@ngx-formly/core";
import { TranslateService } from "@ngx-translate/core";
import { filter } from "rxjs/operators";

import { ChannelAddress, EdgeConfig, Service } from "../../shared";
import { CurrentData, ChannelAddress, EdgeConfig, Service } from "../../shared";
import { SharedModule } from "../../shared.module";
import { Role } from "../../type/role";
import { TextIndentation } from "../modal/modal-line/modal-line";
Expand Down Expand Up @@ -99,7 +99,7 @@ export namespace OeFormlyField {
export type ValueFromChannelsLine = {
type: 'value-from-channels-line',
name: string,
value: Function,
value: (data: CurrentData) => string,
channelsToSubscribe: ChannelAddress[],
indentation?: TextIndentation,
filter?: (value: number[] | null) => boolean,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Service extends AbstractService {
// this.notify(notification);
}

public setCurrentComponent(currentPageTitle: string | { languageKey: string, interpolateParams?: Object }, activatedRoute: ActivatedRoute): Promise<Edge> {
public setCurrentComponent(currentPageTitle: string | { languageKey: string, interpolateParams?: {} }, activatedRoute: ActivatedRoute): Promise<Edge> {
return new Promise((resolve, reject) => {
// Set the currentPageTitle only once per ActivatedRoute
if (this.currentActivatedRoute != activatedRoute) {
Expand Down

0 comments on commit f130325

Please sign in to comment.