Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code React not showing error even after adding jsconfig

So I am building a REACT JS project, and after a while I noticed that it doesn't underline undefined functions nor wrong imports, for example if I does that:

import React, { useState } from 'reactaeasdfas';

it wont say that reactaeasdfas is undefined.

After a bit of searching I found that people say that jsconfig.json should be initialized.

I found a basic one on the internet:

{
    "compilerOptions": {
      "module": "commonjs",
      "target": "es6",
      "jsx": "react"
    },
    "include": [
        "src"
    ]
}

This code above does solve the problem that if I call an undefined function, it will underline it in red, but it still doesn't work if I include undefined import.

Note: I installed react project via create-react-app

like image 577
Dorki Avatar asked Nov 15 '22 13:11

Dorki


1 Answers

Install the ESLint extension for Visual Studio Code - https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

More details:

A standard create-react-app package is already using ESLint, so you shouldn't need to make any changes to the app. However, your editor needs to be set up to work with ESLint. For VS Code this is done by installing an extension/plugin. The CRA documentation has more information about setting up editors - https://create-react-app.dev/docs/setting-up-your-editor/

like image 176
FiveOFive Avatar answered May 25 '23 21:05

FiveOFive