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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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"
    ]
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x