Skip to content

Commit

Permalink
(refactor) by eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dreyliky committed Jan 9, 2023
1 parent 4a90b9c commit e2bf06b
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 65 deletions.
14 changes: 5 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
"error",
4,
{
"SwitchCase": 1
"SwitchCase": 1,
"MemberExpression": 1
}
],
"max-lines-per-function": [
Expand Down Expand Up @@ -247,35 +248,30 @@
"public-static-field",
"protected-static-field",
"private-static-field",
"public-decorated-field",
"protected-decorated-field",
"private-decorated-field",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-abstract-field",
"protected-abstract-field",
"private-abstract-field",
"public-constructor",
"protected-constructor",
"private-constructor",
"public-static-method",
"protected-static-method",
"private-static-method",
"public-instance-method",
"protected-instance-method",
"private-instance-method",
"public-abstract-method",
"protected-abstract-method",
"private-abstract-method"
"protected-abstract-method"
]
}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@angular-eslint/no-host-metadata-property": "off"
"@angular-eslint/no-host-metadata-property": "off",
"@angular-eslint/no-input-rename": "off"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/app/library/core/classes/base-components/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export abstract class ɵOsBaseOptionComponent<T>
@HostBinding(`class.${ɵCommonCssClassEnum.Disabled}`)
public isDisabled: boolean = false;

/** Fires when the option item selected */
@Output()
public readonly abstract osSelected: EventEmitter<unknown>;

protected readonly _dataUpdated$ = new Subject<T>();

private _data: T;

/** Fires when the option item selected */
@Output()
public readonly abstract osSelected: EventEmitter<unknown>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export class EmailBoxComponent extends ɵOsBaseFieldComponent implements OnInit
/** Fires when the email-box value change */
@Output()
public osChange: Observable<EmailBoxChangeEvent> = this.createEvent('change')
.pipe(
map((event) => this.transformChangeEvent(event))
);
.pipe(
map((event) => this.transformChangeEvent(event))
);

/** @internal */
public get _inputAutocompleteAttrValue(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export class NumberBoxComponent
/** Fires when the number-box value change */
@Output()
public osChange: Observable<NumberBoxChangeEvent> = this.createEvent('change')
.pipe(
map((event) => this.transformChangeEvent(event))
);
.pipe(
map((event) => this.transformChangeEvent(event))
);

/** @internal */
public get _inputAutocompleteAttrValue(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class PasswordBoxComponent extends ɵOsBaseFieldComponent implements OnIn
/** Fires when the password-box value change */
@Output()
public osChange: Observable<PasswordBoxChangeEvent> = this.createEvent('change')
.pipe(
map((event) => this.transformChangeEvent(event))
);
.pipe(
map((event) => this.transformChangeEvent(event))
);

/** @internal */
public get _inputAutocompleteAttrValue(): string {
Expand Down
1 change: 1 addition & 0 deletions src/app/library/modules/resizer/classes/resizer.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ɵResizerFactory {
return new ResizerType(context, this.injector);
}

// eslint-disable-next-line max-lines-per-function
private getResizerClassById(id: ResizerEnum): typeof ɵTopResizer {
switch (id) {
case ResizerEnum.TopLeft:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class ResizableDirective implements OnChanges, AfterViewInit, OnDestroy {
this._resizableElement.classList.add(CssClass.Resizing);
this.document.addEventListener('mousemove', this.onPointerMove);
this.document.addEventListener('mouseup', this.onPointerUp);
}
};

private readonly onPointerMove = (event: PointerEvent | TouchEvent): void => {
const resizeInfo = this.getResizeInfo(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class TextBoxComponent extends ɵOsBaseFieldComponent implements OnInit {
/** Fires when the text-box value change */
@Output()
public osChange: Observable<TextBoxChangeEvent> = this.createEvent('change')
.pipe(
map((event) => this.transformChangeEvent(event))
);
.pipe(
map((event) => this.transformChangeEvent(event))
);

/** @internal */
public get _inputAutocompleteAttrValue(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export class TextareaBoxComponent
/** Fires when the textarea-box value change */
@Output()
public osChange: Observable<TextareaBoxChangeEvent> = this.createEvent('change')
.pipe(
map((event) => this.transformChangeEvent(event))
);
.pipe(
map((event) => this.transformChangeEvent(event))
);

protected override targetInternalElementSelector = 'textarea';

Expand Down
4 changes: 2 additions & 2 deletions src/app/library/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ declare const require: {
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
teardown: { destroyAfterEach: false }
}
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import { DraggerConfig, DragStrategyByAxisProperties } from 'ngx-os';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DraggerOnAbsoluteElementComponent implements AfterViewInit {
@ViewChild('containerHideButton', { read: ElementRef })
private readonly containerHideButton: ElementRef<HTMLElement>;

public draggerConfig: DraggerConfig;

public isContainerVisible = false;
Expand All @@ -34,6 +31,9 @@ export class DraggerOnAbsoluteElementComponent implements AfterViewInit {
};
}

@ViewChild('containerHideButton', { read: ElementRef })
private readonly containerHideButton: ElementRef<HTMLElement>;

constructor(
private readonly changeDetector: ChangeDetectorRef
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { DraggerConfig } from 'ngx-os';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DraggerViaHandleComponent implements AfterViewInit {
public draggerConfig: DraggerConfig;

@ViewChild('container')
private readonly containerElement: ElementRef<HTMLDivElement>;

@ViewChild('handle')
private readonly handleElement: ElementRef<HTMLDivElement>;

public draggerConfig: DraggerConfig;

constructor(
private readonly changeDetector: ChangeDetectorRef
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
})
export class NumberBoxAsFormControlComponent {
public readonly numberBoxControl = new UntypedFormControl();
public readonly numberBoxDisabledControl = new UntypedFormControl({ value: '', disabled: true });
public readonly numberBoxDisabledControl = new UntypedFormControl({
value: '',
disabled: true
});

public readonly formGroup = new UntypedFormGroup({
numberBoxValue: this.numberBoxControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
})
export class PasswordBoxAsFormControlComponent {
public readonly passwordBoxControl = new UntypedFormControl();
public readonly passwordBoxDisabledControl = new UntypedFormControl({ value: '', disabled: true });
public readonly passwordBoxDisabledControl = new UntypedFormControl({
value: '',
disabled: true
});

public readonly formGroup = new UntypedFormGroup({
passwordBoxValue: this.passwordBoxControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class RadioButtonAsFormControlComponent {
];

public readonly selectedValueControl = new UntypedFormControl(this.items[1]);
public readonly radioButtonDisabledControl = new UntypedFormControl({ value: true, disabled: true });
public readonly radioButtonDisabledControl = new UntypedFormControl({
value: true,
disabled: true
});

public readonly formGroup = new UntypedFormGroup({
selectedValue: this.selectedValueControl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ChangeDetectionStrategy, Component,
ChangeDetectionStrategy,
Component,
ElementRef,
ViewChild
} from '@angular/core';
Expand All @@ -11,9 +12,6 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ResizerOnAbsoluteElementComponent {
@ViewChild('containerHideButton', { read: ElementRef })
private readonly containerHideButton: ElementRef<HTMLElement>;

public isContainerVisible = false;

public get labelOfToggleVisibilityButton(): string {
Expand All @@ -28,6 +26,9 @@ export class ResizerOnAbsoluteElementComponent {
};
}

@ViewChild('containerHideButton', { read: ElementRef })
public readonly containerHideButton: ElementRef<HTMLElement>;

public onToggleContainerVisibilityButtonClick(): void {
this.isContainerVisible = !this.isContainerVisible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
})
export class TextareaAsFormControlComponent {
public readonly textareaBoxControl = new UntypedFormControl('Hi there!');
public readonly textareaBoxDisabledControl = new UntypedFormControl({ value: '', disabled: true });
public readonly textareaBoxDisabledControl = new UntypedFormControl({
value: '',
disabled: true
});

public readonly formGroup = new UntypedFormGroup({
textareaBoxValue: this.textareaBoxControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import { SideBarItemsService } from './side-bar-items.service';
]
})
export class SideBarListComponent implements OnInit, AfterViewInit {
@ViewChild(TreeViewComponent)
private readonly treeView: TreeViewComponent<SideBarItem>;

public metaInfo$: Observable<ComponentMetaInfo>;
public nodes$: Observable<TreeNode<SideBarItem>[]>;

@ViewChild(TreeViewComponent)
private readonly treeView: TreeViewComponent<SideBarItem>;

constructor(
private readonly componentsSearchService: LibraryComponentsSearchService,
private readonly overviewService: OverviewService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ComponentFactoryResolver, Input, ViewChild,
Input,
ViewChild,
ViewContainerRef
} from '@angular/core';
import { AppRouteEnum } from '@core/enums';
Expand Down Expand Up @@ -39,9 +40,6 @@ export class ExampleComponent implements AfterViewInit {
return this._demoComponentMetaInfo;
}

@ViewChild('exampleTemplate', { read: ViewContainerRef })
private readonly exampleContainer: ViewContainerRef;

public get isScssExist(): boolean {
return !!this.docComponent?.styleUrlsData?.[0]?.data;
}
Expand All @@ -58,22 +56,21 @@ export class ExampleComponent implements AfterViewInit {
public openedSection = SectionEnum.Demo;
public docComponent: DocComponent;

@ViewChild('exampleTemplate', { read: ViewContainerRef })
private readonly exampleContainer: ViewContainerRef;

private _demoComponentMetaInfo: DemoComponentMetaInfo;

constructor(
private readonly overviewService: OverviewService,
private readonly docService: ExamplesDocumentationService,
private readonly componentFactoryResolver: ComponentFactoryResolver,
private readonly dynamicWindowService: DynamicWindowService,
private readonly changeDetector: ChangeDetectorRef
) {}

public ngAfterViewInit(): void {
const componentFactory = this.componentFactoryResolver
.resolveComponentFactory(this._demoComponentMetaInfo.component);

this.exampleContainer.clear();
this.exampleContainer.createComponent(componentFactory);
this.exampleContainer.createComponent(this._demoComponentMetaInfo.component);
this.changeDetector.detectChanges();
}

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

public undo(): void {
const lastItemIndex = (this.pastHistory.data!.length - 1);
const lastItemIndex = (this.pastHistory.data.length - 1);
const removedItem = this.pastHistory.removeItemByIndex(lastItemIndex);

this.futureHistory.pushItem(removedItem);
Expand All @@ -46,7 +46,7 @@ export class EditorHistoryService {
}

public redo(): void {
const lastItemIndex = (this.futureHistory.data!.length - 1);
const lastItemIndex = (this.futureHistory.data.length - 1);
const removedItem = this.futureHistory.removeItemByIndex(lastItemIndex);

this.pastHistory.pushItem(removedItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export class ImageSelectionComponent {
@Input()
public currentBackground: BackgroundMetadata;

public readonly defaultBackgroundUrls = BACKGROUND_URLS;

@ViewChild('fileUploader')
private readonly fileUploaderRef: ElementRef<HTMLInputElement>;

public readonly defaultBackgroundUrls = BACKGROUND_URLS;

public get isCurrentBackgroundImage(): boolean {
return (this.currentBackground.type === BackgroundTypeEnum.Image);
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/pages/example/example.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import { RouteParam } from './route-param.enum';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ExampleComponent implements OnInit, AfterViewInit {
@ViewChild('exampleContainer', { read: ViewContainerRef })
private readonly exampleContainer: ViewContainerRef;

public componentType: OsComponentEnum;
public demoMetaInfo: DemoComponentMetaInfo;

@ViewChild('exampleContainer', { read: ViewContainerRef })
private readonly exampleContainer: ViewContainerRef;

private exampleComponentName: string;

constructor(
Expand Down
4 changes: 2 additions & 2 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ declare const require: {
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
teardown: { destroyAfterEach: false }
}
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
Expand Down

0 comments on commit e2bf06b

Please sign in to comment.