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

Add DiagnosticTag tags for pylint, pycodestyle, and flake8 #144

Closed
krassowski opened this issue Dec 31, 2021 · 3 comments · Fixed by #229
Closed

Add DiagnosticTag tags for pylint, pycodestyle, and flake8 #144

krassowski opened this issue Dec 31, 2021 · 3 comments · Fixed by #229
Milestone

Comments

@krassowski
Copy link
Contributor

As a follow up to #142 we can now add tags to diagnostics for specific plugins.
This would likely need to be based on matching the error codes.

I think it's worth the effort, but wanted to first see if you agree. Happy to make a PR with the changes.

@krassowski krassowski changed the title Add DiagnosticTag tags for pylint, pycodestyle Add DiagnosticTag tags for pylint, pycodestyle, and flake8 Dec 31, 2021
@ccordoba12
Copy link
Member

Could you post an example of a reply that includes the tag?

@krassowski
Copy link
Contributor Author

/**
 * @deprecated
 */
function oldFunc(test) { 
    return;
    let x = 1;
}
oldFunc
{
    "uri": "javascript_test.js",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 3,
                    "character": 17
                },
                "end": {
                    "line": 3,
                    "character": 21
                }
            },
            "message": "'test' is declared but its value is never read.",
            "severity": 4,
            "code": 6133,
            "source": "typescript",
            "tags": [
                1
            ]
        },
        {
            "range": {
                "start": {
                    "line": 5,
                    "character": 4
                },
                "end": {
                    "line": 5,
                    "character": 14
                }
            },
            "message": "Unreachable code detected.",
            "severity": 4,
            "code": 7027,
            "source": "typescript",
            "tags": [
                1
            ]
        },
        {
            "range": {
                "start": {
                    "line": 5,
                    "character": 8
                },
                "end": {
                    "line": 5,
                    "character": 9
                }
            },
            "message": "'x' is declared but its value is never read.",
            "severity": 4,
            "code": 6133,
            "source": "typescript",
            "tags": [
                1
            ]
        },
        {
            "range": {
                "start": {
                    "line": 7,
                    "character": 0
                },
                "end": {
                    "line": 7,
                    "character": 7
                }
            },
            "message": "'oldFunc' is deprecated",
            "severity": 4,
            "code": 6385,
            "source": "typescript",
            "tags": [
                2
            ]
        }
    ]
}

I'm rendering it as:

Screenshot from 2021-12-31 01-28-09

because:

export namespace DiagnosticTag {
	/**
	 * Unused or unnecessary code.
	 *
	 * Clients are allowed to render diagnostics with this tag faded out
	 * instead of having an error squiggle.
	 */
	export const Unnecessary: 1 = 1;
	/**
	 * Deprecated or obsolete code.
	 *
	 * Clients are allowed to rendered diagnostics with this tag strike through.
	 */
	export const Deprecated: 2 = 2;
}

@ccordoba12
Copy link
Member

Ok, I see. Then it's just extra metadata in the request. Then I'm fine with your proposal.

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 a pull request may close this issue.

2 participants