Gruntfuggly / todo-tree

Use ripgrep to find TODO tags and display the results in a tree view
Other
1.4k stars 134 forks source link

ESLint auto-add #825

Open philsherry opened 4 months ago

philsherry commented 4 months ago

I spent a bit of time searching through the backlog of Issues (open and closed) to see if anyone had asked about this, but I couldn’t find any results.

What I’m after is a way to quickly show all ESLint comments in the TODO Tree, but without modifying the comments or adding new ones. I’d then do the same for Stylelint. I’d like to be able to apply this to several legacy projects that I’m updating.

Say I have a file with this at the top, I’d want these three rules to highlight in the Tree so that I can pay them some attention.

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable func-names */
/* eslint-disable prefer-arrow-callback */

I’m currently adding an inline comment with an uppercase label, which is obviously not great due to the duplication involved.

// ESLINT @typescript-eslint/no-explicit-any

I’ve tried adding eslint-disable and eslint-enable to tagGroups but it doesn’t seem to pick them up. Is it the hyphen that it doesn’t like?

Here’s the relevant config:

{
  "todo-tree.general.tagGroups": {
    "ESLINT": [
      "ESLINT",
      "eslint-disable",
      "eslint-enable"
    ]
  },
  "todo-tree.general.tags": [
    "ESLINT"
  ],
  "todo-tree.highlights.customHighlight": {
    "ESLINT": {
      "background": "#101828",
      "foreground": "#4b32c3",
      "icon": "gear",
      "iconColour": "#4b32c3"
    }
  },
  "todo-tree.highlights.defaultHighlight": {
    "background": "#ffab00",
    "borderRadius": "2px",
    "foreground": "#900",
    "gutterIcon": true,
    "icon": "alert",
    "iconColour": "#fff",
    "opacity": 90,
    "type": "tag-and-subTag"
  },
  "todo-tree.regex.enableMultiLine": true,
  "todo-tree.regex.regex": "(//|#|<!--|/\\*|^\\s*\\*)\\s*($TAGS)",
  "todo-tree.regex.subTagRegex": "\\s*\\((.*)\\):",
  "todo-tree.tree.labelFormat": "${tag} ${after}",
  "todo-tree.tree.subTagClickUrl": "${subTag}",
  "todo-tree.tree.tooltipFormat": "${filepath}, line ${line}"
}

Thanks in advance.