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

The solution is to disable the native no-unused-vars so that only the TS one is enabled. The former is likely to be enabled if you extend a config in ESLint. Add the rules below to your ESLint config. “rules”: { “no-unused-vars”: “off”, “@typescript-eslint/no-unused-vars”: “error” }

what is the meaning of tslint: “Warning: The ‘no-use-before-declare’ rule requires type information”?

Update! Since this question was asked, the –type-check flag has been deprecated so you should be able use: tslint –project tsconfig.json src/**/**.ts Original answer below. I believe that this means you can’t enable the no-use-before-declare rule unless you run with the –type-check and the –project flags. It must depend on something that happens when those … Read more

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

This made me curious, so I checked out the TSlint source code for this rule. It has a function called isFiltered which seems to only check for ts.SyntaxKind.IfStatement, not for ts.SyntaxKind.SwitchStatement. function isFiltered({statements}: ts.Block): boolean { switch (statements.length) { case 0: return true; case 1: return statements[0].kind === ts.SyntaxKind.IfStatement; default: return statements[0].kind === ts.SyntaxKind.IfStatement && … Read more

Proper explanation for NodeJS/Typescript Export / Import?

Agreed, import/export syntax is confusing for at least two reasons: the commonjs syntax: var module = require (“module”); works but that is commonjs -> no typings it changed: the syntax import x = require(‘y’) is now deprecated in TS TL;DR;: Use the ‘es6 style’ syntax introduced in TS 1.5 The ‘best’ resource on import/export in … Read more

Why are bitwise operators not allowed in tslint?

Linters exist for multiple reasons: to help maintain consistent, clean and readable code, catch developer mistakes (e.g. unreachable code or unused variables) and to warn you about potentially bad practices even though they may technically be allowed. As mentioned in the TSLint documentation Bitwise operators are often typos – for example bool1 & bool2 instead … Read more

How to ignore/exclude some files/directory from linting in angular cli

From Angular6+, .angular-cli.json has been replaced by angular.json, but you can still add the exclude path in its lint part. “lint”: { “builder”: “@angular-devkit/build-angular:tslint”, “options”: { “tsConfig”: [ “src/tsconfig.app.json”, “src/tsconfig.spec.json” ], “exclude”: [ “**/node_modules/**” // excluded directories ] } } According to the angular-cli issue#5063, you can add the exclude path in .angular-cli.json like this: … Read more

TypeScript linter warning: no-unused-variable is deprecated; but I’m not using this config

no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. Remove deprecated no-unused-variable from your or dependency tslint.json file. Specify the following compiler options in your tsconfig.json file. “compilerOptions”: { “noUnusedLocals”: true, /* Report errors on unused locals. */ “noUnusedParameters”: true /* Report errors on unused parameters. */ }

tech