@mrhenry/stylelint-mrhenry-attribute-selector-no-unknown

2.1.3 • Public • Published

version

Disallow unknown attribute selectors.

/* valid, the `name` attribute is allowed on button elements. */
button[name] {}

/* valid, the `name` attribute is not a global attribute, but used without a type selector. */
[name] {}

/* invalid, the `href` attribute is not allowed on button elements. */
button[href] {}
/* valid, the `data-foo` attribute has a `data-*` prefix. */
[data-foo] {}

/* invalid, `foo` attribute doesn't exist. */
[foo] {}

Warns when attribute selectors are used that are not allowed on the given element.

While it is valid and allowed to use any attribute name on any element, it is not recommended to do so.

It is preferable to use the data-* attribute for custom attributes.

Usage

npm install --save-dev @mrhenry/stylelint-mrhenry-attribute-selector-no-unknown

// stylelint.config.js
module.exports = {
	plugins: [
		"@mrhenry/stylelint-mrhenry-attribute-selector-no-unknown",
	],
	rules: {
		"@mrhenry/stylelint-mrhenry-attribute-selector-no-unknown": true,
	},
}

Package Sidebar

Install

npm i @mrhenry/stylelint-mrhenry-attribute-selector-no-unknown

Weekly Downloads

454

Version

2.1.3

License

MIT

Unpacked Size

81.6 kB

Total Files

6

Last publish

Collaborators

  • wearemrhenry
  • romainmenke
  • fd