Skip to content
ESLint rules for Web Components
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
custom_typings
docs/rules
media
src
.editorconfig
.eslintrc.json
.gitignore
.prettierrc
.travis.yml
CHANGELOG.md
LICENSE
README.md adds module sourceType (#30) Feb 26, 2019
package-lock.json
package.json
tsconfig.json

README.md

Eslint + WebComponents

eslint-plugin-wc

ESLint plugin for Web Components.

npm version Build Status Coverage Status License: MIT

Install

$ npm i -D eslint eslint-plugin-wc

Usage

Add wc to the plugins section of your .eslintrc file:

{
  "plugins": ["wc"]
}

Configure your rules like so:

{
  "rules": {
    "wc/rule-name": "error"
  }
}

Configuration

You may also extend the recommended configuration like so:

{
  "extends": ["plugin:wc/recommended"],
  "env": {"browser": true}
}

Or the best practice configuration which extends this to include all best practice rules:

{
  "extends": ["plugin:wc/best-practice"],
  "env": {"browser": true}
}

Supported Rules

Possible Errors (recommended)

Rule
wc/no-constructor-attributes Disallows interaction with attributes in constructors
wc/no-invalid-element-name Disallows invalid custom element names
wc/no-self-class Disallows class mutations on self

Best Practice

Rule
wc/attach-shadow-constructor Disallows attaching a shadow root outside the constructor
wc/guard-super-call Requires a guard before calling a super method inside a Custom Element Lifecycle hook
wc/no-closed-shadow-root Disallows closed shadow roots
wc/no-typos Prevents common typos
You can’t perform that action at this time.