# Stylelint

Lint the CSS of every package with a Stylelint config, cached per package.

The Stylelint plugin gives every package with a Stylelint config a `lint:css` task, so each package's styles are linted on their own and stay cached until something they read changes.

## Add it

```sh
axle add stylelint
```

This writes it into the root `axle.toml`:

```toml
[plugins.stylelint]
source = "npm:@axle-rs/plugin-stylelint@0.1.0"
hash = "sha256-…"
```

## Tasks

A package or project with `.stylelintrc` with or without an extension, `stylelint.config.*` or a `"stylelint"` key in its `package.json` gets:

| Task       | Command                | Settings                                                              |
| ---------- | ---------------------- | --------------------------------------------------------------------- |
| `lint:css` | `stylelint "**/*.css"` | `inputs` the package's files and the root's config, `outputs` nothing |

Each command runs through the repository's package manager, such as `pnpm exec stylelint "**/*.css"`, so it uses the version the package installs.

A package that lints SCSS or the styles inside components keeps its own `lint:css` script, or sets the task's command in its `axle.toml`.

## Scripts the repository already has

A package's own script wins. When its `package.json` has a script with a task's name that runs something else, such as `"lint:css": "stylelint \"**/*.scss\""`, the plugin leaves that task alone and Axle runs the script. A script that runs the same command is replaced by the plugin's task, which runs it and adds its settings. The repository's `axle.toml` changes a task as it would any other, and wins over the plugin.

## Settings

| Setting | Default      | Meaning                                          |
| ------- | ------------ | ------------------------------------------------ |
| `lint`  | `"lint:css"` | the name of the task, or `false` to leave it out |

The plugin's answers are kept until a Stylelint config, a `package.json`, `pnpm-workspace.yaml` or a lockfile changes.
