Skip to content

Flag path-like codes in diagnosticFilters - #1753

Merged
TwitchBronBron merged 4 commits into
rokucommunity:v1from
markwpearce:markp/1384-flag-path-like-diagnostic-codes
Aug 28, 2026
Merged

Flag path-like codes in diagnosticFilters#1753
TwitchBronBron merged 4 commits into
rokucommunity:v1from
markwpearce:markp/1384-flag-path-like-diagnostic-codes

Conversation

@markwpearce

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new diagnostic that warns when a v1-style diagnosticFilters entry 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, where diagnosticFilters entries were file globs.
  • Skipped when diagnosticFiltersV0Compatibility is enabled, since those filters are legitimately file globs.

Closes #1384

Test plan

  • Added unit tests for DiagnosticFilterer.getPathLikeDiagnosticFilterCodes
  • Added an integration test in Program.spec.ts verifying the diagnostic is emitted/not emitted during program.validate()
  • npm run build, npm run lint, and npm run test:nocover all pass

🤖 Generated with Claude Code

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>
@markwpearce markwpearce added this to the v1.0.0 milestone Jul 21, 2026
Comment thread src/DiagnosticFilterer.ts
}
const lowerValue = value.toLowerCase();
return (
value.includes('./') ||

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about windows? .\

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed. isCodeValuePathLike now also checks for the Windows-style .\\ relative-path separator in addition to ./.

Comment thread src/DiagnosticManager.ts Outdated
* 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@markwpearce
markwpearce force-pushed the markp/1384-flag-path-like-diagnostic-codes branch from 1a68537 to 66c76cc Compare August 26, 2026 14:54
@TwitchBronBron
TwitchBronBron merged commit 20eab35 into rokucommunity:v1 Aug 28, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants