Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Diagnostic Filters and adds human-readable diagnostic names #1241

Open
wants to merge 16 commits into
base: release-1.0.0
Choose a base branch
from

Conversation

markwpearce
Copy link
Collaborator

@markwpearce markwpearce commented Jun 28, 2024

Addresses #1060

  • Changes the structure of bsconfig.json "diagnosticFilters" option to look like this:
Array<string | number | { files?: string | Array<string | { src: string } | { dest: string }>; codes?: Array<number | string> }>;

In more detail:

{
"diagnosticFilters": [
    123,   // numbers are applied to diagnostic code or legacyCode against all files
    "some-diagnostic-name", // strings are applied to diagnostic code (or legacyCode) against all files
    { "codes": ["code-1", "code-2"]}, // an object is allowed with a list of codes to applied against all files
    { "files": "some/glob/**" }, // a file list will suppress all diagnostics in matched files
    { "files": "other/glob/**", "codes": ["some-code"]}, //suppress specific codes in matched files
    { "files": [              //files can be an array of globs
            "other/glob/**",
            "other2/glob/**"
       ],
       "codes": ["some-code"]
    },
    { "files": [{ "src": "yet/another/glob/**"}] }, //file listings in an array can be a object that references src path
    { "files": [{ "dest": "yet/another/glob/**"}] } //file listings in an array can be a object that references dest path
]}

Additionally, I went through all the diagnostics and assigned a human-readable code property to them, which can also be used for any diagnostic filtering. The previous (numerical) code property was renamed to legacyCode

@markwpearce markwpearce added this to the v1.0.0 milestone Jun 28, 2024
@markwpearce markwpearce changed the base branch from master to release-1.0.0 June 28, 2024 13:51
@markwpearce
Copy link
Collaborator Author

@josephjunker Please take a look at this PR -- you did a lot of work on DiagnosticFiltering and I hope that's respected here.

@josephjunker
Copy link
Collaborator

@markwpearce Looks good to me!

Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

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

I did an initial pass of this and have some suggestions. I still need to go through every diagnostic code and tweak their names, that'll come later.

docs/bsconfig.md Outdated Show resolved Hide resolved
docs/bsconfig.md Outdated Show resolved Hide resolved
docs/bsconfig.md Outdated Show resolved Hide resolved
docs/bsconfig.md Outdated Show resolved Hide resolved
docs/bsconfig.md Outdated Show resolved Hide resolved
docs/bsconfig.md Outdated Show resolved Hide resolved
src/DiagnosticMessages.spec.ts Show resolved Hide resolved
markwpearce and others added 3 commits July 12, 2024 14:12
Co-authored-by: Bronley Plumb <bronley@gmail.com>
Co-authored-by: Bronley Plumb <bronley@gmail.com>
Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

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

We've only made it through diagnostic code 1063. Figure I'll submit what I have awhile, and keep working.

src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
severity: DiagnosticSeverity.Error
legacyCode: 1053,
severity: DiagnosticSeverity.Error,
code: 'expected-expression-for-each'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
code: 'expected-expression-for-each'
code: 'missing-loop-expression'

Some devs may struggle undrestanding what expression means, perhpas mixing it up with binaryExpression from for loop. Is there a better name?

severity: DiagnosticSeverity.Error
legacyCode: 1054,
severity: DiagnosticSeverity.Error,
code: 'unexpected-colon-before-if'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
code: 'unexpected-colon-before-if'
code: 'unexpected-leading-colon'

We can expand this messaging/diagnostic in the future to more things that do this.

src/DiagnosticMessages.ts Show resolved Hide resolved
severity: DiagnosticSeverity.Error
legacyCode: 1058,
severity: DiagnosticSeverity.Error,
code: 'expected-terminator-on-then'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
code: 'expected-terminator-on-then'
code: 'missing-if-terminator'

Let's consider merging all "missing terminator" into a single diagnostic. Something like missing-statement-terminator. That would aply to namespaces, enums, classes, constants, if statements, etc etc. Then parameterize the message so each message makes sense.

Several of the if statement diagnostics below would also apply.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like this idea.

severity: DiagnosticSeverity.Error
legacyCode: 1061,
severity: DiagnosticSeverity.Error,
code: 'expected-statement-after-conditional'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe merge a few of these together, parameterize the message a bit.

markwpearce and others added 5 commits July 20, 2024 09:25
Co-authored-by: Bronley Plumb <bronley@gmail.com>
Co-authored-by: Bronley Plumb <bronley@gmail.com>
Co-authored-by: Bronley Plumb <bronley@gmail.com>
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.

None yet

3 participants