Installation
npm install --save-dev eslint-plugin-apex
Quick Start (flat config)
Add to your eslint.config.js:
import apex from 'eslint-plugin-apex'; export default [ apex.configs.recommended, // optionally add more configs: // apex.configs.security, // apex.configs.performance, ];
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.