vscode textmaterule 到目标 react className 字符串

vscode textmaterule to target react className string

发现关于如何 dim semicolons in vscode 的精彩 post。

认为在使用像 tailwind 这样的 class 实用程序时,javascriptreacttypescriptreact 文件对 className 字符串执行相同的操作可能很有用。

有人知道解决这个问题的方法吗?


如果在 j/tsx 个元素聚焦时可以忽略该规则,那将是锦上添花。

发布后继续搜索 SO(按照@rioV8 的建议)并找到 答案让我接近目标。

安装了 highlight extension 并写了这个:

  "highlight.regexes": {
    "(.*\sclassName=\")(.*?)\"": [
      {},
      {
        "color": "grey"
      }
    ]
  }

替代(无需扩展)解决方案是

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "string.quoted.double.tsx",
        "settings": {
          "foreground": "#ffffff77"
        }
      }
   ]

问题在于它的目标范围太广,而不仅仅是 className 范围内的 string.quoted.double.tsx