Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After upgrade eslint says NodeJS is undefined

I have upgraded Eslint from 7.7.0 to 7.10.0 and @types/node from 14.6.0 to 14.11.2. The application tsconfig.json defines types: ["node"] and typescript is version 4.0.3. Eslint is called with eslint --env node,es2020.

Before the upgrade Eslint never flagged any problem in my code. Now Eslint started complaining that NodeJS is not defined in the following code fragment:

private handleServerErrors(error: NodeJS.ErrnoException): void {
    if(error.code === "EADDRINUSE") {
        . . .

I silence the Eslint error and the compilation succeeded. So seems a problem specific to eslint, not the code.

The same problem happens in another file for namespace JQuery, but I had not yet investigated.

Is there anything I'm missing? Need to add some import? What has changed in eslint/typescript/node?

Thanks for your help! mario

like image 612
SiliconValley Avatar asked Sep 27 '20 13:09

SiliconValley


People also ask

Does ESLint require node?

ESLint requires Node. js for installation. Follow the instructions in the Getting Started Guide to install ESLint. Note: You can also use alternative package managers such as Yarn or pnpm to run ESLint.

What is ESLint used for in node JS?

ESLint is a JavaScript and TypeScript linting tool, that means it analyses source code and identifies possible programming problems and errors. It underlines errors in red and warnings in yellow. It is very useful to cover coding styles issues.

Can ESLint lint TypeScript?

ESLint is a JavaScript linter that you can use to lint either TypeScript or JavaScript code.

What is TypeScript linting?

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.


1 Answers

In my case, @typescript-eslint/parser@4 causes this problem.

Downgrade it to v3 @typescript-eslint/parser@3 to solve the problem.

See: https://github.com/Chatie/eslint-config/issues/45

like image 159
Huan Avatar answered Oct 10 '22 11:10

Huan