validate-element-name
Advanced tools
Comparing version 0.5.0 to 0.6.0
24
index.js
@@ -43,14 +43,22 @@ 'use strict'; | ||
function hasWarning(name) { | ||
if (/^polymer-/.test(name)) { | ||
if (/^polymer-/i.test(name)) { | ||
return 'Custom element names should not start with `polymer-`.\nSee: http://webcomponents.github.io/articles/how-should-i-name-my-element'; | ||
} | ||
if (/^x-/.test(name)) { | ||
if (/^x-/i.test(name)) { | ||
return 'Custom element names should not start with `x-`.\nSee: http://webcomponents.github.io/articles/how-should-i-name-my-element/'; | ||
} | ||
if (/^ng-/.test(name)) { | ||
if (/^ng-/i.test(name)) { | ||
return 'Custom element names should not start with `ng-`.\nSee: http://docs.angularjs.org/guide/directive#creating-directives'; | ||
} | ||
if (/^xml/i.test(name)) { | ||
return 'Custom element names should not start with `xml`.'; | ||
} | ||
if (name.toLowerCase() !== name) { | ||
return 'Custom element names should be lowercase.'; | ||
} | ||
if (/^[^a-z]/i.test(name)) { | ||
@@ -60,6 +68,10 @@ return 'This element name is only valid in XHTML, not in HTML. First character should be in the range a-z.'; | ||
if (/-$/.test(name)) { | ||
return 'Custom element names should not end with an hyphen.'; | ||
if (/[^a-z0-9]$/i.test(name)) { | ||
return 'Custom element names should not end with a non-alpha character.'; | ||
} | ||
if (/[\.]/.test(name)) { | ||
return 'Custom element names should not contain a dot character as it would need to be escaped in a CSS selector.'; | ||
} | ||
if (/[^\x20-\x7E]/.test(name)) { | ||
@@ -73,3 +85,3 @@ return 'Custom element names should not contain non-ASCII characters.'; | ||
if (/[^a-z0-9]{2}/.test(name)) { | ||
if (/[^a-z0-9]{2}/i.test(name)) { | ||
return 'Custom element names should not contain consecutive non-alpha characters.'; | ||
@@ -76,0 +88,0 @@ } |
{ | ||
"name": "validate-element-name", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Validate the name of a custom element", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5522
107