Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create-react-app subfolder projects do not lint

Projects bootstrapped with create-react-app within subfolders do not lint. However, if I open the project subfolder as root in VSCode (pictured below), or setup a new create-react-app project at root, linting works fine.

enter image description here

This occurs with both standard and ejected create-react-app projects.

Ideally without ejecting, how can I make create-react-app's linting work with subfolder projects?

I'm using create-react-app v3.1.1, VSCode August 2019 and Windows 10.

like image 857
Chunky Chunk Avatar asked Sep 10 '19 23:09

Chunky Chunk


People also ask

Does create react app use ESLint?

Because Create React App comes with ESLint already integrated. They use their own sharable ESLint configuration and this can be found under the eslintConfig object in package.

Do you need to install ESLint With create react app?

Note, ESLint is installed with create-react-app, so you don't need to explicitly install it. Then install the packages for Airbnb config. This command will work for Yarn or NPM.

Does create react app create a folder?

Create a New React Project To create a new app/project using this tool, all we need to do is run the command "create-react-app" followed by the app name. After running the above command, a new folder called "my-sample-app" will get created and that would have all of our application code.


1 Answers

The VSCode ESLint Extension includes settings for specifying working directories:

an array for working directories to be used. ESLint resolves configuration files (e.g. eslintrc) relative to a working directory. This new settings allows users to control which working directory is used for which files.

Therefore, in this case, adding the following to the Workspace settings.json file solves the issue:

{
    "eslint.workingDirectories": [
        "./client"
    ]
}
like image 141
Chunky Chunk Avatar answered Oct 17 '22 07:10

Chunky Chunk