Commands

Use these commands to work with SLDS Linter. To uplift your code to SLDS 2 best practices, review and fix the issues that are captured in the generated report.

lint 

Performs style and component linting on your files.

Description 

This command runs SLDS Linter on your code and identifies all the instances where the code doesn’t meet the SLDS 2 rules. It runs ESLint rules on HTML, CMP, and CSS files.

Examples 

See the lint output in the Terminal:

1npx @salesforce-ux/slds-linter@latest lint

Recursively lint all style and markup files in a single directory:

1npx @salesforce-ux/slds-linter@latest lint aura

Recursively lint all style and markup files in multiple directories:

1npx @salesforce-ux/slds-linter@latest lint "**/{aura,lwc}/**"

Recursively lint all CSS files in a single directory:

1npx @salesforce-ux/slds-linter@latest lint "aura/**/*.css"

Lint multiple types of style files:

1npx @salesforce-ux/slds-linter@latest lint "**/*.{css,scss,sass}"

Recursively lint all HTML files in a single directory:

1npx @salesforce-ux/slds-linter@latest lint "aura/**/*.html"

Lint multiple types of markup files:

1npx @salesforce-ux/slds-linter@latest lint "**/*.{html,cmp}"

Flags 

--fix
Optional

Automatically fix problems.

Type: Boolean

–config-eslint <path>
Optional

Path to ESLint configuration file.

Type: Option/String

--editor <editor>
Optional

Editor to open files. For example, VS Code, Atom, Sublime.

Type: Option/String

Default value: VS Code

report 

Generates a SARIF or CSV report for analyzing the issues identified by SLDS Linter. The default format is SARIF.

Description 

This command generates a report containing all the instances in your code that don’t align with SLDS 2 guidelines. The report is generated in .csv or .sarif format.

Examples 

Generate a SARIF report:

1npx @salesforce-ux/slds-linter@latest report --format sarif

Generate a CSV report:

1npx @salesforce-ux/slds-linter@latest report --format csv

Generate a CSV report to a specific directory:

1npx @salesforce-ux/slds-linter@latest report --format csv /mydirectory

Flags 

-o, --output <path>
Optional

Output directory for reports. Defaults to the current directory.

Type: Option/String

--config-eslint <path>
Optional

Path to ESLint configuration file.

Type: Option/String

–format <type>
Optional

Output format for the report. Allowed values are sarif and csv.

Type: Option/String

Default value: sarif

emit 

Generates the custom configuration files used by SLDS Linter. By default, the files are placed in the current directory.

Description 

This command generates the .eslintrc.yml configuration file used by the SLDS Linter CLI. In this file, you can add new rules and enable or disable existing rules.

Examples 

1npx @salesforce-ux/slds-linter@latest emit

Flags 

-d, –directory <path>
Optional

Target directory to scan. Defaults to the current directory. Supports glob patterns.

Type: Option/String

help 

Displays help for the various commands.

Description 

To view help, add --help to each command.

Examples 

See which options you can use with the lint command:

1npx @salesforce-ux/slds-linter@latest lint --help

Flags 

-V, --version
Optional

Displays the version number.

Type: Option/String

-h, –help
Optional

Displays help for the various commands.

Type: Option/String