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 existing .eslint.config.mjs file at the root of your project directory.

To use ESLint along with other plug-ins, modify the default configuration in the .eslint.config.mjs file. Import each additional plug-in that you want to use and edit the extends property to load the plug-in’s configuration.
For example, to use the CSS plug-in, add the CSS plug-in configuration to the .eslint.config.mjs file.

This shows the .eslint.config.mjs file containing the default configuration that is emitted.

This shows the .eslint.config.mjs file with the CSS plug-in configuration included.

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, use the lint command with this argument.

--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.