---
schema_version: "1"
id: 4851788c6867587bb51eab8e110e93685f9f74a69f2b385a964728d590f47ac6
title: Use SLDS Linter Rules with Salesforce Code Analyzer
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/slds_linter/guides/use/use-work-with-code-analyzer.md
canonical_url: https://developer.salesforce.com/docs/platform/slds-linter/guide/use-work-with-code-analyzer.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 815035d6ff577546c4f7397393b62977aed2b6f7d6f7283fc593a3e78a4da255
products:
  - SLDS Linter
  - lwc
---
# Use SLDS Linter Rules with Salesforce Code Analyzer

To set up and use SLDS Linter rules with Salesforce Code Analyzer, complete these prerequisites and follow these steps.  
By default, Code Analyzer is configured to include rules from the ESLint configuration. The SLDS Linter rules are part of the default ESLint configuration in Code Analyzer and have the tag `SLDS`. To view the SLDS rules supported in Code Analyzer, run this command:

```
sf code-analyzer rules --rule-selector SLDS --view detail
```

## Prerequisites

1. Install Salesforce CLI using one of the methods listed in [Install Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm) in the Salesforce CLI Setup Guide.
2. Install the Code Analyzer CLI plug-in by running this command in a terminal (macOS and Linux) or a command prompt (Windows).

   ```
    sf plugins install code-analyzer
   ```

   For more information about the CLI and Code Analyzer, see [Use CLI Commands to Analyze Your Code](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/analyze.html) in the Salesforce Code Analyzer Developer Guide.

   Alternatively, install the Code Analyzer VS Code Extension.  
   See [Use the VS Code Extension to Analyze Your Code](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/analyze-vscode.html) in the Salesforce Code Analyzer Developer Guide.

## Run Code Analyzer

1. Verify that the Code Analyzer plug-in is installed by running the `sf plugins` command.

   ```
   sf plugins
   ```

   The output shows the core and user plug-ins currently installed in Salesforce CLI. If Code Analyzer is installed, an entry like this one appears in the output. Depending on your environment, the returned Code Analyzer version can vary.

   ```
   code-analyzer 5.2.2 (5.2.2)
   ```

2. Run Code Analyzer to analyze your files using the `sf code-analyzer run` command. Add flags to analyze a single file, multiple files or all files in your current directory.  
   For detailed information about the `code-analyzer run` command, see [code-analyzer Commands](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_code-analyzer_commands_unified.htm#cli_reference_code-analyzer_run_unified).

   ### Examples

   Analyze the `hardcoded-values.css` file using all the ESLint rules that have the tag `slds`.

   ```
     # Run on a specific file
     sf code-analyzer run --rule-selector eslint:slds --workspace ./small-set/hardcoded-values.css
   ```

   Analyze all the files in the `./small-set` directory using the ESLint rules that have the tag `slds`.

   ```
    # Run on a specific folder with a specific tag
    sf code-analyzer run --rule-selector eslint:slds --workspace ./small-set/
   ```

   Analyze all the files in an entire directory using the ESLint rules that have the tag `slds`.

   ```
    # Run on an entire directory
    sf code-analyzer run --rule-selector eslint:slds --workspace .
   ```

After the analysis is completed, Code Analyzer displays the analysis results in a human-readable format. The results contain several details including the severity of the violation, the name of the rule associated with the violation and so on. To interpret the various details that are displayed in the results, see [Use CLI Commands to Analyze Your Code](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/analyze.html#interpret-the-run-results) in the Salesforce Code Analyzer Developer Guide.  
To learn about the SLDS Linter rules and understand how to fix the violations, see [SLDS Linter Rules](https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html).
