Course contentsShow
← Web Development
Lesson 1442 of 2,98226. Code Quality ToolsFree lesson

Integrating with Prettier

Configuring stylelint-config-prettier to avoid conflicts between Stylelint and Prettier formatting.

Integrating with Prettier

You'll learn how to make Stylelint and Prettier work together without stepping on each other's toes.

When you use both Stylelint and Prettier in the same project, you might encounter conflicts. Prettier handles code formatting (spaces, line breaks, indentation), while Stylelint checks CSS quality (validity, best practices). The problem? Some Stylelint rules also care about formatting—and when they disagree with Prettier, you get confusing errors about things Prettier just auto-fixed.

The Solution: stylelint-config-prettier

This special configuration turns off all Stylelint rules that conflict with Prettier's formatting decisions. Think of it as a peace treaty between two helpful tools that occasionally argue about tab spacing.

Installation:

npm install --save-dev stylelint-config-prettier

Configuration in .stylelintrc.json:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-prettier"
  ]
}

The key detail: stylelint-config-prettier must come last in your extends array. This ensures it overrides any formatting-related rules from earlier configurations.

What Gets Disabled

Rules like indentation, max-line-length, string-quotes, and declaration-colon-space-after are turned off. Prettier handles these concerns; Stylelint focuses on the CSS logic and quality rules it's best at.

Now you can run both tools in your workflow—Prettier formats your code, Stylelint catches actual CSS issues—without conflicting warnings.

Key Takeaway: Always add stylelint-config-prettier as the last item in your Stylelint extends array to disable formatting rules that conflict with Prettier's decisions, letting each tool do what it does best.