Skip to content

lightning-flow-scanner

GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

Lightning Flow Scanner is a sfdx plugin scanning the integrity and best practices of Salesforce Flows

If your root folder is not force-app, please set variable SALESFORCE_LIGHTNING_FLOW_SCANNER_DIRECTORY

lightning-flow-scanner documentation

lightning-flow-scanner-sfdx - GitHub

Configuration in MegaLinter

Variable Description Default value
SALESFORCE_LIGHTNING_FLOW_SCANNER_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
SALESFORCE_LIGHTNING_FLOW_SCANNER_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
SALESFORCE_LIGHTNING_FLOW_SCANNER_CLI_LINT_MODE Override default CLI lint mode
⚠️ As default value is project, overriding might not work
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
project
SALESFORCE_LIGHTNING_FLOW_SCANNER_PRE_COMMANDS List of bash commands to run before the linter None
SALESFORCE_LIGHTNING_FLOW_SCANNER_POST_COMMANDS List of bash commands to run after the linter None
SALESFORCE_LIGHTNING_FLOW_SCANNER_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling SALESFORCE_LIGHTNING_FLOW_SCANNER and its pre/post commands None
SALESFORCE_LIGHTNING_FLOW_SCANNER_CONFIG_FILE lightning-flow-scanner configuration file nameUse LINTER_DEFAULT to let the linter find it .flow-scanner.json
SALESFORCE_LIGHTNING_FLOW_SCANNER_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
SALESFORCE_LIGHTNING_FLOW_SCANNER_DISABLE_ERRORS Run linter but consider errors as warnings false
SALESFORCE_LIGHTNING_FLOW_SCANNER_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
SALESFORCE_LIGHTNING_FLOW_SCANNER_CLI_EXECUTABLE Override CLI executable ['sf']
SALESFORCE_DIRECTORY Directory containing SALESFORCE files (use any to always activate the linter) force-app

IDE Integration

Use lightning-flow-scanner in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Visual Studio Code Lightning Flow Scanner Install in VSCode

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 124 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 54 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • Activated only if sub-directory force-app is found. (directory name can be overridden with SALESFORCE_DIRECTORY)
  • If this linter is active, all files will always be linted

How the linting is performed

lightning-flow-scanner is called once on the whole project directory (project CLI lint mode)

  • filtering can not be done using MegaLinter configuration variables,it must be done using lightning-flow-scanner configuration or ignore file (if existing)
  • VALIDATE_ALL_CODEBASE: false doesn't make lightning-flow-scanner analyze only updated files

Example calls

sf flow:scan

Help content

 ›   Warning: @salesforce/cli update available from 2.60.13 to 2.61.8.
(node:1745) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Find and fix potential bugs in Salesforce flows.

USAGE
  $ sf flow scan [--json] [--flags-dir <value>] [-d <value>] [-c
    <value>] [-f error|warning|note|never] [-r] [-p <value>] [-u <value>]

FLAGS
  -c, --config=<value>          Path to configuration file
  -d, --directory=<value>       Directory to scan for flows
  -f, --failon=<option>         [default: error] Threshold failure level (error,
                                warning, note, or never) defining when the
                                command return code will be 1
                                <options: error|warning|note|never>
  -p, --sourcepath=<value>      Comma-separated list of source flow paths to
                                scan
  -r, --retrieve                Force retrieve Flows from org at the start of
                                the command
  -u, --targetusername=<value>  Retrieve the latest metadata from the target
                                before the scan.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

Installation on mega-linter Docker image

  • Dockerfile commands :
# Parent descriptor install
# renovate: datasource=npm depName=@salesforce/cli
ARG SALESFORCE_CLI_VERSION=2.61.8
# renovate: datasource=npm depName=@salesforce/plugin-packaging
ARG SALESFORCE_PLUGIN_PACKAGING_VERSION=2.8.12
# renovate: datasource=npm depName=sfdx-hardis
ARG SFDX_HARDIS_VERSION=5.1.0
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"
RUN sf plugins install @salesforce/plugin-packaging@${SALESFORCE_PLUGIN_PACKAGING_VERSION} \
    && echo y|sf plugins install sfdx-hardis@${SFDX_HARDIS_VERSION} \
    && npm cache clean --force || true \
    && rm -rf /root/.npm/_cacache
ENV SF_AUTOUPDATE_DISABLE=true
# Linter install
# renovate: datasource=npm depName=lightning-flow-scanner
ARG LIGHTNING_FLOW_SCANNER_VERSION=2.34.0
RUN echo y|sf plugins install lightning-flow-scanner@${LIGHTNING_FLOW_SCANNER_VERSION} \
    && npm cache clean --force || true \
    && rm -rf /root/.npm/_cacache