eslint-plugin-sf-plugin

1.18.3 • Public • Published

eslint-plugin-sf-plugin

Helpful eslint rules for sf plugins.

Use these rules in a sf plugin

yarn add --dev eslint-plugin-sf-plugin

Then, in your plugin's .eslintrc.js, add "plugin:sf-plugin/recommended" to your extends property.

example:

module.exports = {
  extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/recommended'],
};

To override how an individual rules behaves, add the plugin name and change the its rules value.

plugins: ['sf-plugin'],
rules: {
  'sf-plugin/no-hardcoded-messages': 'error'
}

Use these rules to migrate a plugin based on sfdxCommand to use sfCommand

These eslint rules are experimental and cause significant code changes. Please use with caution and test changes thoroughly

yarn add @salesforce/sf-plugins-core
yarn add --dev eslint-plugin-sf-plugin

[migration includes all of the recommended rules, so you don't have to include both]

module.exports = {
  extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/migration'],
};

Rules

💼 Configurations enabled in.
⚠️ Configurations set to warn in.
🚫 Configurations disabled in.
📚 Set in the library configuration.
✈️ Set in the migration configuration.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

Name                               Description 💼 ⚠️ 🚫 🔧 💡
command-example Ensure commands have a summary, description, and examples ✈️
command-summary Ensure commands have a summary ✈️ 🔧
dash-o Warn on a flag that uses -o ✈️
encourage-alias-deprecation Commands and flags aliases probably want to deprecate their old names to provide more warnings to users ✈️ 🔧 💡
esm-message-import Looks for the verbose Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url))) to offer a simpler alternative 📚 ✈️ 🔧
flag-case Enforce lowercase kebab-case flag names ✈️ 🔧
flag-cross-references Enforce flag cross references for dependOn,exclusive,exactlyOne ✈️
flag-min-max-default Enforce that flags with min/max values have a default value ✈️
flag-summary Enforce that flags have a summary property and that longDescription is renamed to description ✈️ 🔧
get-connection-with-version Calls to getConnection should pass in a version ✈️
id-flag-suggestions Create better salesforceId flags with length and startsWith properties ✈️ 🔧 💡
no-args-parse-without-strict-false If you parse args/argv, the class should have strict set to false ✈️ 🔧
no-builtin-flags Handling for sfdxCommand's flags.builtin ✈️ 🔧
no-classes-in-command-return-type The return type of the run method should not contain a class. ✈️ 🔧
no-deprecated-properties Removes non-existent properties left over from SfdxCommand ✈️ 🔧
no-duplicate-short-characters Prevent duplicate use of short characters or conflicts between aliases and flags ✈️
no-execcmd-double-quotes Do not use double quotes in NUT examples. They will not work on windows 📚 ✈️ 🔧
no-filepath-flags Change filepath flag to file flag 🔧
no-h-short-char Do not allow creation of a flag with short char -h ✈️
no-hardcoded-messages-commands Use loaded messages and separate files for messages ✈️
no-hardcoded-messages-flags Use loaded messages and separate files for messages. Follow the message naming guidelines ✈️ 🔧
no-hyphens-aliases Mark when an alias starts with a hyphen, like -f or --foo ✈️ 🔧
no-id-flags Change Id flag to salesforceId ✈️ 🔧
no-json-flag Do not allow creation of json flag ✈️
no-messages-load Use Messages.loadMessages() instead of Messages.load() 📚 ✈️ 🔧
no-missing-messages Checks core Messages usage for correct usage of named messages and message tokens 📚 ✈️
no-number-flags Change number flag to integer 🔧
no-oclif-flags-command-import Change import of flags and Command from oclif to use sf-plugins-core ✈️ 🔧
no-sfdx-command-import Change import and base class from SfdxCommand to sfCommand ✈️ 🔧
no-split-examples Arrays of messags should use getMessages instead of getMessage followed by EOL splitting ✈️ 🔧
no-this-flags Fix references to this.org (property on SfdxCommand) ✈️ 🔧 💡
no-this-org Fix references to this.org (property on SfdxCommand) ✈️ 🔧 💡
no-this-ux SfCommand does not have a ux property ✈️ 🔧
no-time-flags Migrate time flags to Flags.duration ✈️ 🔧
no-unnecessary-aliases Mark when an alias is unnecessary because its only an order permutation, not really a different name ✈️ 🔧
no-unnecessary-properties Boolean properties are false by default, so they should not be set to false ✈️ 🔧
no-username-properties Convert requiresUsername and supportusername to username flags ✈️ 🔧
read-only-properties Class-level static properties, like flags or descriptions, should be marked public and read-only ✈️ 🔧
run-matches-class-type The return type of the run method should match the Type passed to sfCommand ✈️ 🔧
sfdx-flags-property Change flag definitions to SfCommand version ✈️ 🔧
should-parse-flags The run method should call this.parse when there are flags ✈️ 🔧
use-sf-command-flags Use Flags export from sf-plugins-core ✈️ 🔧

Package Sidebar

Install

npm i eslint-plugin-sf-plugin

Weekly Downloads

14,807

Version

1.18.3

License

BSD-3-Clause

Unpacked Size

177 kB

Total Files

49

Last publish

Collaborators

  • salesforce-releases