It would be good if we could have file-based configuration, extending the mechanism implemented by [[diagnostic Support message based configuration]].
# 2025-11-22
Thinking about it again, it's pretty rare that we'd want to set severity just based on the file path. Usually, we'd want to set `severity` using patterns for `code` or `message` that apply to files. So, the following schema would probably be more useful than the one we discussed in [[#2025-11-20]]:
```toml
# Downgrade 'macro name not found' diagnostics to 'info' for files under `LSP/src/`
[[diagnostic.patterns]]
pattern = "Macro name `@namespace` not found"
match_by = "message"
match_type = "literal"
severity = "info"
path = "LSP/src/**/*.jl"
# Turn off all diagnostics for any file under `test`
[[diagnostic.patterns]]
pattern = "*"
match_by = "code"
match_type = "regex"
severity = "off"
path = "test/**/*.jl"
```
It would be handy to use glob patterns for path specification. For a glob implementation, we could use https://github.com/vtjnash/Glob.jl, but since it currently doesn't support globstar (`**`), we might want to check in a vendored version that implements globstar features into JETLS (see https://github.com/aviatesk/Glob.jl/tree/avi/globstar). `path` is an optional field and is represented as a `Maybe{Glob.FilenameMatch}` type in JETLS.
# 2025-11-20
~~We could extend the format of `diagnostic.patterns` and add `path` to `match_by` to allow configuration like this. (Maybe we should add `glob` to `match_type` since it's easier to specify than `regex`?)~~
```toml
[[diagnostic.patterns]]
pattern = "test/some_folder/**/*.jl`
match_by = "path"
match_type = "regex" # should be `glob`?
severity = "info"
```