
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
eslint-plugin-custom-element
Advanced tools
This plugin creates rules specific for validating custom element implementation in HTML
This plugin creates custom rules to lint custom elements in HTML.
This plugin leverages the @html-eslint/eslint-plugin
and @html-eslint/parser
packages to parse the DOM.
npm install -D eslint-plugin-custom-element eslint @html-eslint/eslint-plugin @html-eslint/parser
NOTE: If you would like to have these rules automatically generated for you, check out the Custom Element ESLint Rule Generator.
// eslint.config.js
import customElement from "eslint-plugin-custom-element";
import html from "@html-eslint/eslint-plugin";
import htmlParser from "@html-eslint/parser";
export default [
{
files: ["**/*.html"],
languageOptions: {
parser: htmlParser,
},
plugins: {
html,
"custom-element": customElement,
},
rules: {
/* Add configuration for custom element rules */
},
},
];
For more configuration options, check out the HTML ESLint docs.
The plugin provides predefined rules for validating custom element APIs.
The custom-element/constrained-attrs
rule provides validation for attributes with predefined acceptable values.
// eslint.config.js
export default [
{
/* ...plugin config... */
rules: {
"custom-element/constrained-attrs": [
"error",
{
tag: "my-button",
attr: "appearance",
values: ["primary", "outline", "default", "transparent"],
},
],
},
},
];
The custom-element/no-deprecated-attrs
rule notifies the developer when an attribute for a custom element is deprecated.
// eslint.config.js
export default [
{
/* ...plugin config... */
rules: {
"custom-element/no-deprecated-attrs": [
"warn",
{
tag: "my-button",
attr: "size",
},
],
},
},
];
The custom-element/no-deprecated-tags
rule notifies the developer when a custom element is deprecated.
// eslint.config.js
export default [
{
/* ...plugin config... */
rules: {
"custom-element/no-deprecated-tags": [
"warn",
{
tag: "your-element",
},
],
},
},
];
The custom-element/required-attrs
rule notifies the developer if an expected attribute is not present on the custom element.
// eslint.config.js
export default [
{
/* ...plugin config... */
rules: {
"custom-element/required-attrs": [
"error",
{
tag: "my-button",
attr: "type",
},
],
},
},
];
The custom-element/no-boolean-attr-values
rule notifies users that setting a value on boolean
attributes will result in it always being true
(ie - <my-button disabled="false"></my-button>
will result in a disabled button).
// eslint.config.js
export default [
{
/* ...plugin config... */
rules: {
"custom-element/no-boolean-attr-values": [
"error",
{
tag: "my-button",
attr: "disabled",
},
],
},
},
];
FAQs
This plugin creates rules specific for validating custom element implementation in HTML
The npm package eslint-plugin-custom-element receives a total of 0 weekly downloads. As such, eslint-plugin-custom-element popularity was classified as not popular.
We found that eslint-plugin-custom-element demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.