---
title: "StyleLint"
description: "StyleLint is a tool that automatically checks and enforces consistent CSS code in your projects."
date: "2025-10-02"
lastUpdated: "2026-03-24"
tags: ["stylelint","css","linting","frontend"]
canonical: "/learn/guides/project/stylelint"
---

import { Code } from '@astrojs/starlight/components'
import Source from './.stylelintrc.json?raw'
import PackageManagers from '~/components/PackageManagers.astro'

## Installation

See the [official documentation](https://stylelint.io/user-guide/get-started).

<PackageManagers pkg="stylelint" dev />

<PackageManagers
  pkg="stylelint-a11y stylelint-config-standard stylelint-order stylelint-plugin-defensive-css stylelint-use-logical-spec"
  dev
/>

## Settings

These are basic `.stylelintrc.json` settings.

<Code code={Source} lang="json" title=".stylelintrc.json" wrap />

Create an ignore file (`.stylelintignore`) with the following:

```txt
build
dist
coverage
analysis
```

## Usage

and here is a script to run stylelint on your project:

```sh
# File: package.json

"style:lint": "pnpm run stylelint --cache './src/**/*.css'",
"style:lint:fix": "pnpm run style:lint --fix",
```
