I am using the ESLint plugin by Dirk Baeumer in Visual Studio Code.
My project is large and complex and divided into several primary directories. Each directory has its own package.json file, its own node_modules directory and its own version of eslint. This is causing havoc after upgrading to ESLint 6 because my ESLint plugins won't resolve.
How do I configure the ESLint plugin to respect the eslint version used in each directory? I think it has something to do with the eslint.workingDirectories setting, but I don't understand how to use it properly.
Further information:
My project workspace has two root directories, "folder1" and "folder2". The directory structure looks something like this:
folder1
.eslintrc.json -- rules for the entire "folder1" project to follow
build
platform
core
Makefile
core-v1
.eslintrc.json
Makefile
package.json -- eslint v4
node_modules
core-v2
.eslintrc.json
Makefile
package.json -- eslint v6
node_modules
folder2
My workspace configuration file includes:
"eslint.workingDirectories": [
"./folder1/core/core-v1",
"./folder1/core/core-v2"
]
This seems to produce the following error, and no linting errors are detected or highlighted:
Uncaught exception received.
Error: spawn /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper (Renderer).app/Contents/MacOS/Code - Insiders Helper (Renderer) ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
How do I configure the ESLint plugin to use eslint v4 for files in "folder1/core/core-v1" and v6 for files in "folder1/core/core-v2"? My build process runs separate scripts for these directories, but my editor (VS Code) is trying to use a either v4 or v6 to lint all of the files in my project.
First off, the working directories cannot include root folder names:
"eslint.workingDirectories": [
"./core/core-v1",
"./core/core-v2"
]
This seems to correctly identify the working directories and allows version 6 of ESLint to correctly resolve plugins, etc. It also applies v6 rules to core-v2 but still seems to be using the v4 rules for core-v1, so I think this is correct.
One issue that is still not resolve completely is how this works with multi-root workspaces. This works fine for folder1. folder2 just seems to be working, though I can't explain why since it's not identified as a working directory. Thankfully there are no conflicting paths, but what would I do if there were? That may be worth a separate question, but I seem to be up and running now.
Related
When working on a Tauri project in VSCode, I get the following error message from the rust-analyzer plugin.
rust-analyzer failed to discover workspace
I know that the cause of the problem is that I loaded the Tauri project as my workspace in VSCode which does not have a Cargo.toml in its project root, but in the Rust-related sub-directory src-tauri. Is there a way I can tell the plugin that it should refer to this sub-directory src-tauri for the Cargo.toml? The workaround is to switch the workspace to src-tauri every time I touch the Rust code, which is quite inconvenient.
You can use the rust-analyzer.linkedProjects setting in VSCode. It takes a list of paths pointing to Cargo.toml files.
Try adding this to your settings.json:
"rust-analyzer.linkedProjects": [
"src-tauri/Cargo.toml",
],
I am trying to use clangd for code completion within vscode. I am using CMake for the project setup and I am creating a compilation database. However, I have several build directories with different flags (Debug, Release...) and clangd requires to have the compilation database in the source directory. This is not possible, since compilation databases for each build type are different...
Is there any way to use clangd when you have multiple build types?
I solved this my using a VSCode cmake tools feature.
in the settings of my workspace I added
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json"
This copies the compile_commands.json of the build dir to workspace folder, which in my case happens to be where clangd is looking for the compile_commands.json file.
If I change the preset, the new compile_commands.json from the new is copied again so the clangd model is updated.
I typically solve this by symlinking one compilation database into the source directory. Which one depends on what I do - mostly it is the one for the "standard" build I use most often. There are other specialized builds, but I only switch to the corresponding compdb if I really need the different settings.
I have an angular project open in VSCode, but whenever I activate certain file tabs it hides every file & folder inside my src/ directory!
Here's a screen recording of what happens: https://imgur.com/kQrIUdQ
No other folders are affected, and nothing is actually chnaged in the src/ folder. I can seect a *.ts file, close VSCode, and then re-open it with that *.ts file active and the folder contents shows again until I activate a tab that does this again.
This is extremely annoying and I've never seen this happen before. let me know if you need any other information to help diagnose this issue.
Edit: My installed extensions are as follows:
Angular Language Service 0.1.11
AutoHotkey 0.2.2
C# 1.18.0
Code Spell Checker v1.6.10
Hosts Language v1.1.1
npm v0.3.5
npm Intellisense v1.3.0
Prettify JSON v0.0.3
stylelint v0.48.0
TSLint v1.0.0
From the documentation https://code.visualstudio.com/docs/editor/tasks it hints that Visual Code will autodetect various project tasks such as gulp, grunt and npm. However it is not clear whether or not Visual Code will detect task.json files nested inside a project.
Currently, I can only define the task.json file in .vscode/ which is not distributed within the repository. Is there a way to include project specific task.json files outside of .vscode?
I'm porting two AS3 projects to TS using Visual Studio Code.
The second project uses code from the first project's folders.
I wonder if it is possible to specify additional source folders outside the main source folder in Visual Studio Code, like in the old good FlashBuilder.
For example:
Main source folder: "src"
Additional folders: ["../previous_project/src", "../previous_project/libs"]
This way I can use or extend classes from the external projects like if they were saved in the main source folder.
Investigating a bit I've found that the 'Insiders' version of Visual Studio Code have something called 'multi-root workspaces'. I made some experiment with it, but I must be doing something wrong: When compiling, I get:
"error TS6059: File is not under 'rootDir'.
'rootDir' is expected to contain all source files."
So, how do I specify additional source folders in Visual Studio Code?
After playing a bit more with workspaces, it seems that commeting out "rootDir" in tsconfig.json removes 'error TS6059'. Now I can compile with no issues.
It would be good to see a correct example of multi-root workspaces, though.