Use SLDS Linter with Custom Configuration Files

You can enable or disable the rules used by SLDS Linter. To do so, use the emit command to generate custom configuration files and edit them to disable the rules that you don’t want to run. Then, use the edited files to run SLDS Linter and generate reports.

To enhance your linting and error analysis experience while using custom configuration files, we recommend that you install this additional extension.
By default, the linting issues present in the code aren’t highlighted in the custom configuration files. Installing this extension makes it easier to locate these issues, as they’re highlighted with squiggly lines.

ESLint extension: Applicable for linting HTML, Component (CMP), and Cascading Style Sheet (CSS) files. The ESLint extension checks your code and highlights any violations of the ESLint rules with squiggly lines.

Follow these steps to set up your custom configuration files.

To export the ESLint configuration file used by the SLDS Linter Command Line Interface (CLI), run the emit command.

This command creates or overwrites the .eslint.config.mjs file at the root of your project directory.

To disable specific rules in the .eslint.config.mjs file, comment the rule entry by using #.

To lint your code based on the modified custom configuration file, send the file to the lint command using this option.

--config-eslint
Supplies the .eslint.config.mjs file.

Lint HTML and CMP files based on a ESLint configuration file.

To generate reports containing all the lint issues, use the report command with the --format option.

Generate a SARIF report.

Generate a CSV report.