Skip to main content

invalid-attr Rule Changes

This page covers breaking changes to the invalid-attr rule options. If you customized allowAttrs, disallowAttrs, or attrs in your config, read on.

Summary

ChangeWho is affected
{ type: X } wrapper removedConfigs using { "value": { "type": "Int" } }
attrs option deletedConfigs using the deprecated attrs option
Object format deprecatedConfigs using object format for allowAttrs / disallowAttrs

{ type: X } wrapper removed

Breaking Change

The { type: X } wrapper object for attribute values has been removed. Specify the type string directly.

Before (v4):

{
"invalid-attr": {
"options": {
"allowAttrs": [
{
"name": "x-count",
"value": { "type": "Int" }
}
]
}
}
}

After (v5):

{
"invalid-attr": {
"options": {
"allowAttrs": [
{
"name": "x-count",
"value": "Int"
}
]
}
}
}
note

{ enum: [...] } and { pattern: "..." } formats continue to work as before. Only the { type: X } wrapper is removed.

attrs option deleted

Breaking Change

The attrs option has been removed. It was deprecated since v3.7.0. Use allowAttrs and disallowAttrs instead.

Before (v4):

{
"invalid-attr": {
"options": {
"attrs": {
"x-data": { "type": "Any" },
"x-count": { "type": "Int" },
"x-color": { "enum": ["red", "blue"] },
"x-id": { "pattern": "/^[a-z]+$/" },
"x-banned": { "disallowed": true }
}
}
}
}

After (v5):

{
"invalid-attr": {
"options": {
"allowAttrs": [
"x-data",
{ "name": "x-count", "value": "Int" },
{ "name": "x-color", "value": { "enum": ["red", "blue"] } },
{ "name": "x-id", "value": { "pattern": "/^[a-z]+$/" } }
],
"disallowAttrs": ["x-banned"]
}
}
}

Key differences:

  • Allowed attributes go into allowAttrs as an array
  • Attributes with "disallowed": true go into disallowAttrs
  • Attributes without a value constraint can be specified as a plain string (e.g., "x-data")

Object format deprecated

Deprecation Warning

The object format for allowAttrs and disallowAttrs still works in v5, but it will be removed in a future version. Switch to the array format now.

Before (object format):

{
"invalid-attr": {
"options": {
"allowAttrs": {
"x-attr": "Int"
}
}
}
}

After (array format):

{
"invalid-attr": {
"options": {
"allowAttrs": [
{
"name": "x-attr",
"value": "Int"
}
]
}
}
}