Category : eslint

I am developing a web application using Angular typescript. Recently, I tried to update @angular/cli package but got the following error: (env) ➜ tsclient git:(feature/my-branch) npm install –save-dev @angular/[email protected] npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: @angular/[email protected] npm ERR! node_modules/@angular/cli ..

Read more

private userSubject$: BehaviorSubject<UserModel> = new BehaviorSubject<UserModel>(null); userChanged$: Observable<UserModel> = this.userSubject$.asObservable(); It says: Member userChanged$ should be declared before all private instance field [email protected]/member-ordering I like this rule. But how can I use the above code without disabling this rule? If I’ll change the order then it says: Property ‘userSubject$’ is used before its initialization. Source: ..

Read more

I would like to be able to utilize the eslint angular template that checks for i18n tags as shown here https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/i18n.ts and listed here https://github.com/angular-eslint/angular-eslint#readme, but there isn’t really any helpful instruction on how to activate it or what needs to be put in the config to make it work. I just need to know ..

Read more

I want to use lint in an excisting Angular Application. Now i get an lint error for an Guard Class: The name of the class FormCanDeactivate should end with the suffix Directive (https://angular.io/styleguide#style-02-03) (directive-class-suffix)tslint(1) Why should i use Directive as suffix? import { FormGroup, NgForm } from ‘@angular/forms’; import { ComponentCanDeactivate } from ‘@svn.app/core/guards/ComponentCanDeactivate’; import ..

Read more

The following line const reducers: ActionReducerMap<any> = {}; throws the error: ESLint: Unexpected any. Specify a different type.(@typescript-eslint/no-explicit-any) I’d like to know what the type for ActionReducerMap is? Can I set it explicitly? export const metaReducers: MetaReducer<State>[] = !environment.production ? [logger] : []; interface State { router: fromRouter.RouterReducerState<BaseRouterStoreState>; } const reducers: ActionReducerMap<any> = {}; export ..

Read more

I’m trying to fix the error: TS7015: Element implicitly has an ‘any’ type because index expression is not of type ‘number’. My code so far is as follows: private readonly TWITTER_OBJECT = ‘twttr’; constructor(@Inject(DOCUMENT) document: Document) { this.document = document; } loadScript(): Observable<unknown> { return new Observable((observer: Observer<unknown>) => { this.startScriptLoad(); if (this.document.defaultView) { (this.document.defaultView[ ..

Read more

I have the following directive which blocks any alphanumeric characters from being entered into a field. In the validateFields method, ESLint is throwing the following error message: ESLint: Unsafe call of an any typed value.(@typescript-eslint/no-unsafe-call) I looked at the type for ElementRef and it has has the following properties: ElementRef<any>.nativeElement: any With this in mind, ..

Read more