Skip to content

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

Closed

Description

@krassowski

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.

Activity

  1. changed the title [-]Add `DiagnosticTag` tags for pylint, pycodestyle[/-] [+]Add `DiagnosticTag` tags for pylint, pycodestyle, and flake8[/+] on Dec 31, 2021
  2. ccordoba12 commented on Dec 31, 2021

    @ccordoba12
    Member

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

  3. krassowski commented on Dec 31, 2021

    @krassowski
    MemberAuthor
    /**
     * @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;
    }
    
  4. ccordoba12 commented on Jan 3, 2022

    @ccordoba12
    Member

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

  5. added this to the v1.5.0 milestone on Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions