{"id":19983,"library":"eslint-plugin-wc","title":"eslint-plugin-wc","description":"ESLint plugin enforcing best practices for Web Components, compatible with custom elements and libraries like LitElement. Current stable version 3.1.0, maintained actively. Requires ESLint >=8.40.0 and ships TypeScript types. Key differentiator: dedicated Web Components lint rules covering lifecycle callbacks, naming conventions, and shadow DOM correctness. ESM-only since v3.0.0; provides both legacy .eslintrc and flat config support.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/43081j/eslint-plugin-wc","tags":["javascript","eslint","eslintplugin","webcomponents","wc","typescript"],"install":[{"cmd":"npm install eslint-plugin-wc","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-wc","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-wc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required >=8.40.0","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v3.0.0; default export is the plugin object","wrong":"const plugin = require('eslint-plugin-wc')","symbol":"plugin (default)","correct":"import plugin from 'eslint-plugin-wc'"},{"note":"Named export for flat configs; requires ESM import. Use configs['flat/recommended'] for flat config.","wrong":"const { configs } = require('eslint-plugin-wc')","symbol":"configs","correct":"import { configs } from 'eslint-plugin-wc'"},{"note":"Named export containing all rule definitions, useful for custom rule inspection.","wrong":"","symbol":"rules","correct":"import { rules } from 'eslint-plugin-wc'"}],"quickstart":{"code":"// Install: npm install eslint-plugin-wc --save-dev\n\n// .eslintrc.json\n{\n  \"plugins\": [\"wc\"],\n  \"extends\": [\"plugin:wc/recommended\"],\n  \"rules\": {\n    \"wc/no-constructor-attributes\": \"error\",\n    \"wc/attach-shadow-constructor\": \"warn\"\n  },\n  \"settings\": {\n    \"wc\": {\n      \"elementBaseClasses\": [\"LitElement\"]\n    }\n  }\n}\n\n// or flat config (eslint.config.js)\nimport plugin from 'eslint-plugin-wc';\nexport default [\n  plugin.configs['flat/recommended'],\n  {\n    rules: {\n      'wc/no-constructor-attributes': 'error',\n      'wc/attach-shadow-constructor': 'warn'\n    },\n    settings: {\n      wc: {\n        elementBaseClasses: ['LitElement']\n      }\n    }\n  }\n];","lang":"typescript","description":"Minimal configuration to enable recommended Web Components linting with both legacy .eslintrc and flat config formats."},"warnings":[{"fix":"Use import statements or update to dynamic import().","message":"ESM-only since v3.0.0: require() will fail.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update ESLint to version 8.40.0 or later.","message":"Requires ESLint >=8.40.0; older versions not supported.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use default import or configs export for configuration.","message":"The `rules` object export may be considered internal; prefer using the plugin default or configs.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use `configs['flat/recommended']` in eslint.config.js.","message":"Flat config users must reference `configs['flat/recommended']`; the `recommended` config is not the same object.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Add settings.wc.elementBaseClasses in your ESLint config.","message":"Some rules require `settings.wc.elementBaseClasses` to recognize base classes like LitElement.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Switch to import statement or use dynamic import().","cause":"Using require() on an ESM-only package (v3+).","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Run npm install eslint-plugin-wc --save-dev.","cause":"Plugin not installed or not in node_modules.","error":"ESLint couldn't find the plugin 'eslint-plugin-wc'."},{"fix":"Check rule documentation for valid option schema; options are typically an empty array or specific format.","cause":"Invalid rule options passed.","error":"Configuration for rule 'wc/no-constructor-attributes' is invalid."},{"fix":"Use import { configs } from 'eslint-plugin-wc' and access configs['flat/recommended'].","cause":"Wrong import path for flat config.","error":"Cannot read properties of undefined (reading 'recommended')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}