eslint-plugin-sf-plugin

raw JSON →
1.20.33 verified Sat Apr 25 auth: no javascript

ESLint plugin providing rules for Salesforce CLI plugins development. Current stable version is 1.20.33, with frequent patch releases following @salesforce/core dependencies. It offers recommended and migration configurations to enforce best practices like command summaries, flag naming conventions, and hardcoded message detection. Differentiates by integrating with Salesforce toolchain and easing migration from sfdxCommand to sfCommand.

error Error: Failed to load plugin 'sf-plugin' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-sf-plugin'
cause Plugin not installed as a dev dependency.
fix
Run 'yarn add --dev eslint-plugin-sf-plugin' or 'npm install --save-dev eslint-plugin-sf-plugin'.
error Parsing error: The keyword 'const' is reserved
cause ESLint parser is not set to handle TypeScript or modern JavaScript.
fix
Add '@typescript-eslint/parser' as the parser and ensure 'parserOptions.ecmaVersion' is >= 2020.
error Definition for rule 'sf-plugin/command-summary' was not found
cause Incorrect plugin name in rules section (e.g., 'sfplugin' instead of 'sf-plugin').
fix
Use 'sf-plugin' as the plugin prefix in rules. Example: 'sf-plugin/command-summary': 'error'.
breaking Version 1.x requires Node >=18.0.0. Older Node versions are not supported.
fix Update Node.js to version 18.0.0 or later.
deprecated The 'sfdxCommand' pattern is deprecated. Use 'sfCommand' instead.
fix Apply the migration config ('plugin:sf-plugin/migration') to auto-fix many issues.
gotcha Rules like 'no-hardcoded-messages' may require additional setup (e.g., message bundle files) and can produce false positives if not configured.
fix Ensure your project follows the Salesforce message bundle conventions or disable the rule.
gotcha Using 'plugin:sf-plugin/migration' will auto-fix rule violations, which may cause unexpected code changes. Review changes carefully.
fix Run ESLint with --fix and then commit changes after thorough testing.
npm install eslint-plugin-sf-plugin
yarn add eslint-plugin-sf-plugin
pnpm add eslint-plugin-sf-plugin

Shows how to install and configure the plugin with recommended rules in an ESLint config file.

// Install
// yarn add --dev eslint-plugin-sf-plugin

// .eslintrc.js
module.exports = {
  extends: ['eslint-config-salesforce-typescript', 'plugin:sf-plugin/recommended'],
  rules: {
    'sf-plugin/no-hardcoded-messages': 'error'
  }
};