Flag path-like codes in diagnosticFilters - #1753
Conversation
Warn when a v1-style diagnosticFilters entry looks like a file path or glob (contains `./`, `../`, `**`, or ends in `.bs`/`.brs`/`.xml`) instead of a diagnostic code, since that's a common leftover from migrating a v0-style config. Skipped when diagnosticFiltersV0Compatibility is enabled, since those filters are legitimately file globs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| } | ||
| const lowerValue = value.toLowerCase(); | ||
| return ( | ||
| value.includes('./') || |
There was a problem hiding this comment.
Good catch — fixed. isCodeValuePathLike now also checks for the Windows-style .\\ relative-path separator in addition to ./.
| * This is a common mistake when migrating a bsconfig.json from the v0-style filters (which were file globs) | ||
| */ | ||
| public detectPathLikeDiagnosticFilterCodes(config: FinalizedBsConfig, context?: DiagnosticContext) { | ||
| const pathLikeCodes = this.diagnosticFilterer.getPathLikeDiagnosticFilterCodes(config); |
There was a problem hiding this comment.
Might be worth checking to see if the pattern is exactly a path to a known file in the files array? like source/main.json or something?
There was a problem hiding this comment.
Done — getPathLikeDiagnosticFilterCodes/isCodeValuePathLike now accept an optional set of known project file destPaths, and DiagnosticManager passes through the destPaths of all files currently loaded in the program. A filter entry that exactly matches one of those (e.g. a bare source/main.json) is flagged even when it doesn't match the glob-like heuristics.
There was a problem hiding this comment.
Great. Did you push the changes? I'm not sure I'm seeing them.
- isCodeValuePathLike now also flags values containing the Windows-style `.\` relative-path separator (in addition to the existing `./` check). - getPathLikeDiagnosticFilterCodes/isCodeValuePathLike accept an optional set of known project file destPaths; a diagnosticFilters entry that exactly matches one of these is flagged even if it doesn't match the glob-like heuristics (e.g. a bare `source/main.json`). - DiagnosticManager.detectPathLikeDiagnosticFilterCodes now builds that known-destPaths set from the program's files and passes it through. Addresses review comments from @TwitchBronBron on PR rokucommunity#1753.
1a68537 to
66c76cc
Compare
Summary
diagnosticFiltersentry looks like a file path or glob (contains./,../,**, or ends in.bs/.brs/.xml) rather than a diagnostic code — a common mistake when migrating a v0-style bsconfig, wherediagnosticFiltersentries were file globs.diagnosticFiltersV0Compatibilityis enabled, since those filters are legitimately file globs.Closes #1384
Test plan
DiagnosticFilterer.getPathLikeDiagnosticFilterCodesProgram.spec.tsverifying the diagnostic is emitted/not emitted duringprogram.validate()npm run build,npm run lint, andnpm run test:nocoverall pass🤖 Generated with Claude Code