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.

  • Node.js >= 14.0.0
  • A supported package manager
    • NPM >= 6.0.0
    • Yarn (Classic) >= 1.22.19

Use Terminal (or your command line tool of choice) to run all commands from the root directory of your Lightning web components project.

Note

  1. Install the node project dependencies.
    NPM
    npm install --save-dev @salesforce/eslint-plugin-lwc-mobile
    YARN
    yarn add --dev @salesforce/eslint-plugin-lwc-mobile
  2. Configure your project to use the new plugin.
    Modify the .eslintrc.json file under your project’s force-app/main/default/lwc directory. Extending the plugin:@salesforce/lwc-mobile/recommended ESlint configuration enables static analysis of all .js files used in your Lightning web components.
    {
        "extends": ["eslint:recommended", "plugin:@salesforce/lwc-mobile/recommended"]
    }