eslint-plugin-apex

Apex linting for ESLint — inspired by apex-pmd, built for LWC + Apex teams

PMD Apex Rule XML Input
ESLint Config Snippet Output
Rule Skeleton (src/rules/…/rule-name.js)

Installation

npm install --save-dev eslint-plugin-apex

Quick Start (flat config)

Add to your eslint.config.js:

Available Configs

Config Description
apex.configs.recommended Recommended rules — errors for problems, warnings for suggestions
apex.configs.strict All rules at error severity
apex.configs.security Security rules only at error
apex.configs.performance Performance rules only at error

Manual Rule Configuration

import apex from 'eslint-plugin-apex';

export default [
  {
    files: ['**/*.cls', '**/*.trigger', '**/*.apex'],
    plugins: { apex },
    languageOptions: apex.configs.recommended.languageOptions,
    rules: {
      'apex/security-no-soql-injection': 'error',
      'apex/perf-no-dml-in-loop': 'error',
      'apex/best-test-has-asserts': 'warn',
    },
  },
];

PMD Converter

Switch to the PMD Converter tab to paste a PMD Apex rule XML and get an ESLint flat-config snippet and a rule implementation skeleton. The converter runs entirely in the browser — no data is sent anywhere.

Background

This plugin is inspired by apex-pmd and aims to port its rules into the ESLint ecosystem so teams can use a single linting tool for both Apex and Lightning Web Components (LWC). If you already use eslint-plugin-lwc, adding eslint-plugin-apex brings your Apex codebase into the same workflow — one eslint.config.js, one npm run lint, one CI step.

Links