Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eslint rules and refactoring types. #2676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you fix formatting, why did you change the order around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clear rule cateogry. I commented on this commit.
4a1365c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,i agree

"@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would ban empty object as well, otherwise, type safety is not guaranteed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I want to ban {}. but in this repo there are using many {} type. especially {} used in json rpc related type. this means if I remove {} in this repo, this will be super heavy task(Many typing will needed....). so I focused to ban Object and Function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing any type and banning {}, applying strictNullChecks is very very important...
if I have time, I will address this kind little by little in other PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i understand in terms of being a heavy task, so i approve

}
}
]
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> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} is better than Object but still not good, anyway this method is deprecated and shouldnt be used in the future anyway

return new Promise((resolve, reject) => {
// Set the currentPageTitle only once per ActivatedRoute
if (this.currentActivatedRoute != activatedRoute) {
Expand Down