@salesforce/eslint-plugin-aura

3.0.0 • Public • Published

eslint-plugin-aura

Build status NPM version

Salesforce Lightning (Aura) specific linting rules for ESLint.

Installation

npm install --save-dev @salesforce/eslint-plugin-aura

Usage

[!IMPORTANT] Starting with v3.0.0, @salesforce/eslint-plugin-aura only supports eslint@v9. Use @salesforce/eslint-plugin-aura@v2.x for older versions of ESLint.

Add this plugin to your ESLint configuration and extend your desired configuration. See ESLint documentation for details.

Example eslint.config.js:

const eslintAura = require('@salesforce/eslint-plugin-aura');
module.exports = [
  ...eslintAura.configs.recommended,
  ...eslintAura.configs.locker,
];

Rules

Aura

Rule ID Description
aura/aura-api validate Aura APIs
aura/getevt-markup-prefix verify the presence of the markup:// prefix for events accessed via $A.getEvt()
aura/no-deprecated-aura-error prevent usage of $A.error
aura/no-deprecated-component-creation prevent usage of deprecated component creation methods
aura/no-deprecated-event-creation prevent usage of deprecated event creation methods

Locker

Rule ID Description
aura/ecma-intrinsics validate JavaScript intrinsic APIs
aura/secure-document validate secure document public APIs
aura/secure-window validate secure window public APIs

Configurations

This package exposes 2 configurations for your usage.

Recommended configuration

Goal: Prevent common pitfalls with Lightning component development, and enforce other Salesforce platform restrictions.

Rules:

Usage

// eslint.config.js
const eslintPluginAura = require('@salesforce/eslint-plugin-aura');

module.exports = [...eslintPluginAura.configs.recommended];

Migration to ESLint v9

The recommended configurations extend ESLint's js/recommended predefined configuration (previously known as eslint:recommended). ESLint v9 has added 4 new rules to the recommended config, you can read about that here. You can opt to turn these off for backwards compatibility.

// eslint.config.js
const eslintAura = require('@salesforce/eslint-plugin-aura');
module.exports = [
  ...eslintAura.configs.recommended,
  {
    rules: {
      'no-empty-static-block': 'off',
      'no-constant-binary-expression': 'off',
      'no-new-native-non-constructor': 'off',
      'no-unused-private-class-members': 'off',
    },
  },
];

Lightning Locker configuration

Goal: Prevent Lightning Locker violations.

Rules:

  • @salesforce/eslint-plugin-aura/recommended rules.
  • Proper usage of document and window via the secure-document and secure-window rules, respectively.
  • Proper usage of Javascript intrinsic APIs via the ecma-intrinsics rule.

Usage

// eslint.config.js
const eslintPluginAura = require('@salesforce/eslint-plugin-aura');

module.exports = [...eslintPluginAura.configs.locker];

Readme

Keywords

Package Sidebar

Install

npm i @salesforce/eslint-plugin-aura

Weekly Downloads

66,888

Version

3.0.0

License

BSD-3-Clause

Unpacked Size

76.7 kB

Total Files

20

Last publish

Collaborators

  • demianbrecht
  • jye-sf
  • jburnie
  • kevinv11n
  • byao
  • pmdartus
  • jcourtner
  • dferro
  • duane.chew
  • ekashida
  • ravi.jayaramappa
  • mjrust
  • apapko
  • jleen-sfdc
  • jqian
  • cwallsf
  • dhagberg-sf
  • khawkins
  • mbettio
  • amphro
  • ire-npm-team-user
  • damilareolowoniyi
  • jodarove
  • sfdctaka
  • fernomac
  • jimjag
  • ivarley
  • jbartolotta-sfdc
  • dhersam
  • mmadialagan
  • dbreese-salesforce
  • ashokrudraraju
  • salesforce-releases
  • iamaziz
  • packagellama
  • hkii
  • adirasanam
  • nolanlawson
  • jasonschroeder-sfdc
  • danielshox
  • dme722
  • maward
  • jmsjtu
  • mobify
  • dlouvton
  • lwc-admin
  • abirchfieldsfdc
  • ww951206