简体   繁体   中英

VSCode Eslint configuration for a two projects workspace

I have a folder with two projects, a Nodejs backend and a Vuejs frontend. I want to open both projects at the same time, and being able to use eslint to check and format code in both.

The problem I'm having is that whenever a get the configuration sort of working for the vue project, the js files in the backend are not validated.

My main question is if it is possible at all to do this or not. I've already followed countless tutorials on getting eslint+prettier+airbnb plus all of the relevant plugins working. Else, if is it better to open two instances of VSCode, one for the backend and another for the frontend, each with its own configuration.

Thanks !!!

Yes, you can get this working. You'll need to update your workspace settings.

https://medium.com/devityoself/monorepo-eslint-vscode-6f5982c8404d

For me, this was an issue with the VS Code ESLint extension when you have the app in a subfolder from the root. To solve it, I created a.vscode folder in the root with a file settings.json and this contents

{
  "eslint.workingDirectories": ["./app", "./another-app"]
}

This only works this way if you're using the VS Code "workspace" where you've started with an empty workspace and added directories to the workspace, so it's not a directory itself.

If you've loaded the parent folder using Code ~/parent-folder with a lot of subfolders for projects, and then you've got two folders inside those folders, you'll need to create the .vscode/settings.json in your parent folder, but then add in the folder path to the start, so

{
  "eslint.workingDirectories": ["./subfolder/app", "./subfolder/another-app"]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM