UNPKG

validate-element-name

Version:
42 lines (27 loc) 975 B
# validate-element-name > Validate the name of a [custom element](http://www.html5rocks.com/en/tutorials/webcomponents/customelements/) Custom element names should start with `a-z` and contain `a-z` and at least one `-` with optionally `0-9`. You should not use the [`x-`, `polymer-`](http://webcomponents.github.io/articles/how-should-i-name-my-element/), [`ng-`](http://docs.angularjs.org/guide/directive#creating-directives) prefixes. ## Install ``` $ npm install validate-element-name ``` ## Usage ```js import validateElementName from 'validate-element-name'; validate('unicorn'); //=> {isValid: false, message: 'Custom element names must contain a hyphen. Example: unicorn-cake'} ``` See [cli.js](cli.js) for real-world usage. ## CLI ``` $ npm install --global validate-element-name ``` ``` $ validate-element-name --help Usage $ validate-element-name <element-name> Example $ validate-element-name s-slider ✔︎ Valid element name. ```