aurelia / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
56 stars 17 forks source link

Question: require attribute on element #155

Closed 4nderss closed 7 years ago

4nderss commented 7 years ago

I see you have the following default rule:

Require
ensure require elments have a 'from' attribute

I would like to configure so that this:

 tag: "button",
            attr: /^type$/,
            is: /^button$|^submit$|^reset$|^menu$/,
            msg: "button type invalid"

includes to check that there is a type tag present on each

MeirionHughes commented 7 years ago

Not currently; could done by adding a "required" boolean option, then check to make sure the the element has that attribute.

Been swamped with some work code I need to get done; but I will try to get a release out on the weekend.

MeirionHughes commented 7 years ago

bolted on functionality for this.

see:

https://github.com/MeirionHughes/aurelia-template-lint/blob/b8fe917b6ce7feabfa1fc03c2325ad1046121d06/source/config.ts#L49

https://github.com/MeirionHughes/aurelia-template-lint/blob/b8fe917b6ce7feabfa1fc03c2325ad1046121d06/spec/required-attr.spec.ts

published: 0.9.22

MeirionHughes commented 7 years ago

Rolled back the config on this so its not on by default (until next minor version) ; you can add it on by setting the config:

config.requiredAttribute = [{
    tag: /^button$/,
    attr: /^type$/,
    msg: "buttons without a type have irregular behavour"
}];