Installations
npm install @lwc/eslint-plugin-lwc
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=10.0.0
Node Version
20.12.2
NPM Version
10.5.0
Score
87.5
Supply Chain
93.8
Quality
94.1
Maintenance
100
Vulnerability
97
License
Releases
Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
salesforce
Download Statistics
Total Downloads
13,732,978
Last Day
36,771
Last Week
237,601
Last Month
751,020
Last Year
5,678,376
GitHub Statistics
MIT License
104 Stars
152 Commits
33 Forks
29 Watchers
6 Branches
59 Contributors
Updated on Jan 24, 2025
Bundle Size
130.12 kB
Minified
34.93 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.0
Package Id
@lwc/eslint-plugin-lwc@2.1.0
Unpacked Size
139.02 kB
Size
24.61 kB
File Count
46
NPM Version
10.5.0
Node Version
20.12.2
Published on
Jan 24, 2025
Total Downloads
Cumulative downloads
Total Downloads
13,732,978
Last Day
36.2%
36,771
Compared to previous day
Last Week
70%
237,601
Compared to previous week
Last Month
74.3%
751,020
Compared to previous month
Last Year
50.5%
5,678,376
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Peer Dependencies
2
@lwc/eslint-plugin-lwc
Official ESLint rules for Lightning Web Components (LWC).
Installation
$ npm install eslint @babel/core @babel/eslint-parser @lwc/eslint-plugin-lwc --save-dev
Usage
Add @lwc/eslint-plugin-lwc
to the plugins
section of your configuration. 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
.
Example of .eslintrc
:
1{ 2 "parser": "@babel/eslint-parser", 3 "parserOptions": { 4 "requireConfigFile": false, 5 "babelOptions": { 6 "parserOpts": { 7 "plugins": ["classProperties", ["decorators", { "decoratorsBeforeExport": false }]] 8 } 9 } 10 }, 11 12 "plugins": ["@lwc/eslint-plugin-lwc"], 13 14 "rules": { 15 "@lwc/lwc/no-deprecated": "error", 16 "@lwc/lwc/valid-api": "error", 17 "@lwc/lwc/no-document-query": "error", 18 "@lwc/lwc/ssr-no-unsupported-properties": "error" 19 } 20}
Usage with TypeScript
To enable working with TypeScript projects, install @babel/preset-typescript
as a dependency add "typescript"
to parserOptions.babelOptions.parserOpts.plugins
in your .eslintrc
.
Example:
1{ 2 "parserOptions": { 3 "babelOptions": { 4 "parserOpts": { 5 "plugins": [ 6 "classProperties", 7 ["decorators", { "decoratorsBeforeExport": false }], 8 "typescript" 9 ] 10 } 11 } 12 } 13}
For more details about configuration please refer to the dedicated section in the ESLint documentation: https://eslint.org/docs/user-guide/configuring
Configurations
To choose from three configuration settings, install the eslint-config-lwc
sharable configuration package.
Processors
Processor ID | Description |
---|---|
lwc/ssr | Lint only JavaScript files of SSR-able components |
Rules
LWC
Rule ID | Description | Fixable |
---|---|---|
lwc/consistent-component-name | ensure component class name matches file name | 🔧 |
lwc/no-api-reassignments | prevent public property reassignments | |
lwc/no-deprecated | disallow usage of deprecated LWC APIs | |
lwc/no-document-query | disallow DOM query at the document level | |
lwc/no-attributes-during-construction | disallow setting attributes during construction | |
lwc/no-disallowed-lwc-imports | disallow importing unsupported APIs from the lwc package | |
lwc/no-leading-uppercase-api-name | ensure public property doesn't start with an upper-case character | |
lwc/no-unexpected-wire-adapter-usages | enforce wire adapters to be used with wire decorator | |
lwc/no-unknown-wire-adapters | disallow usage of unknown wire adapters | |
lwc/valid-api | validate api decorator usage | |
lwc/valid-track | validate track decorator usage | |
lwc/valid-wire | validate wire decorator usage | |
lwc/no-restricted-browser-globals-during-ssr | disallow access to global browser APIs during SSR | |
lwc/no-unsupported-ssr-properties | disallow access of unsupported properties in SSR | |
lwc/no-node-env-in-ssr | disallow usage of process.env.NODE_ENV in SSR | |
lwc/ssr-no-restricted-browser-globals | disallow access to global browser APIs during SSR | |
lwc/ssr-no-unsupported-properties | disallow access of unsupported properties in SSR | |
lwc/ssr-no-node-env | disallow usage of process.env.NODE_ENV in SSR | |
lwc/valid-graphql-wire-adapter-callback-parameters | ensure graphql wire adapters are using 'errors' instead of 'error' | |
lwc/no-host-mutation-in-connected-callback | disallow the host element mutation in 'connectedCallback' | |
Rule ID | Description | Fixable |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------- |
lwc/consistent-component-name | ensure component class name matches file name | 🔧 |
lwc/no-api-reassignments | prevent public property reassignments | |
lwc/no-deprecated | disallow usage of deprecated LWC APIs | |
lwc/no-document-query | disallow DOM query at the document level | |
lwc/no-attributes-during-construction | disallow setting attributes during construction | |
lwc/no-disallowed-lwc-imports | disallow importing unsupported APIs from the lwc package | |
lwc/no-leading-uppercase-api-name | ensure public property doesn't start with an upper-case character | |
lwc/no-unexpected-wire-adapter-usages | enforce wire adapters to be used with wire decorator | |
lwc/no-unknown-wire-adapters | disallow usage of unknown wire adapters | |
lwc/valid-api | validate api decorator usage | |
lwc/valid-track | validate track decorator usage | |
lwc/valid-wire | validate wire decorator usage | |
lwc/ssr-no-restricted-browser-globals | disallow access to global browser APIs during SSR | |
lwc/ssr-no-unsupported-properties | disallow access of unsupported properties in SSR | |
lwc/ssr-no-node-env | disallow usage of process.env.NODE_ENV in SSR | |
lwc/valid-graphql-wire-adapter-callback-parameters | ensure graphql wire adapters are using 'errors' instead of 'error' | |
lwc/ssr-no-host-mutation-in-connected-callback | disallow the host element mutation in 'connectedCallback' | |
lwc/ssr-no-static-imports-of-user-specific-scoped-modules | disallow static imports of user-specific scoped modules in SSR-able components | |
lwc/ssr-no-form-factor | disallow formFactor in SSR-able components |
Best practices
Rule ID | Description | Fixable |
---|---|---|
lwc/no-async-operation | restrict usage of async operations | |
lwc/no-dupe-class-members | disallow duplicate class members | |
lwc/no-inner-html | disallow usage of innerHTML | |
lwc/no-template-children | prevent accessing the immediate children of this.template | |
lwc/no-leaky-event-listeners | prevent event listeners from leaking memory | |
lwc/prefer-custom-event | suggest usage of CustomEvent over Event constructor | |
lwc/ssr-no-unsupported-node-api | disallow unsupported Node API calls in SSR-able components |
Compat performance
Older browsers like IE11 run LWC in compatibility mode. For more information about browser performance, please refer to Supported Browsers in the Lightning Web Components Developer Guide.
Rule ID | Description | Fixable |
---|---|---|
lwc/no-async-await | disallow usage of the async-await syntax | |
lwc/no-for-of | disallow usage of the for-of syntax | |
lwc/no-rest-parameter | disallow usage of the rest parameter syntax |
Deprecated

No vulnerabilities found.
Reason
12 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/salesforce/.github/SECURITY.md:1
- Info: Found linked content: github.com/salesforce/.github/SECURITY.md:1
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: github.com/salesforce/.github/SECURITY.md:1
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
Reason
Found 21/27 approved changesets -- score normalized to 7
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Score
6.8
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More