eslint-plugin-wc

ESLint plugin for Web Components

MIT 29 个版本
安装
npm install eslint-plugin-wc
yarn add eslint-plugin-wc
pnpm add eslint-plugin-wc
bun add eslint-plugin-wc
README

eslint-plugin-wc

npm version Build Status Coverage Status

ESLint plugin for Web Components.

Install

Assuming you already have ESLint installed, run:

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

# yarn
yarn add eslint-plugin-wc --dev

Usage

Then extend the recommended eslint config:

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

Or if you're using ESLint flat configs, add this to your eslint.config.js:

import {configs} from 'eslint-plugin-wc';

export default [
  configs['flat/recommended'],

  // or if you want to specify `files`, or other options
  {
    ...configs['flat/recommended'],
    files: ['test/**/*.js']
  }
];

You should also specify settings that will be shared across all the plugin rules. (More about eslint shared settings)

{
  "settings": {
    "wc": {
      "elementBaseClasses": ["LitElement"] // Recognize `LitElement` as a Custom Element base class
    }
  }
}

Custom Configuration

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

{
  "plugins": [
    // ...
    "wc"
  ],
  "rules": {
    // ...
    "wc/no-invalid-element-name": "error",
    "wc/no-typos": "warn"
  }
}

Supported Rules

Best Practice

Preference/convention

Shareable configurations

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

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

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

Best Practices

This plugin exports a best-practice configuration that enforces WebComponent best practices.

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

{
  "extends": ["eslint:recommended", "plugin:wc/best-practice"]
}

Note: These configurations will enable sourceType: 'module' in parser options.

License

eslint-plugin-wc is licensed under the MIT License.

版本列表
3.1.0 2026-02-09
3.0.2 2025-10-01
3.0.1 2025-04-27
3.0.0 2025-03-18
2.2.1 2025-02-20
2.2.0 2024-10-07
2.1.1 2024-08-21
2.1.0 2024-04-08
2.0.4 2023-09-25
2.0.3 2023-09-20
2.0.2 2023-09-18
2.0.1 2023-09-18
2.0.1-lit.1 2023-09-17
2.0.1-lit.0 2023-09-16
2.0.0 2023-09-16
2.0.0-ce.1 2023-08-23
2.0.0-ce.0 2023-08-22
1.5.0 2023-04-23
1.4.0 2022-11-26
1.3.2 2021-09-26
1.3.1 2021-07-20
1.3.0 2021-02-22
1.2.0 2019-07-31
1.1.1 2019-06-10
1.1.0 2019-05-13
1.0.1 2019-05-12
1.0.0 2019-02-26
0.1.1 2019-02-26
0.1.0 2019-02-26