Install ESLint Rules for Mobile Lightning Web Components
We’ve created ESLint rules to help you develop code that works with mobile and offline Lightning web components. You can install them on your development machine and run them on your source code.
The ESLint rules flag violations for:
- Apex usage
- Offline GraphQL feature limitations
- Offline GraphQL hard limits
The ESLint rules are documented in the ESLint Plugin LWC Mobile GitHub repository.
The ESLint rules are a plugin that you install using a package manager, such as NPM or Yarn.
Use Terminal (or your command line tool of choice) to run all commands from the root directory of your Lightning web components project.
-
Install the node project dependencies.
NPM
YARN
-
The default configurations use the flat config format, which is compatible with ESLint 9 and later. To integrate
recommendedConfigsinto your flat configuration, you should spread this collection of preset configurations into your configuration array.eslint.config.js
eslint.config.mjs
ESLint 8 and earlier (Legacy Config)
Configurations for legacy ESLint now use extensions with the
-legacysuffix. For instance, to enable static analysis on all.jsfiles within your Lightning Web Components using theeslint-plugin-lwc-mobileplugin, extend theplugin:@salesforce/lwc-mobile/recommended-legacyESLint configuration within your.eslintrc.jsonfile.
-
Use ESLint Rules in Visual Studio Code
The ESLint rules for warnings against Lightning web components are displayed in Visual Studio (VS) Code where your code violates them. The rules map to distortions that affect your code. The popup for a rule violation includes a link to documentation for the rule.