Questions tagged [tslint]

tslint is a static analysis linter for TypeScript.

tslint is a linter for the language, similar to jslint.

Use this tag on questions about:

  • installation
  • command-line options
  • default/built-in rules
  • rule flags
  • Custom formatters
  • creation of custom rules

Github home of tslint
NPM home of tslint

1054 questions
41
votes
1 answer

Is there a way to enforce method return types on Typescript classes via a tslint rule?

I've read the tslint rules here and while it looks like the typedef rule's call-signature option is what I want, it doesn't complain about the lack of a return type. Anyone know the rule (f one exists) to enforce return types on class methods?
icfantv
  • 4,523
  • 7
  • 36
  • 53
40
votes
2 answers

tslint complaining "statements must be filtered with an if statement" when using switch

Lets say I have the following method: getErrorMessage(state: any, thingName?: string) { const thing: string = state.path || thingName; const messages: string[] = []; if (state.errors) { for (const errorName in state.errors) { …
MHOOS
  • 5,146
  • 11
  • 39
  • 74
38
votes
4 answers

what is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information"?

What is the meaning of tslint: "Warning: The 'no-use-before-declare' rule requires type information."? I did some basic googling but I'm not clear on what this means or its implications.
user8570495
  • 1,645
  • 5
  • 19
  • 29
37
votes
3 answers

@typescript-eslint/eslint-plugin error: 'Route' is defined but never used (no-unused-vars)

After eslint adds typescript check, there will be an error when the attribute variable in the class definition is Array. this is my eslintrc.js module.exports = { root: true, env: { node: true }, 'extends': ['plugin:vue/essential',…
Jian Cl
  • 373
  • 1
  • 3
  • 4
37
votes
4 answers

Error TS2339: Property 'entries' does not exist on type 'FormData'

I searched on Stackoverflow and on the web, I found this thread https://github.com/Microsoft/TypeScript/issues/14813 but it does not solve my problem. I run into this error while compiling my code with ng serve --watch. Error TS2339: Property…
b00r00x0
  • 853
  • 1
  • 15
  • 21
34
votes
8 answers

Angular 6 ng lint combineLatest is deprecated

I recently updated from Angular 5 to Angular 6. I'm getting this warning combineLatest is deprecated: resultSelector no longer supported, pipe to map instead. Rxjs is version 6.1.0, tslint is 5.10.0, Angular CLI is 6.0.0 and Typescript 2.7.2. I'm…
Phaze
  • 545
  • 1
  • 5
  • 14
34
votes
2 answers

What is the "as syntax" pointed out by tslint?

I upgraded tslint and now it complains about: ERROR: src/Metronome/JobFetcher.ts[13, 32]: Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead. The offending code looks like: const jobs = await…
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
34
votes
6 answers

Update TSLint Errors : Could not find implementations for the following rules specified in the configuration

I upgraded my tslint to 4.0.2 and now I get a lot of errors like the following Could not find implementations for the following rules specified in the configuration: directive-selector-name component-selector-name …
David Cruwys
  • 6,262
  • 12
  • 45
  • 91
33
votes
1 answer

TSLint , enforce spacing between brackets in import statements

Which rule do I need to apply to enforce spaces between curly brackets in the import statements? i.e Instead of : import {IPostService} from './api/IPostService'; I want: import { IPostService } from './api/IPostService';
fgonzalez
  • 3,787
  • 7
  • 45
  • 79
32
votes
3 answers

Mobx-State-Tree - Assign to Array Type

I have this basic model. const stuff = types.model({ term: types.string, excludeTerm: types.string, stores: types.array(types.string) }).actions(self => ({ setTerm(term: string) { self.term = term }, setExcludeTerm(term: string) { …
etudor
  • 1,183
  • 1
  • 11
  • 19
32
votes
5 answers

tslint Error - Shadowed name: 'err'

tslint is currently throwing the following error Shadowed name: 'err' Here is the code fs.readdir(fileUrl, (err, files) => { fs.readFile(path.join(fileUrl, files[0]), function (err, data) { if (!err) { …
bobdolan
  • 563
  • 3
  • 9
  • 21
32
votes
6 answers

VS Code: Change color of squiggly underline for Lint

My configurations currently show the same red squiggly line for Typescript errors and TSLint warnings. I am using TSLint extension for Visual Studio Code but the configuration I believe is a general VS Code configuration. This is what it should look…
Esteban Santini
  • 465
  • 1
  • 4
  • 11
30
votes
7 answers

Project must list all files or use an 'include' pattern

I see this warning thrown in VSCode: This is the line that throws the ts warning: import packageJson from "../package.json"; Weirdly, building and linting the project works fine: $ tsc --project . ✨ Done in 1.16s. $ tslint --config…
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
29
votes
7 answers

how to set multiple CSS style properties in typescript for an element?

Please consider the below snippet. i need to set multiple CSS properties in typescript. for that i have tried the below code. public static setStyleAttribute(element: HTMLElement, attrs: { [key: string]: Object }): void { if (attrs !==…
29
votes
2 answers

How to configure Visual Studio Code and tslint?

In 0.3.0, I'm seeing intellisense for typescript. However, I was also expecting to see some tslinting as I have a tslint.json. Does VSC support linting natively or do I just need to lean on gulp? If the latter, is it configurable to run as files are…
Mark Nadig
  • 4,901
  • 4
  • 37
  • 46
1 2
3
70 71