TypeScript errors undetected by ESlint

I am currently working on a nextJS app with typescript in VSCode. I've noticed that while VSCode accurately displays TS errors when I open a file with an error, the eslint doesn't seem to do the same.

For instance, here are the errors shown in my VSCode:

https://i.sstatic.net/C85Fc.png

But when it comes to linting results, this is what I get:

▶ yarn lint

yarn run v1.22.10
$ eslint .
(node:83388) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time
(node:83388) ExperimentalWarning: Package name self resolution is an experimental feature. This feature could change at any time
✨  Done in 5.26s.

Here are some key files that might help identify the issue:

.eslintrc.js:

module.exports = {
  plugins: [
    '@typescript-eslint',
  ],
  extends: [
    'airbnb-typescript',
    'airbnb/hooks',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  ignorePatterns: [
    'app.js',
    '.eslintrc.js',
    'jest.config.js',
    'babel.config.js',
    '/plugins',
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  rules: {
    'react/require-default-props': ['warn', { ignoreFunctionalComponents: true }],
  },
  overrides: [
    {
      files: ['*.spec.tsx', '*.stories.tsx'],
      rules: {
        'import/no-extraneous-dependencies': 'off',
      }
    }
  ]
};

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2016",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

bable.config.js:

const path = require('path');

module.exports = {
  presets: [
    [
      'next/babel',
      {
        'styled-jsx': {
          plugins: [path.join(__dirname, '/plugins/styled-jsx-plugin-sass.js')],
        }
      }
    ]
  ],
  plugins: ['inline-react-svg']
}

package.json scripts:

{
"scripts": {
    "preinstall": "npx only-allow npm",
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "storybook": "start-storybook -s ./public -p 6006",
    "build-storybook": "build-storybook",
    "lint": "eslint .",
    "test": "jest"
  },
}

If you need more details or information to help resolve this issue, please let me know. Thanks for your assistance!

Answer №1

Doing further investigation, I stumbled upon this particular github issue addressing the same issue: https://github.com/typescript-eslint/typescript-eslint/issues/352

The response provided in the discussion was as follows:

We intentionally overlook errors that may occur due to type checking errors. Our focus is solely on ensuring that the code is structurally correct (i.e. can be parsed without any issues), rather than its semantic correctness (i.e. disregarding whether it is type sound)

If you wish for your code to undergo typechecking - we recommend using tsc (or a similar tool tailored for your specific build process).

Therefore, the resolution in my scenario involved modifying my lint script to:

{
  "scripts": {
    "lint": "tsc --noEmit && eslint .",
  },
}

The addition of the --noEmit flag instructs the command to refrain from generating any output files.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

include the ReactToastify.css file in your project using the import statement

Error in file path C:\Users\User\Documents\GitHub\zampliasurveys_frontend\node_modules\react-toastify\dist\ReactToastify.css:1 ({"Object.":function(module,exports,require,__dirname,__filename,jest){:ro ...

Best Method for Confirming Deletion in Data Table with Shadow and UI

I have a query regarding the Shadcn/UI - Data Table component. In my case, I am working with a list of users where each row has a delete button in the last column. Upon clicking the delete button, a confirmation dialog pops up. Currently, I am implementi ...

Obtaining context from a higher order component in the constructor of a child component: tips and tricks

In order to gain access to context throughout the application, I've implemented the following context provider: import React, { Component, useContext } from 'react'; import { appInitialization, Context } from "@microsoft/teams-js"; ...

Encountering the error "Missing property '$$typeof' when trying to extend next/link in Next.js using TypeScript"

I have the following code snippet in my project: import NextLink from 'next/link' import ExternalLink from './External' type PropsType = typeof NextLink & { href: string children: React.ReactNode } export default function Link ...

Issues with Angular Reactive Forms Validation behaving strangely

Working on the login feature for my products-page using Angular 7 has presented some unexpected behavior. I want to show specific validation messages for different errors, such as displaying " must be a valid email " if the input is not a valid email addre ...

Step-by-step guide on implementing Form.create in TypeScript and Ant Design with function components

Having trouble compiling my form created using Form.create(). The error message I'm getting is: Argument of type 'FunctionComponent<MyProps>' is not assignable to parameter of type 'ComponentType<{}>'. Type 'Fu ...

Develop a custom function in Typescript that resolves and returns the values from multiple other functions

Is there a simple solution to my dilemma? I'm attempting to develop a function that gathers the outcomes of multiple functions into an array. TypeScript seems to be raising objections. How can I correctly modify this function? const func = (x:number, ...

Using a HOC property within a child component in Typescript is not allowed

Challenge A component I've wrapped with a common HOC used in previous projects is causing issues. I cannot access the HOC's prop currentBreakpoint within the wrapped component because it needs to be defined in the component's type: Propert ...

Creative Solution for Implementing a Type Parameter in a Generic

Within my codebase, there exists a crucial interface named DatabaseEngine. This interface utilizes a single type parameter known as ResultType. This particular type parameter serves as the interface for the query result dictated by the specific database dr ...

Angular is experiencing difficulty locating the routing path for the auxiliary `router-outlet`

Exploring the intricacies of routing in Angular to gain a deeper understanding of the concept. Encountering an issue where I am receiving an exception NG04002: Cannot match any routes. URL Segment: 'about' when attempting to click on the About li ...

Issue with login form in IONIC: Form only functions after page is refreshed

Encountering an issue with my Ionic login form where the submit button gets disabled due to invalid form even when it's not, or sometimes displays a console error stating form is invalid along with null inputs. This problem seems to have surfaced afte ...

"Encountering a 404 error while attempting to forward to an HTML

I've been encountering an issue while trying to transition from a JSX page to an HTML page. Every time I attempt to do so, I receive a 404 error stating that the page doesn't exist. It's puzzling because it is clearly present in my files and ...

What is the best way to set up Storybook.js Webpack to support absolute image paths within CSS modules for a Next.js project?

I'm currently setting up Storybook to integrate with Next.js, Ant Design, Less, and TypeScript. In Next.js, images need to be stored in the public/ directory and linked using absolute paths for universal usage within the project. I am facing challenge ...

How do EventEmitter<undefined> and EventEmitter<void> differ from each other?

At times, there may be a situation where we need to omit the generic variable. For example: @Component( ... ) class MyComponent { @Output() public cancel = new EventEmitter<undefined>(); private myFoo() { this.cancel.emit(); // no value ...

How can I set the default bindLabel for a dropdown in @ng-select/ng-select when the self change event occurs in Angular

I have a scenario where I need to set the default value to null in the ng-select. If the user selects an option from the dropdown first, then on the change event it should check if the Amount model is not null or blank. If the Amount model is blank, then ...

How can I retrieve routing parameters in a Vue.js/Nuxt/TypeScript app?

In the process of developing my website based on the Nuxt TypeScript Starter template, I've encountered a challenge. Specifically, I have created a dynamically routed page named _id.vue within my pages folder and am looking to access the id property i ...

What is the method to retrieve Response Headers in cases of an empty response?

Currently, I am working with Angular2 and dotcms. My goal is to retrieve response headers after making a call to subscribe. const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) .append('Access ...

How to access a static TypeScript variable in Node.js across different files

I encountered a situation like this while working on a node.js project: code-example.ts export class CodeExample { private static example: string = 'hello'; public static initialize() { CodeExample.example = 'modified'; } ...

Encountering an error message stating "The variable 'App' is declared but not used" when running the index.tsx function

This React project is my attempt to learn how to use a modal window. The tutorial I've been following on YouTube uses JavaScript instead of TypeScript for their React project. However, I'm facing some challenges. Could you possibly help me ident ...

Typescript Rest API requests are experiencing issues when made with vscode version 1.82.2

Whenever I try to make Rest API calls in Typescript, I encounter the following error: error code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' message: 'unable to get local issuer certificate' Our API Calls were functioning properly up until vs ...