eslint-plugin-lit icon indicating copy to clipboard operation
eslint-plugin-lit copied to clipboard

lit-html support for ESLint

Eslint + Lit

eslint-plugin-lit

npm version Build Status Coverage Status License: MIT

ESLint plugin for Lit.

Install

Assuming you already have ESLint installed, run:

# npm
npm install eslint-plugin-lit --save-dev

# yarn
yarn add eslint-plugin-lit --dev

Usage

Then extend the recommended eslint config:

{
  "extends": [
    // ...
    "plugin:lit/recommended"
  ]
}

Custom Configuration

If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:

{
  "plugins": [
    // ...
    "lit"
  ],
  "rules": {
    // ...
    "lit/no-legacy-template-syntax": "error",
    "lit/no-template-arrow": "warn"
  }
}

List of supported rules

  • lit/attribute-value-entities
  • lit/binding-positions
  • lit/no-duplicate-template-bindings
  • lit/no-invalid-escape-sequences
  • lit/no-invalid-html
  • lit/no-legacy-imports
  • lit/no-legacy-template-syntax
  • lit/no-private-properties
  • lit/no-property-change-update
  • lit/no-template-arrow
  • lit/no-template-bind
  • lit/no-template-map
  • lit/no-useless-template-literals
  • lit/no-value-attribute
  • lit/quoted-expressions

Shareable configurations

Recommended

This plugin exports a recommended configuration that enforces Lit good practices.

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["eslint:recommended", "plugin:lit/recommended"]
}

Usage with eslint-plugin-wc

We highly recommend you also depend on eslint-plugin-wc as it will provide additional rules for web components in general:

npm i -D eslint-plugin-wc

Then extend the recommended eslint config:

{
  "extends": [
    "plugin:wc/recommended",
    "plugin:lit/recommended"
  ]
}

License

MIT