Upon enabling the plugin:@typescript-eslint/recommended-requiring-type-checking, a notification appears indicating that the file is not listed in the tsconfig

When starting a new project, I typically use the following command:

npx create-react-app my-app --template typescript 

After adding TypeScript type checking to my project, I encountered an error in my App.tsx file:

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/../../../../my-app-ts/src/App.tsx` using `parserOptions.project`: <tsconfigRootDir>/tsconfig .json
However, that TSConfig does not include this file. To resolve this issue, you can:
- Modify ESLint's list of included files
- Update the TSConfig file to include this specific file
- Create a new TSConfig and include it in your parserOptions.project
For more information, refer to the TypeScript ESLint docs: https://typescript-eslint.io/docs/linting/troubleshooting##i-get-errors-telling-me-eslint-was-configured-to-run--however-that -tsconfig-does-not--none-of-those-tsconfigs-include-this-fileeslint

The contents of my .eslintrc.js file are as follows:

module.exports = {
  extends: [
    "react-app",
    "react-app/jest",
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
  ],
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: "./tsconfig.json",
  },
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint"],
  root: true,
};

This is the content of my tsconfig.json file:

{
  "baseUrl": ".",
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src/**/*.tsx",
    "src/**/*.ts"
  ]
}

My directory structure looks like this:

/mnt/data0/work/my-app-ts
├── README.md
├── package.json
├── public
|  ├── favicon.ico
|  ├── index.html
|  ├── logo192.png
|  ├── logo512.png
|  ├── manifest.json
|  └── robots.txt
├── src
|  ├── App.css
|  ├── App.test.tsx
|  ├── App.tsx
|  ├── index.css
|  ├── index.tsx
|  ├── logo.svg
|  ├── react-app-env.d.ts
|  ├── reportWebVitals.ts
|  └── setupTests.ts
├── tsconfig.json
└── yarn.lock

Although src/App.tsx is included in the scope, I am still facing issues. If you have any suggestions or solutions, please feel free to reply. Any help would be highly appreciated.

Answer №1

Here are the likely solutions to your issue:

  • Ensure all @typescript-eslint/* packages are updated to version >=6.x
  • Change parserOptions.project from "./tsconfig.json" to true
  • Verify that every package being linted has a corresponding ESLint config and TSConfig in its package.json
  • Confirm that your TSConfig files have compilerOptions.jsx enabled and can include src/*.tsx files

The first two suggestions address improvements made in later versions of @typescript-eslint/parser, while incorporating project: true enhances TSConfig lookup functionality.

The last two points explain why this error may occur when TypeScript doesn't recognize a file as needing inclusion. This could be due to JSX file recognition settings or incorrect values like

"exclude": ["src"]
or
"include": ["some-typo"]
.

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

"Combining the power of Next.js with a hybrid single-page

My current challenge involves a public section that requires server-side rendering (SSR) for SEO purposes. However, there is also an application within the website where SEO is not a priority and a single-page application (SPA) would be more suitable. I am ...

Differences between POST and GET in relation to submitting a form to an action page and retrieving the results

I am currently exploring a new website and came across a form with an action that redirects to a different page upon submission. Upon submitting the form using the post method on the website itself, it successfully sends the data and loads information fro ...

JavaScript Stub Pusher (Event)

I rely on pusher for handling my sockets and events. The pusher channels I use are encapsulated within an object that is passed as a key/value pair to the child component. The actual channel is accessed through this.channel.value, while this.channel.key s ...

Determine the SVG arc connecting two given points

My situation involves having coordinates for points X and A, A',... as follows: X [x,y] (starting point) A [a,b], A'[a',b'], etc. (ending points) I also have information about angles XCA, XCA', etc. However, I am struggling t ...

What is the best way to move between websites or pages without having to reload the current page using a selector?

Have you ever wondered how to create a webpage where users can navigate to other websites or pages without seeing their address, simply by selecting from a drop-down menu? Take a look at this example. Another similar example can be found here. When visit ...

Ways to transfer textfield input from HTML to servlet without the use of forms

I am currently developing an e-commerce website and I want to offer users the option to select a different shipping address: Shipping Details <input type="button" value="Same as billing address" style="color: #FFFFFF;" class="link-sty ...

Can we use an open-ended peer version dependency in package.json?

Question Summary Is it necessary for me to specify the peer dependency of @angular/core in my package.json file for a package containing easing functions that work with any version of Angular? "peerDependencies": { "@angular/core": "x.x" } Context I ...

The initialization of a static member in a JS class occurs prior to the loading of the cdn

After declaring this class member, I encountered the issue stating that MenuItem is not defined. It appears that the class initialization occurs before React or Material-UI finishes loading (I am currently loading them from their CDN using straight < ...

Leveraging React Hooks' useEffect to trigger a prop callback function defined with useCallback

Currently, I am working on developing a versatile infinite scrolling feature using React Hooks along with the ResearchGate React Intersection Observer. The main concept revolves around a parent passing down a mapped JSX array of data and a callback functio ...

Creating double the mesh in THREE.js by utilizing identical vectors as their position coordinates

Recently, I upgraded from r67 to r69 in ThreeJS and now facing issues with referencing the positions of objects to a single vector. Prior to the update, this code snippet worked fine: var vector = new THREE.Vector3(50, 50, 50); _Mesh1.position = vector; ...

What is the best way to run multiple functions from an object?

My goal is to call all the functions that are contained within an object. const data = { fruits: funcA(), vegetables: funcB(), bread: funcC(), } The desired result looks like this: firstFunc(); dispatch(funcA()); dispatch(funcB()); dispatch(funcC() ...

The injector is currently updating the initial value in the test

I am currently testing one of my injectable components by using a provider to assign a mock value to APP_CONFIG. Here is the structure of the component: export let APP_CONFIG = new InjectionToken<any>('app.config'); @Injectable() export cl ...

I'm struggling to find the right method to display a refreshed page with the updated JSON data

I am struggling to pinpoint where my mistake lies. My journey with node.js is just beginning, and I have immersed myself in learning as much as possible. The process has been quite rushed due to the fast-paced nature of this summer class. I acknowledge tha ...

leveraging properties to extract data from a dataset

I've been attempting to construct a table using props and then pass the value from that table to another function. However, I am facing an issue where the result is not being displayed. Can you pinpoint what I might have done incorrectly? import Table ...

Transform an array of objects into a new array using mapping

I am seeking assistance with the code snippet below that I have used in my app component to build dynamic form fields: const [basics, updateBasics] = useState({ controls: { name: { elementType: "input", elementConfig: { ...

Is it necessary for the version of the @types packages in TypeScript to match their non-types packages?

Are @types and untyped packages versioned the same way? npm i bluebird @types/bluebird -S returns "@types/bluebird": "^3.5.0", "bluebird": "^3.5.0", This seems logical. npm i request @types/request -S yields "@types/request": "0.0.41", "request": "^2. ...

Exploring D3.js version 4: Implementing a zoom button alongside the traditional wheelmouse zoom functionality

This question pertains to the same topic as a previously asked and answered one: D3.js - how to add zoom button with the default wheelmouse zoom behavior I have attempted to implement the code found in this link http://bl.ocks.org/linssen/7352810. The ...

Guide on how to use a JavaScript AJAX call to download a text file in Java

I am looking to implement a way to download a text file (e.g. 'something.txt') using an AJAX call rather than just an anchor tag in HTML. Here is the HTML code: <body> <a href="#" id="exportViewRule">Export</a> </body&g ...

Will the script src onclick change have an effect after the page is fully loaded?

Imagine you have a script that loads right away when a page loads. Now, what happens if the script src changes when you click on a button? Will the new src get executed? Here is some example code: <button> click </button> <script class=" ...

Ensuring Secure API Request Distribution

Currently, I am experimenting with distributed API requests. In PHP, I am developing a website that allows users to make requests on behalf of the server. The objective is to distribute these requests among users to maintain scalability even in high-traffi ...