1,060 questions
1
vote
1
answer
57
views
Unused variable in for each
I have this function in my TS project:
size(): number {
let size = 0;
for (const _ of this) {
size++;
}
return size;
}
While I want to continue using a for each to count ...
1
vote
1
answer
501
views
Migrating from TSlint to ESlint
I am maintaing an old Angular 11 project that uses tslint. I have now migrated every dependency to angular 18 and everything works fine. The last thing is to migrate from tslint to eslint using this ...
1
vote
2
answers
366
views
ng2-smart-table does not support angular 17.3.8 version?
I am upgrading angular cli version from 11 to version 17.x.x when I tried upgrading packages ng2-smart-table and tslint-language-service packages doesn't support angular version 17.It's stating to ...
0
votes
0
answers
37
views
Prettier and eslint / tslint plugins turn off randomly
I have Intellij IDEA 2023.2.3, and I usually use prettier, eslint/tslint on automatic mode, and we have .eslintrc, .prettierrc.json, and tsconfig.json files in our root directory that intellij should ...
0
votes
1
answer
100
views
ES/TS Linting rule to check if i'm not iffing an array instead of array.length >= 1?
I've noticed a common mistake I make where I have a set of different ifs and some of them are strings or booleans, but some of them are an array.
But sometimes I forget it will always be defined and I ...
0
votes
1
answer
39
views
UseEffect cleanup in socket.io-client
useEffect(() => {
if (authUser) {
const socket = io("http://localhost:5000", {
query: {
userId: authUser._id,
},
});
setSocket(socket);
socket.on(&...
1
vote
0
answers
52
views
Is there a way to lint event listener types in JS/TS?
I use eslint and tslint to help me avoid silly mistakes.
However, today, I made a mistake when declaring an event listener to catch uncaught promise rejections:
window.addEventListener('...
3
votes
4
answers
364
views
Node / Typescript / tslint errors on optional chaining operator (?.) in node_modules folder
I have a node script which runs fine on node version up to 17:
$ nvm use 17
Now using node v17.9.1 (npm v8.11.0)
$ cd src
$ npx tsc
$ npx node parser.js
$ cd ..
Beginning with node version 18 it ...
0
votes
0
answers
293
views
Found no valid, enabled rules for this file type and file path in the resolved configuration
There is gitlab runner pipeline for code-verification which is using script tslint **/**/*.ts -t json -o report.json || true. I have migrated my angular project from version 12 to 15, tslint to eslint ...
4
votes
1
answer
2k
views
error attempting to use convert-tslint-to-eslint
The first step
ng add @angular-eslint/schematics
executes successfully but the second step
ng g @angular-eslint/schematics:convert-tslint-to-eslint
produces this error:
Error: The `...
1
vote
1
answer
235
views
Type inference not working on reference parameter of React.forwardRef()
I am trying to utilize React.forwardRef() and I'm scratching my head over the following issue:
It appears that IntelliJ is able to correctly interfer the type of the reference, which is FilterRef in ...
1
vote
1
answer
661
views
Angular 15: error "subscribe is deprecated" still present after changes
I use Webstorm editor and I work with Angular 15.
I get the following message for subscribe function : "Deprecated symbol used"
I found this post and on the rxjs site that the method has ...
1
vote
1
answer
228
views
TS Lint rule to disallow multiple paramters of the same type
Is there any sort of linter that supports a rule that would disallow the following:
function testFn(a: string, b: string)
but would allow:
function testFn(a: number, b: string)
I've seen that eslint ...
9
votes
0
answers
350
views
Illegal options by deploying firebase functions
I got an error when deploying firebase functions in GitLab.
I understand that package.json and firebase.json has to have Unix EOL, which I converted with Notepad++, however that didn't solve any ...
0
votes
1
answer
231
views
Migration from v12 to v16: TS errors in template
I would to migrate a big app from Angular 12 to Angular 16. The app is made through Ionic (also migrated from 5 to 7).
To do this, I performed a migration of:
TSlint to ESlint
Typescript 4.3 to 5.0
...
1
vote
0
answers
795
views
TypeScript - deprecation warning 'createNodeArray'
I am currently updating an Angular project to the newest stable version (Angular V16). While doing that I have to uptade the "typescript" version as well. If I update the ts version to 5.x.x ...
0
votes
1
answer
236
views
Typescript React component type inference
I am having some issue finding a way to achieve what I need to do with TS in a React monorepo.
The structure is kind of classic:
...repo related stuff
packages /
package-a
package-b
...
1
vote
1
answer
175
views
Convert Gulp-TSLint to Gulp-ESLint
I have a Gulp task that needs updating from gulp-tslint to gulp-eslint as outlined below
const { src } = require('gulp');
const config = require('./config');
const plugins = require('gulp-load-...
0
votes
1
answer
228
views
Getting rid of unknown in TypeScript casting
I wrote the below code.
const incompleteKYCClaims = completedProvidersWithoutStripeAccount.map( async (p) => {
const provider = await getProviderOrThrow(p.tin)
const isPreviouslyApproved =...
2
votes
0
answers
639
views
TypeError: Cannot read properties of null (reading 'flags')
I am facing an error with Angular 15.2.9 version:
TypeError: Cannot read properties of null (reading 'flags')
ng v:
I tried all the answers which are for Angular 9, but no luck.
karma.conf.js
// ...
5
votes
0
answers
355
views
Vscode shows linting problems from node_modules folder in Problems tab
This happened after I disabled all my extensions, and restarted vscode, but as far as I remember the default ignored folder settings should be used to exclude the folder from showing up in the ...
0
votes
1
answer
390
views
How to add tslint-disable and prettier-ignore both for a single line
How can I disable tslint/eslint and ignore the prettier for a single line, both rules at the same line?
I want to align all the properties of the object using vscode plugin but prettier reformats it ...
3
votes
1
answer
999
views
Angular -> tslint Error, Definition of Rule jsdoc/newline-after-description
if i run my tslint - i get this error. how can i fix it?
1:1 error Definition for rule 'jsdoc/newline-after-description' was not found jsdoc/newline-after-description
my Version is: "eslint-...
0
votes
2
answers
39
views
tslint-disable comment in method chains
I am populating an Array and using it to map onto a sequence of React components
return (
<div className={style}>
<Header title="INVENTORY" />
...
0
votes
1
answer
37
views
Unable to type function to retrieve values from nested objects using array values
// nested object
const obj = {
one: {
two: {
three: 'xxxx',
},
four: {
five: 5,
},
six: [1, 2, 3],
},
}
I want to get a value from the above nested object using ...
0
votes
1
answer
94
views
Accidentally allowed IntelliJ to install new typescript plugin and after that typescript hints and eslint stopped working on Mac
Accidentally allowed IntelliJ to install new typescript plugin and after that typescript hints and tslint stopped working on Mac. Cannot find out what the plugin was. Would like to uninstall it.
Here'...
0
votes
1
answer
393
views
Typescript Object is possibly null though it has initial value
1: let a: Record<string, any> | null = {};
2: a['b'] = 2;
On Row 2, I am getting TS2531: Object is possibly 'null' error, though it has initial value.
So, I had to change above code like ...
0
votes
0
answers
59
views
Trying to migrate from tslint to eslint in angular@13. Getting lots of dependency errors
enter image description here
I've tried to run "npm i" after cleaning the cache. but not working. Is there anything i'm missing?
Do i need to update the version of the @angular/cdk or flex-...
0
votes
1
answer
500
views
How do I run tslint against a single file?
I'm using Angular 14. I have set up a rule in tslint to warn about unused imports, and I can fix this across my project by running
> tslint --config tslint-imports.json --fix --project .
However, ...
-1
votes
1
answer
471
views
How to turn off eslint rule?
How do you turn off an eslint rule, for example no-inferrable-types which comes from the extension "eslint:recommended"?
For example if my .eslintrc.json contains:
"extends": [
...
1
vote
0
answers
231
views
the file does not match your project config: src\index.html
I am trying to upgrade TSLint to ESLint but having below error:
0:0 error Parsing error: "parserOptions.project" has been set for
@typescript-eslint/parser. The file does not match your ...
4
votes
3
answers
619
views
Why TypesScript allows an invalid comparison - boolean === undefined?
Faced with the strange behavior of TS.
const isItLanding = false;
if (isItLanding === undefined) { // valid
return ...;
}
But here
const isItLanding = 1;
if (isItLanding === 'undefined') { // ...
0
votes
1
answer
579
views
How to update dependent package version
I am working on an Angular 10 project. And as part of the internal audit, I was asked to update the version of minimatch to 3.0.5. I checked my package.json, and I couldn't find the same. But after ...
3
votes
2
answers
809
views
TSLint: non-arrow functions are forbidden
I'm using typescript, yarn, react. I want to use non-arrow functions in some places of my app like this
function myFunction () {
console.log('This is a traditional function')
}
and my TSLint will ...
2
votes
1
answer
775
views
How to access nullable typescript nested type
I want to extract a nested type like in the code below. Is there a way to do that for a nullable field?
type Query = { a: { b?: { c: string } };
type c = Query['a']['b']['c'];
Property 'c' does not ...
1
vote
1
answer
24
views
Typing an any of an any in TypeScript? Parameter 'tag' implicitly has an 'any' type
I have the following code:
export const getTagsByType = (type: string, rawData: any) => {
if (rawData.keywords?.tags){
return rawData.keywords?.tags.filter(tag => tag.type === type);
}
...
0
votes
1
answer
317
views
TSLint Error "Exceeds maximum line length of 250"
TS lint gives me error TSLint Error "Exceeds maximum line length of 250 and for that reason m pipeline is failing on gitlab. I searched for this problem on google and every answer I got was for ...
0
votes
1
answer
202
views
How to get proper linting from commandline for vscode?
Have searched far and wide and found numerous articles, videos etc. tangent to what I look for, but never a perfect solution.
My main question is how to get proper linting (like the one that's inbuilt ...
-1
votes
1
answer
240
views
How to configure tsline in settings.json?
I am using visual studio code
When i search for settings.json file it looks like this
{
"liveServer.settings.donotVerifyTags": true,
"liveServer.settings.donotShowInfoMsg": ...
0
votes
0
answers
65
views
How to catch undefined after conditional?
Consider following example:
function myFunc (b: number): string {
let a: { c: any }
if (b < 20) a = { c: 100 }
console.log(a.c) // depending on 'b' this may throw error
return 'ok'
}
I ...
1
vote
0
answers
630
views
How can I remove parserOptions.project from an Angular MPA without running into "You have used a rule which requires parserServices to be generated"
I'm migrating my angular project's TSLint to ESLing and just as predicted by VS Code's guide, keeping parserOptions.project attribute causes linting to take significant time and memory to run. ...
0
votes
0
answers
34
views
no compilation errors when calling this.method inside callback
durring refactoring I encountered problem with no compilation errors when calling method using this binding in callback function
sample (simplified) code:
private test(flag:boolean){
console.log(...
0
votes
0
answers
101
views
How to use npx tslint?
How to use npx tslint?
npx tslint -c ./tsconfig.json "src/**/*.ts?(x)"
Tried to lint src/service/blah.ts but found no valid, enabled rules for this file type and file path in the resolved ...
1
vote
1
answer
154
views
object-literal-sort-keys needs type info to use "match-declaration-order" or "match-declaration-order-only"
In my tslint.json I have object-literal-sort-keys defined as match-declaration-order:
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
]...
1
vote
1
answer
225
views
Skip tslint alert in angular
I have a tslint alert that I want to skip, but as you can see in the image, I use a lot of flags and don't works
I also try to exclude the folder in the tslint conf but also don't works.
The message ...
1
vote
1
answer
2k
views
TSLint errors when trying to use newest version of ant design
I am getting the following typescrit/tslint erros when trying to use version 4.21.7 of ant design within my Power BI custom visual:
ERROR in /node_modules/antd/lib/input/Input.d.ts
[tsl] ERROR in /...
3
votes
1
answer
13k
views
ERROR Unexpected aliasing of 'this' to local variable @typescript-eslint/no-this-alias
How do I solve this typescript error?
I'm getting error in the below line.
const self = this;
I'm getting error in the terminal like:
error Unexpected aliasing of 'this' to local variable @...
4
votes
1
answer
9k
views
How do I disable TSLint Rule: This rule requires the `strictNullChecks` compiler option to be turned on to function correctly
I am in the middle of upgrading our app and I'm getting the following error when i try to build my angular app:
This rule requires the strictNullChecks compiler option to be turned on to function ...
1
vote
0
answers
1k
views
Typescript lint-fix command not working after checking for typescript lint issues? Need to know a workaround or a fix
When I check for issues with linting in typescript code by running npm run lint it gives out the linting issues but when I try fixing the issues using npm run lint:fix, it gives out an error stating:
...
0
votes
1
answer
747
views
Tslint to ESLint Migration Error : unknown option '--remove-tslint-if-no-more-tslint-targets'
I am using the below option to convert from TSLint to ESLint on Angular 11 and getting the below error
ng g @angular-eslint/schematics:convert-tslint-to-eslint --remove-tslint-if-no-more-tslint-...