-
-
Notifications
You must be signed in to change notification settings - Fork 681
Rule Proposal: no-invalid-attribute-name
#1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for proposing this rule. Do you know the specification of valid attribute names? If you know, please let me know. As far as I can see, You can also report any attribute. |
According to the specification, the HTML name may be written using anything from in the ascii range a-z, and A-Z, but nothing is more specific. |
Could you provide a link to the specs? |
It's right there in the specs you linked, https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 |
Oops. Thank you very much. I didn't understand the sentence correctly. |
Agreed, there doesn't seem to be a clear cut definition here, other than large and small Ascii letters is ok. |
I looked into this one a little bit, and the spec says:
The XML spec it is referring to (referring to what html calls attributes by their XML term "name") gives the following rules for names'construction:
I interpret that to the regex |
Thank you for checking the specifications. Based on the information you gave me, I searched for a package to check it. I think we can use this, what do you think? |
I think we can. Should I change my implementation to use that and reopen the pr? |
Yes thank you! |
* Fix #1373: Add rule no-invalid-attribute-name * Remove stray newline * Apply suggestions from code review Co-authored-by: Flo Edelmann <[email protected]> * #1373 Use xml-name-validator * Fix linting error * remove stray newline * refactor test code * Update lib/rules/no-invalid-attribute-name.js Co-authored-by: Flo Edelmann <[email protected]> * fix bad commit from github ui * fix typechecking error * Respond to PR feedback * Include the added types in package.json * check v-bind directives * Update tests/lib/rules/no-invalid-attribute-name.js Co-authored-by: Flo Edelmann <[email protected]> * Fix failing unit test * Update lib/rules/no-invalid-attribute-name.js * Update lib/rules/no-invalid-attribute-name.js * Update tests/lib/rules/no-invalid-attribute-name.js * Update tests/lib/rules/no-invalid-attribute-name.js Co-authored-by: Flo Edelmann <[email protected]> Co-authored-by: Yosuke Ota <[email protected]>
Please describe what the rule should do:
no-invalid-attribute-name
should disallow invalid attribute names for elements in the<template>
tag.What category should the rule belong to?
[ ] Enforces code style (layout)
[X] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
Here the linter should warn about the attribute
0abc
, which is invalid and will cause a runtime error when vue attempts to insert it onto the dom elementHere the linter should warn about the attribute
--
, which is invalid and will cause a runtime error when vue attempts to insert it onto the dom elementAdditional context
My team discovered this issue when a rogue
0
snuck its way through PR-review and onto an element behind a somewhat rarev-if
condition. A linting rule like this would have immediately caught the problem.The text was updated successfully, but these errors were encountered: