{"id":14978272,"url":"https://github.com/salesforce/eslint-plugin-lwc","last_synced_at":"2025-05-15T11:01:37.316Z","repository":{"id":34270091,"uuid":"158734570","full_name":"salesforce/eslint-plugin-lwc","owner":"salesforce","description":"Official ESLint rules for LWC","archived":false,"fork":false,"pushed_at":"2025-04-11T21:55:14.000Z","size":611,"stargazers_count":111,"open_issues_count":19,"forks_count":33,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-05-14T21:53:41.459Z","etag":null,"topics":["eslint","eslint-plugin","lightning-platform","lwc","salesforce"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salesforce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-22T17:55:39.000Z","updated_at":"2025-04-15T00:00:51.000Z","dependencies_parsed_at":"2023-12-21T02:34:44.827Z","dependency_job_id":"d00da977-9589-4232-840b-6ab83b3834a2","html_url":"https://github.com/salesforce/eslint-plugin-lwc","commit_stats":{"total_commits":137,"total_committers":32,"mean_commits":4.28125,"dds":0.8102189781021898,"last_synced_commit":"34911de749e20cabbf48f5585c92a4b62d082a41"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Feslint-plugin-lwc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Feslint-plugin-lwc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Feslint-plugin-lwc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salesforce%2Feslint-plugin-lwc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salesforce","download_url":"https://codeload.github.com/salesforce/eslint-plugin-lwc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328384,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-plugin","lightning-platform","lwc","salesforce"],"created_at":"2024-09-24T13:57:16.276Z","updated_at":"2025-05-15T11:01:36.614Z","avatar_url":"https://github.com/salesforce.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @lwc/eslint-plugin-lwc\n\n\u003e Official ESLint rules for Lightning Web Components (LWC).\n\n## Installation\n\n```\n$ npm install eslint @babel/core @babel/eslint-parser @lwc/eslint-plugin-lwc --save-dev\n```\n\n## Usage\n\n_Starting with v3.0.0, @lwc/eslint-plugin-lwc only supports eslint@v9. Use @lwc/eslint-plugin-lwc@v1.x for older versions of eslint._\n\nImport `@lwc/eslint-plugin-lwc` and use it in the `plugins` section of your configuration as shown below. Then configure the desired rules in the `rules` sections. Some of the syntax used in Lightning Web Components is not yet stage 4 (eg. class fields or decorators), and the out-of-the-box parser from ESLint doesn't support this syntax yet. In order to parse the LWC files properly, set the `parser` field to [`@babel/eslint-parser`](https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser) in the `languageOptions` section of the eslint config.\n\nExample of `eslint.config.js`:\n\n```js\nconst eslintPluginLwc = require('@lwc/eslint-plugin-lwc');\nconst babelParser = require('@babel/eslint-parser');\n\nmodule.exports = [\n    {\n        languageOptions: {\n            parser: babelParser,\n            parserOptions: {\n                requireConfigFile: false,\n                babelOptions: {\n                    parserOpts: {\n                        plugins: [\n                            'classProperties',\n                            ['decorators', { decoratorsBeforeExport: false }],\n                        ],\n                    },\n                },\n            },\n        },\n        plugins: {\n            '@lwc/lwc': eslintPluginLwc, // https://github.com/salesforce/eslint-plugin-lwc\n        },\n        rules: {\n            '@lwc/lwc/no-deprecated': 'error',\n            '@lwc/lwc/valid-api': 'error',\n            '@lwc/lwc/no-document-query': 'error',\n            '@lwc/lwc/ssr-no-unsupported-properties': 'error',\n        },\n    },\n];\n```\n\n### Usage with TypeScript\n\nTo enable working with TypeScript projects, install `@babel/preset-typescript` as a dependency add `\"typescript\"` to `languageOptions.parserOptions.babelOptions.parserOpts.plugins` in your `eslint.config.js`.\n\nExample:\n\n```js\nconst eslintPluginLwc = require('@lwc/eslint-plugin-lwc');\nconst babelParser = require('@babel/eslint-parser');\n\nmodule.exports = [\n    {\n        languageOptions: {\n            parser: babelParser,\n            parserOptions: {\n                requireConfigFile: false,\n                babelOptions: {\n                    parserOpts: {\n                        plugins: [\n                            'classProperties',\n                            ['decorators', { decoratorsBeforeExport: false }],\n                            'typescript',\n                        ],\n                    },\n                },\n            },\n        },\n    },\n];\n```\n\nFor more details about configuration please refer to the dedicated section in the ESLint documentation: https://eslint.org/docs/user-guide/configuring\n\n## Configurations\n\nTo choose from three configuration settings, install the [`eslint-config-lwc`](https://github.com/salesforce/eslint-config-lwc) sharable configuration package.\n\n### Processors\n\n| Processor ID                        | Description                                       |\n| ----------------------------------- | ------------------------------------------------- |\n| [lwc/ssr](./docs/processors/ssr.md) | Lint only JavaScript files of SSR-able components |\n\n## Rules\n\n### LWC\n\n| Rule ID                                                                                                                                | Description                                                                    | Fixable |\n| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------- |\n| [lwc/consistent-component-name](./docs/rules/consistent-component-name.md)                                                             | ensure component class name matches file name                                  | 🔧      |\n| [lwc/no-api-reassignments](./docs/rules/no-api-reassignments.md)                                                                       | prevent public property reassignments                                          |         |\n| [lwc/no-deprecated](./docs/rules/no-deprecated.md)                                                                                     | disallow usage of deprecated LWC APIs                                          |         |\n| [lwc/no-document-query](./docs/rules/no-document-query.md)                                                                             | disallow DOM query at the document level                                       |         |\n| [lwc/no-attributes-during-construction](./docs/rules/no-attributes-during-construction.md)                                             | disallow setting attributes during construction                                |         |\n| [lwc/no-disallowed-lwc-imports](./docs/rules/no-disallowed-lwc-imports.md)                                                             | disallow importing unsupported APIs from the `lwc` package                     |         |\n| [lwc/no-leading-uppercase-api-name](./docs/rules/no-leading-uppercase-api-name.md)                                                     | ensure public property doesn't start with an upper-case character              |         |\n| [lwc/no-unexpected-wire-adapter-usages](./docs/rules/no-unexpected-wire-adapter-usages.md)                                             | enforce wire adapters to be used with `wire` decorator                         |         |\n| [lwc/no-unknown-wire-adapters](./docs/rules/no-unknown-wire-adapters.md)                                                               | disallow usage of unknown wire adapters                                        |         |\n| [lwc/valid-api](./docs/rules/valid-api.md)                                                                                             | validate `api` decorator usage                                                 |         |\n| [lwc/valid-track](./docs/rules/valid-track.md)                                                                                         | validate `track` decorator usage                                               |         |\n| [lwc/valid-wire](./docs/rules/valid-wire.md)                                                                                           | validate `wire` decorator usage                                                |         |\n| [lwc/valid-graphql-wire-adapter-callback-parameters](./docs/rules/valid-graphql-wire-adapter-callback-parameters.md)                   | ensure graphql wire adapters are using 'errors' instead of 'error'             |         |\n| [lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md)                                   | disallow the host element mutation in 'connectedCallback'                      |         |\n| [lwc/consistent-component-name](./docs/rules/consistent-component-name.md)                                                             | ensure component class name matches file name                                  | 🔧      |\n| [lwc/no-api-reassignments](./docs/rules/no-api-reassignments.md)                                                                       | prevent public property reassignments                                          |         |\n| [lwc/no-deprecated](./docs/rules/no-deprecated.md)                                                                                     | disallow usage of deprecated LWC APIs                                          |         |\n| [lwc/no-document-query](./docs/rules/no-document-query.md)                                                                             | disallow DOM query at the document level                                       |         |\n| [lwc/no-attributes-during-construction](./docs/rules/no-attributes-during-construction.md)                                             | disallow setting attributes during construction                                |         |\n| [lwc/no-disallowed-lwc-imports](./docs/rules/no-disallowed-lwc-imports.md)                                                             | disallow importing unsupported APIs from the `lwc` package                     |         |\n| [lwc/no-leading-uppercase-api-name](./docs/rules/no-leading-uppercase-api-name.md)                                                     | ensure public property doesn't start with an upper-case character              |         |\n| [lwc/no-unexpected-wire-adapter-usages](./docs/rules/no-unexpected-wire-adapter-usages.md)                                             | enforce wire adapters to be used with `wire` decorator                         |         |\n| [lwc/no-unknown-wire-adapters](./docs/rules/no-unknown-wire-adapters.md)                                                               | disallow usage of unknown wire adapters                                        |         |\n| [lwc/valid-api](./docs/rules/valid-api.md)                                                                                             | validate `api` decorator usage                                                 |         |\n| [lwc/valid-track](./docs/rules/valid-track.md)                                                                                         | validate `track` decorator usage                                               |         |\n| [lwc/valid-wire](./docs/rules/valid-wire.md)                                                                                           | validate `wire` decorator usage                                                |         |\n| [lwc/ssr-no-restricted-browser-globals](./docs/rules/ssr/ssr-no-restricted-browser-globals.md)                                         | disallow access to global browser APIs during SSR                              |         |\n| [lwc/ssr-no-unsupported-properties](./docs/rules/ssr/ssr-no-unsupported-properties.md)                                                 | disallow access of unsupported properties in SSR                               |         |\n| [lwc/ssr-no-node-env](./docs/rules/ssr/ssr-no-node-env.md)                                                                             | disallow usage of process.env.NODE_ENV in SSR                                  |         |\n| [lwc/valid-graphql-wire-adapter-callback-parameters](./docs/rules/valid-graphql-wire-adapter-callback-parameters.md)                   | ensure graphql wire adapters are using 'errors' instead of 'error'             |         |\n| [lwc/ssr-no-host-mutation-in-connected-callback](./docs/rules/ssr/ssr-no-host-mutation-in-connected-callback.md)                       | disallow the host element mutation in 'connectedCallback'                      |         |\n| [lwc/ssr-no-static-imports-of-user-specific-scoped-modules](./docs/rules/ssr/ssr-no-static-imports-of-user-specific-scoped-modules.md) | disallow static imports of user-specific scoped modules in SSR-able components |         |\n| [lwc/ssr-no-form-factor](./docs/rules/ssr/ssr-no-form-factor.md)                                                                       | disallow formFactor in SSR-able components                                     |         |\n\n### Best practices\n\n| Rule ID                                                                            | Description                                                | Fixable |\n| ---------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------- |\n| [lwc/no-async-operation](./docs/rules/no-async-operation.md)                       | restrict usage of async operations                         |         |\n| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md)                 | disallow duplicate class members                           |         |\n| [lwc/no-inner-html](./docs/rules/no-inner-html.md)                                 | disallow usage of `innerHTML`                              |         |\n| [lwc/no-template-children](./docs/rules/no-template-children.md)                   | prevent accessing the immediate children of this.template  |         |\n| [lwc/no-leaky-event-listeners](./docs/rules/no-leaky-event-listeners.md)           | prevent event listeners from leaking memory                |         |\n| [lwc/prefer-custom-event](./docs/rules/prefer-custom-event.md)                     | suggest usage of `CustomEvent` over `Event` constructor    |         |\n| [lwc/ssr-no-unsupported-node-api](./docs/rules/ssr/ssr-no-unsupported-node-api.md) | disallow unsupported Node API calls in SSR-able components |         |\n\n### Compat performance\n\nOlder browsers like IE11 run LWC in compatibility mode. For more information about browser performance, please refer to [Supported Browsers](http://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.get_started_supported_browsers) in the Lightning Web Components Developer Guide.\n\n| Rule ID                                                    | Description                                 | Fixable |\n| ---------------------------------------------------------- | ------------------------------------------- | ------- |\n| [lwc/no-async-await](./docs/rules/no-async-await.md)       | disallow usage of the async-await syntax    |         |\n| [lwc/no-for-of](./docs/rules/no-for-of.md)                 | disallow usage of the for-of syntax         |         |\n| [lwc/no-rest-parameter](./docs/rules/no-rest-parameter.md) | disallow usage of the rest parameter syntax |         |\n\n### Deprecated\n\n| Rule ID                                                            | Replaced by                                                                                    |\n| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |\n| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md) | [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members)(base eslint rule) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforce%2Feslint-plugin-lwc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalesforce%2Feslint-plugin-lwc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforce%2Feslint-plugin-lwc/lists"}