How to order imports with tslint’s import-ordering rule

I agree that it’s confusing. The problem is that the source string comparisons include the ../.. portions of the module names, so to appease the rule, you would need to sort them like this: import FetchStatus from ‘../../../../../state/generic/models/FetchStatus’; import Geofilter from ‘../../../../../state/geofilter/models/Geofilter’; import FlexRow from ‘../../../../generic/components/FlexRow’; import Input from ‘../../../../generic/components/Input’; import CopyLensModal from ‘./CopyLensModal’; The … Read more

Making Sense of ‘No Shadowed Variable’ tslint Warning

The linter complains because you are redefining the same variable multiple times. Thus replacing the ones in the closure containing it. Instead of redeclaring it just use it: private getNextStageStep(currentDisciplineSelected) { let nextStageStep = ”; if (this.stageForDiscipline(this.currentDisciplineSelected) === ‘step 1’) { nextStageStep = ‘step 2’; } else if (this.stageForDiscipline(this.currentDisciplineSelected) === ‘step 2’) { nextStageStep = … Read more

How to fix the issue not all the code paths return value?

The complaint is that the first if(){} is missing an else{} block with a return statement. You can disable this behaviour in a tsconfig file setting: “noImplicitReturns”: false, Of course you could also add else {return …} But I would not recommend that, since forEach is not supposed to return anything as stated for example … Read more

Typescript : require statement not part of an import statement

TypeScript modules are an implementation of ES6 modules. ES6 modules are static. Your issue comes from the dynamic path: path.join(process.cwd() + “/data”). The compiler can’t determine which module it is at compile time, and the linter doesn’t like the causes that lead to any. You should use a static path to the module. At compile … Read more

[tslint]Expected a ‘for-of’ loop instead of a ‘for’ loop with this simple iteration (prefer-for-of)

It is asking you to use format like the following. The of keyword loops over the objects in the array instead of looping over the indexes of the array. I’m assuming it is triggering because you are only using the index as a way of getting to the value in the array (which can be … Read more

Angular2 – HTTP RequestOptions HEADERS

Update As of today, @angular/http has been deprecated, and @angular/common/http should be used instead. So the best way to work with http headers is to import import { HttpHeaders } from ‘@angular/common/http’; (documentation). Old answer The Headers type you are supposed to import is import { Headers } from ‘@angular/http’;. Check your imports

TSLint Error “Exceeds maximum line length of 120”

It’s not really something you can change, not related to your code. You should simply disable the rule for this import by adding a comment before : // tslint:disable-next-line:max-line-length import { PersonsSingleAccountComponent} from ‘../persons-information/fragments/persons-single-account/persons-single-account-bookings/persons-single-account-bookings.component’

tech