3

I am writing custom eslint rules. The rules are flagging the correct spot in the code, but Visual Studio Code is not offering my quick fixes.

Here's the start of the code:

module.exports = {
  meta: {
      type: "suggestion",
      docs: {
          description: "Use design tokens",
          category: "Design System",
          recommended: false
      },
      fixable: "code"
  },

And Here is, where I report the problem:

for (const m of matchedTokens) {
  suggest.push({
    desc: property.value.raw + " should be " + m,
    fix(fixer) {
      return fixer.replaceText(property.value, m);
    }
  })
}
context.report({
  node: property,
  message: 'Possible value for replacement of {{ key }} with design token',
  data: {
    key: property.key.name
  },
  suggest
})

How can I make suggestions work in the IDE? Is my expectation correct that these should show as quick fix in Visual Studio code? Is there anything else I need to do to opt into fixes?

Karthick Nagarajan
  • 1,327
  • 2
  • 15
  • 27
Jason Hocker
  • 6,879
  • 9
  • 46
  • 79

0 Answers0