macabeus / vscode-fluent

💬 VS Code extension to work with Fluent, the correct-by-design l10n programming language
MIT License
36 stars 4 forks source link

Add a setting to exclude folders from the linter #30

Open aminomancer opened 1 year ago

aminomancer commented 1 year ago

The repo I spend most of my time on has this third party file with a whitespace error at the bottom. Fixing it isn't really practical since this mirrors some old code. So when I open the repo in vscode, that error automatically shows up in the Problems tab and in the status bar. Every folder on the path to the problematic file is also highlighted red in the Explorer tab. It's the status bar and Explorer thing that really bug me, since they always make me think there's an actionable problem I actually need to deal with.

Unfortunately, although vscode has a little filter input bar in the Problems tab which lets you exclude folders, that doesn't affect how folders containing the file with the error are displayed with red text color in the Explorer tab. And although the error is hidden in the Problems tab, it still shows up in the status bar, so that 1 error display is still present. So there doesn't seem to be any way to tell the extension or vscode to just ignore errors in that folder.

In microsoft/vscode#22289, Microsoft confirmed they would not fix this issue in vscode since they think extensions should handle the implementation. So my request is basically for a setting that accepts an array of folder globs that should not be linted. Thanks for the extension btw!

macabeus commented 1 year ago

Do you know how the other extensions handle it? It would be useful to at least have a good configuration naming for that.

aminomancer commented 1 year ago

Hmm, I guess there are 2 main approaches. Extensions for ESLint, for example, tend to just look for a .eslintignore file in the workspace, and may have a setting where you can specify the path to a fallback .eslintignore file. Same with Prettier and probably a variety of other extensions built on preexisting node/CLI linters.

That may be good enough for our purposes, because the linter we normally use in CI and development takes a configuration file with includes/excludes. But how the extension should search for it is another matter, since this config file is not in the project root folder, unlike the config files for other linters. Maybe the extension could search for the file up the tree but also add a workspace-scoped setting for a fallback path. And then we could just set it to tools/lint/l10n.yml within the workspace's .vscode/settings.json file.

Other extensions just register a setting that accepts an array of glob patterns or an object keyed by glob patterns. The closest example I could find is in the Python extension: ms-python.python:

"python.linting.ignorePatterns": [
  "**/site-packages/**/*.py",
  ".vscode/*.py"
]

There are some other similar settings from various extensions though: ms-vscode.cpptools:

"C_Cpp.codeAnalysis.exclude": {
  "**/node_modules": true
}

ms-python.vscode-pylance:

"python.analysis.exclude": [
  "**/node_modules"
]

vscode.typescript:

"typescript.preferences.autoImportFileExcludePatterns": [
  "**/node_modules"
]