create-react-app subfolder projects do not lint

徘徊边缘 提交于 2020-04-13 06:49:13

问题


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.

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.


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


来源:https://stackoverflow.com/questions/57879267/create-react-app-subfolder-projects-do-not-lint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!