Skip to main content

attr-name-style

If set, HTML attributes names must conform to the given format.

Options

The rule accept the following as rule options.

  • A validation regexp deprecated
module.exports = {
rules: {
"attr-name-style": [true, /^[0-9a-o]+$/],
},
};
  • A string value form the following list value [camel,regexp,lowercase,dash] deprecated
{
"rules": {
"attr-name-style": [true, "dash"]
}
}
  • An config object
"attr-name-style": [true, {
format: "camel" | "regexp" | "lowercase" | "dash" | RegExp;
ignore?: string | RegExp
}],

format

Given the following config:

module.exports = {
rules: {
"attr-name-style": [
"error",
{
format: 'dash',
}
]
},
};

The following patterns are considered violations:

  <div attrName=""></div>
  <div attr_name=""></div>

The following patterns are not considered violations:

  <div attr-name=""></div>

ignore

module.exports = {
rules: {
"attr-name-style": [
"error",
{
format: 'dash',
ignore: 'xLink'
}
]
},
};

The following patterns are considered violations:

  <div attrName=""></div>

The following patterns are not considered violations:

  <div xLink=""></div>