Salesforce ESLint Configuration for TypeScript

4.0.1 · active · verified Tue Apr 21

eslint-config-salesforce-typescript is a comprehensive ESLint configuration designed specifically for TypeScript projects within the Salesforce ecosystem. Currently at version 4.0.1, this package provides a curated set of ESLint rules, including those from `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser`, ensuring consistent code quality and adherence to Salesforce's coding standards for TypeScript. It offers a structured approach to linting, integrating best practices for TypeScript development, and helps prevent common issues. The package receives regular maintenance updates, often weekly or bi-weekly as evidenced by the release log, primarily focused on dependency bumps and minor rule adjustments. It differentiates itself by providing a ready-to-use setup tailored for Salesforce projects, abstracting away the complexity of configuring multiple ESLint plugins for TypeScript. Developers can extend this configuration in their `.eslintrc` files, simplifying the setup process for new and existing projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install the configuration and its required peer dependencies, then set up a basic .eslintrc.js file to extend the Salesforce TypeScript ESLint rules.

yarn add eslint-config-salesforce-typescript eslint eslint-plugin-import eslint-plugin-prettier eslint-plugin-jsdoc @typescript-eslint/eslint-plugin @typescript-eslint/parser

// Create a .eslintrc.js file in your project root:
// .eslintrc.js
module.exports = {
  extends: [
    'eslint-config-salesforce-typescript'
  ],
  // If you are using type-aware rules, uncomment and adjust the parserOptions
  // parserOptions: {
  //   project: './tsconfig.json'
  // }
  // Add any project-specific overrides here, e.g., to disable a rule:
  // rules: {
  //   '@typescript-eslint/no-explicit-any': 'off'
  // }
};

// To run ESLint:
// npx eslint src/

view raw JSON →