Salesforce ESLint License Config
raw JSON → 1.0.2 verified Sat Apr 25 auth: no javascript
An ESLint configuration package from Salesforce that enforces a license header comment on all source files. Current stable version is 1.0.2. It is a small, single-purpose config that wraps the eslint-plugin-header plugin to ensure every JavaScript/TypeScript file in a Salesforce project starts with the required Salesforce copyright and license notice. Key differentiators: it is the official Salesforce tooling, tightly integrated with @salesforce/dev-scripts, and provides a plug-and-play setup for license compliance across Salesforce DX projects. Release cadence is sporadic, driven by license year updates or CI changes.
Common errors
error Error: Failed to load plugin 'header' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-header' ↓
cause eslint-plugin-header is a missing required dependency
fix
npm install --save-dev eslint-plugin-header
error Error: Failed to load config 'eslint-config-salesforce-license' to extend from. ↓
cause The package is not installed or not found in node_modules
fix
npm install --save-dev eslint-config-salesforce-license
error ReferenceError: module is not defined in ES module scope ↓
cause Using .eslintrc.mjs with CJS-style module.exports
fix
Use export default { extends: ['eslint-config-salesforce-license'] } or rename to .eslintrc.cjs
Warnings
gotcha The 'header/header' rule will fail if the license header does not exactly match the template defined by this config. ↓
fix Make sure your source files start with the exact license comment. Check the config source at https://github.com/forcedotcom/eslint-config-salesforce-license
deprecated Version 0.x used an older license text; upgrade to 1.x for the current year's license. ↓
fix Update to the latest version: npm install eslint-config-salesforce-license@latest
gotcha The eslint-plugin-header must be installed separately; it is not bundled and will not be installed automatically. ↓
fix Run: npm install --save-dev eslint-plugin-header
gotcha This config only checks for the license header; it does not include other Salesforce-specific rules (e.g., naming conventions). ↓
fix Combine with eslint-config-salesforce-typescript for full Salesforce linting: extends: ['eslint-config-salesforce-license', 'eslint-config-salesforce-typescript']
Install
npm install eslint-config-salesforce-license yarn add eslint-config-salesforce-license pnpm add eslint-config-salesforce-license Imports
- extends wrong
extends: ['salesforce-license']correctextends: ['eslint-config-salesforce-license'] - module.exports wrong
export default { extends: ['eslint-config-salesforce-license'] }correctmodule.exports = { extends: ['eslint-config-salesforce-license'] } - plugins wrong
plugins: ['eslint-plugin-header'] or omitting the plugin entirelycorrectplugins: ['header'] combined with extends: ['eslint-config-salesforce-license']
Quickstart
// Install dependencies
npm install --save-dev eslint eslint-config-salesforce-license eslint-plugin-header
// .eslintrc.js
module.exports = {
extends: ['eslint-config-salesforce-license'],
// Optionally disable header rule for test files or specific directories
overrides: [
{
files: ['**/*.test.ts', '**/__tests__/**'],
rules: {
'header/header': 'off',
},
},
],
};
// Then run ESLint: npx eslint src/