Skip to content

Commit

Permalink
(fix) whole project by new eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dreyliky committed Aug 19, 2021
1 parent d896723 commit 10ce6e6
Show file tree
Hide file tree
Showing 128 changed files with 744 additions and 858 deletions.
101 changes: 80 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,37 @@
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@angular-eslint/recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"project": ["./tsconfig.eslint.json"]
},
"rules": {
"max-len": ["warn", { "code": 100, "ignorePattern": "import(.*).then(.*)", "ignoreComments": true }],
"max-len": ["error", { "code": 120, "ignorePattern": "import(.*).then(.*)" }],
"no-shadow": "off",
"padded-blocks": ["error", { "classes": "always" }],
"padded-blocks": ["error", { "classes": "never" }],
"padding-line-between-statements": [
"warn",
"error",
{ "blankLine": "always", "prev": "*", "next": ["block", "block-like"] }
],
"space-infix-ops": "warn",
"no-multi-spaces": "warn",
"arrow-parens": "warn",
"no-trailing-spaces": "warn",
"computed-property-spacing": "error",
"arrow-spacing": ["error", { "before": true, "after": true }],
"space-infix-ops": "error",
"no-multi-spaces": "error",
"arrow-parens": "error",
"eqeqeq": "error",
"dot-location": ["error", "property"],
"curly": "error",
"no-trailing-spaces": "error",
"space-before-function-paren": ["error", "never"],
"no-mixed-spaces-and-tabs": "error",
"array-callback-return": "error",
"newline-before-return": "error",
"object-curly-spacing": ["error", "always"],
"comma-spacing": ["error", { "before": false, "after": true }],
"indent": ["warn", 4, { "SwitchCase": 1 }],
"max-lines-per-function": ["warn", { "max": 20, "skipComments": true }],
"indent": ["error", 4, { "SwitchCase": 1 }],
"max-lines-per-function": ["error", { "max": 20, "skipComments": true }],
"spaced-comment": ["error", "always"],
"space-before-blocks": "error",
"keyword-spacing": "error",
Expand All @@ -47,16 +57,48 @@
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"no-extra-boolean-cast": "off",
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
"radix": ["error", "always"],
"yoda": ["error", "never"],
"no-useless-return": "error",
"no-useless-concat": "error",
"no-useless-call": "error",
"no-unmodified-loop-condition": "error",
"no-throw-literal": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-redeclare": "error",
"no-proto": "error",
"no-octal": "error",
"no-param-reassign": "error",
"no-new-wrappers": "error",
"no-new-func": "error",
"no-new": "error",
"no-multi-str": "error",
"no-implied-eval": "error",
"no-global-assign": "error",
"no-floating-decimal": "error",
"no-extra-label": "error",
"no-extend-native": "error",
"no-eval": "error",
"no-var": "error",
"prefer-const": "warn",
"no-lone-blocks": "error",
"prefer-const": "error",
"semi": "error",
"eol-last": "warn",
"eol-last": ["error", "always"],
"comma-dangle": "error",
"lines-between-class-members": "off",
"no-multiple-empty-lines": ["warn", { "max": 1 }],
"no-empty-pattern": "error",
"no-else-return": ["error"],
"no-constructor-return": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
"no-empty-function": [
"error",
{ "allow": ["constructors"] }
],
"max-lines": ["error", {"max": 400, "skipComments": true}],
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/lines-between-class-members": [
"warn",
"error",
"always",
{ "exceptAfterSingleLine": true }
],
Expand All @@ -79,28 +121,45 @@
"error",
{
"default": [
"signature",

"public-static-field",
"protected-static-field",
"private-static-field",
"public-decorated-field",
"protected-decorated-field",
"private-decorated-field",
"public-instance-field",
"static-field",
"protected-instance-field",
"private-instance-field",
"instance-field",
"constructor",
"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",
"static-method",
"protected-instance-method",
"private-instance-method",
"instance-method"
"public-abstract-method",
"protected-abstract-method",
"private-abstract-method"
]
}
],
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["**/*.spec.ts"],
"files": ["*.spec.ts"],
"rules": {
"max-lines-per-function": "off"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --aot",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
Expand Down
2 changes: 0 additions & 2 deletions projects/os-angular/src/lib/core/base-components/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { OsBaseComponent } from './element';
template: ''
})
export class OsBaseButtonComponent extends OsBaseComponent {

@Input()
public isDisabled: boolean;

Expand Down Expand Up @@ -36,5 +35,4 @@ export class OsBaseButtonComponent extends OsBaseComponent {
constructor() {
super();
}

}
4 changes: 0 additions & 4 deletions projects/os-angular/src/lib/core/base-components/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IdGenerator } from 'os-angular/helpers';
template: ''
})
export class OsBaseComponent {

/**
* Object with css styles which will applied for target internal element
*/
Expand Down Expand Up @@ -71,7 +70,4 @@ export class OsBaseComponent {
*/
@Output()
public osWheel: EventEmitter<MouseEvent> = new EventEmitter();

constructor() {}

}
2 changes: 0 additions & 2 deletions projects/os-angular/src/lib/core/base-components/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { OsBaseComponent } from './element';
template: ''
})
export class OsBaseFieldComponent extends OsBaseComponent {

@Input()
public isDisabled: boolean;

Expand Down Expand Up @@ -36,5 +35,4 @@ export class OsBaseFieldComponent extends OsBaseComponent {
constructor() {
super();
}

}
2 changes: 0 additions & 2 deletions projects/os-angular/src/lib/helpers/id-generator.helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { RandomHelper } from './random.helper';

export class IdGenerator {

public static generate(name: string = ''): string {
const randomId = RandomHelper.getRandomInt(1, 1000000);
const nameAsPrefix = (name) ? `${name}-` : '';
Expand All @@ -13,5 +12,4 @@ export class IdGenerator {

return `${nameAsPrefix}${randomId}`;
}

}
2 changes: 0 additions & 2 deletions projects/os-angular/src/lib/helpers/outside-click.helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export class OutsideClick {

public static checkForElement(element: HTMLElement, event: MouseEvent): boolean {
const bubbledElements: HTMLElement[] = event.composedPath() as any;

return bubbledElements
.every((currElement) => (currElement !== element));
}

}
2 changes: 0 additions & 2 deletions projects/os-angular/src/lib/helpers/random.helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export class RandomHelper {

public static getRandomInt(min: number, max: number): number {
const minN = Math.ceil(min);
const maxN = Math.floor(max);

return Math.floor(Math.random() * (maxN - minN)) + minN;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import { buttonType } from '../../shared';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ButtonComponent extends OsBaseButtonComponent {

@Input()
public type: buttonType = 'button';

constructor() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {
ChangeDetectionStrategy, ChangeDetectorRef, Component,
EventEmitter, forwardRef, Input, Output
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
forwardRef,
Input,
Output
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { OsBaseComponent } from 'os-angular/core';
Expand All @@ -18,7 +23,6 @@ import { OsBaseComponent } from 'os-angular/core';
]
})
export class CheckboxComponent extends OsBaseComponent implements ControlValueAccessor {

@Input()
public label: string;

Expand All @@ -37,6 +41,9 @@ export class CheckboxComponent extends OsBaseComponent implements ControlValueAc
@Output()
public checkedChange = new EventEmitter<boolean>();

public onChange: (value: boolean) => any;
public onTouched: () => any;

constructor(
private readonly changeDetector: ChangeDetectorRef
) {
Expand All @@ -48,14 +55,14 @@ export class CheckboxComponent extends OsBaseComponent implements ControlValueAc

this.osChange.emit(event);
this.checkedChange.emit(target.checked);
this.onChange(target.checked);
this.onChange?.(target.checked);
}

public registerOnChange(fn: () => {}): void {
public registerOnChange(fn: () => any): void {
this.onChange = fn;
}

public registerOnTouched(fn: () => {}): void {
public registerOnTouched(fn: () => any): void {
this.onTouched = fn;
}

Expand All @@ -64,9 +71,4 @@ export class CheckboxComponent extends OsBaseComponent implements ControlValueAc

this.changeDetector.detectChanges();
}

public onChange: any = (): any => {};

public onTouched: any = (): any => {};

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { MouseButtonEnum } from '../../../core';

export class DraggerConfig {

public draggableElement?: HTMLElement;
public movableElement?: HTMLElement;
public childElementsBlackList?: HTMLElement[] = [];
Expand All @@ -10,5 +9,4 @@ export class DraggerConfig {
public shiftY?: number;
public isEnabled?: boolean = true;
public isAllowMoveElement?: boolean = true;

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import {
Directive, ElementRef,
EventEmitter, Input, OnDestroy, OnInit, Output
} from '@angular/core';
import { Directive, ElementRef, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
import { DraggerConfig } from '../classes';
import { DragInfo } from '../interfaces/drag-info.interface';

@Directive({
selector: '[os-draggable]'
})
export class OsDraggableDirective implements OnInit, OnDestroy {

export class OsDraggableDirective implements OnDestroy {
@Input('os-draggable')
public set draggerConfig(config: DraggerConfig) {
this._draggerConfig = { ...this._draggerConfig, ...config };
Expand Down Expand Up @@ -49,8 +45,6 @@ export class OsDraggableDirective implements OnInit, OnDestroy {
private readonly element: ElementRef<HTMLElement>
) {}

public ngOnInit(): void {}

public ngOnDestroy(): void {
this._draggableElement.removeEventListener('mousedown', this.elementMouseDownHandler);
}
Expand Down Expand Up @@ -167,5 +161,4 @@ export class OsDraggableDirective implements OnInit, OnDestroy {

return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import { OsBaseComponent } from 'os-angular/core';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class FieldRowComponent extends OsBaseComponent {

@Input()
public stacked: boolean = false;

constructor() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { GridComponent } from './grid.component';


describe('GridComponent', () => {
let component: GridComponent;
let fixture: ComponentFixture<GridComponent>;
Expand Down
Loading

0 comments on commit 10ce6e6

Please sign in to comment.