JSPM

  • Created
  • Published
  • Downloads 20666
  • Score
    100M100P100Q151277F
  • License Apache-2.0

Check if button has type attribute set

Package Exports

  • @hint/hint-button-type

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hint/hint-button-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Specify button type (button-type)

button-type checks if all buttons have a type attribute set.

Why is this important?

The default type for <button> is submit (not type="button" as one might expect). This can lead to surprising keyboard behavior within a form.

The best way to avoid unexpected surprises is to always explicitly set a type on <button>s.

What does the hint check?

This hint checks whether the type attribute of a <button> is explicitly set.

Examples that trigger the hint

<button></button>

Examples that pass the hint

<button type="submit"></button>
<button type="button"></button>

How to use this hint?

To use it you will have to install it via npm:

npm install @hint/hint-button-type

Note: You can make npm install it as a devDependency using the --save-dev parameter, or to install it globally, you can use the -g parameter. For other options see npm's documentation.

And then activate it via the .hintrc configuration file:

{
    "connector": {...},
    "formatters": [...],
    "parsers": [...],
    "hints": {
        "button-type": "error"
    },
    ...
}

Further Reading

What can the user read to know more about this subject?