2

I am trying to adjust my property-blacklist in stylelint and want to provide a message to each property that is blacklisted, like I did below with the top-property.

"property-blacklist": [
  "top",
  {
    "message": "Use translateY instead."
  }
]

If I now just want to simply add a custom message for the left-property, then how do I do this? The following configuration does not work:

"property-blacklist": [
  [
    "top",
    {
      "message": "Use translateY instead."
    }
  ],
  [
    "left",
    {
      "message": "Use translateX instead."
    }
  ]
]
Dominik Spiertz
  • 156
  • 2
  • 6

1 Answers1

1

Only one custom message can be assigned to each rule. The documentation suggests writing a custom formatter if you need more control:

Writing a custom formatter gives you maximum control if you need serious customization.

Alternatively, you could write a plugin. For example, plugin/property-no-box-offsets, which would disallow box offset properties. You can then generate, within the plugin itself, specific messages for each of the offsets e.g. "Unexpected box offset property. Use translateY instead" for occurrences of the top property.

jeddy3
  • 3,451
  • 1
  • 12
  • 21