Skip to content

Add lint groups to Q# #2103

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add lint groups to Q# #2103

wants to merge 10 commits into from

Conversation

orpuente-MS
Copy link
Contributor

@orpuente-MS orpuente-MS commented Jan 14, 2025

This PR adds the necessary infrastructure to define lint groups. It also adds the deprecation lint group, which allows the user to enable all deprecation lints at the same time, which are set to allow by default.

A lint group can be added to the qsharp.json manifest as follows:

{
   "lints": [
      { "group": "deprecations", "level": "warn" }
   ]
}

@minestarks
Copy link
Member

Should we update our qsharp.json schema? ( vscode\qsharp.schema.json )

/// End-user configuration for a specific lint or a lint group.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum LintOrGroupConfig {
Copy link
Member

Choose a reason for hiding this comment

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

Since level is a common field, I probably would have organized the types like this - fewer structs. It doesn't make a meaningful difference at runtime, and it might make deserialization awkward I don't know. So take it or leave it - I just wanted to make sure you considered it

struct LintConfig {
    kind: LintConfigKind,
    level: LintLevel,
}

enum LintConfigKind {
    Lint(LintKind),
    Group(LintGroup)
}

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I just saw unfold_group above - my suggestion would probably make that function more awkward. So I can see why you did it this way

Copy link
Member

Choose a reason for hiding this comment

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

Please add copyright header

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.

4 participants