visual-studio-code

Is it possible to exclude folders from the problems tab in VS code


I have a problem with a file that causes the problems tab to EXPLODE with warnings, and the reason is that I only use that file inside of another "main" file, which means that instead of creating a variable in every single one of the files that I use, I only create it in the "main" one, but VScode has no idea about that, so it trashes my problems tab with errors of missing variables.

So I just thought if it was possible to exclude the folder with problematic files from the problems tab or if there is any other way to avoid the warning diarrhea.

And although I did see somewhere unrelated to this that it is possible to use .json files or something to control VScode, I know nothing about it


Solution

  • You may have to try a language specific solution. As far as September 2023, and as far as I was able to research, there is NOT a VSCode solution for this.

    In Dart, you may use in your workspace file;

    Create the flutter.code-workspace file at project's root, outside of .vscode folder, with content:

    {
        "folders": [
            {
                "path": "."
            },
            // OTHER PATHS
        ],
        "settings": {
            "problems.decorations.enabled": false,
            "dart.analysisExcludedFolders": [
                "C:/Users/carlo/repos/_practice/flutter/cinemapedia/lib/config", // It takes everything inside the folder.
                "C:/Users/carlo/repos/_practice/flutter/cinemapedia/lib/main.dart", // As far as I was able to find out, it does not work in files where the error is originated in subordinated files (in the case of imported classes, for example).
                "" // It takes everything at the workspace level.
            ]
        },
    }
    

    Other language, may have options similar to "dart.analysisExcludedFolders" (Dart docs). Here's a gif displaying the proposed workaround:

    enter image description here

    Hopefully, other languages allow to target files with higher accuracy.