# StyleLint Presets

The module `stylelint` provides a `defineConfig` function for project-wide StyleLint configuration.

## Functions

### Function `defineConfig`

Generates standard configuration targeting the source files in the entire project. Internally, various StyleLint plugins will be included and configured to use their recommended rule sets.

| Target | StyleLint Plugin |
| - | - |
| Stylesheet files (`.css`, `.less`, `.scss`) | StyleLint core rules |
| Less files only | [stylelint-config-standard-less](https://github.com/stylelint-less/stylelint-config-standard-less) |
| Sass files only | [stylelint-config-standard-scss](https://github.com/stylelint-scss/stylelint-config-standard-scss) |
| Source code formatting | [@stylistic/stylelint-plugin](https://github.com/stylelint-stylistic/stylelint-stylistic) |

#### `defineConfig` Signature

```ts
import type { Config } from 'stylelint'

function defineConfig(options?: ProjectOptions): Config
```

#### `defineConfig` Options

| Name | Type | Default | Description |
| - | - | - | - |
| `ignores` | `string[]` | `[]` | Glob patterns with all files to be ignored by StyleLint. |
| `license` | `string` | `''` | Full path to the template file containing the license header to be used in all source files. |
| `stylistic` | `StylisticOptions` | | Configuration options for code style. |
| `stylistic.indent` | `number` | `2` | Default indentation size (number of space characters). |
| `stylistic.quotes` | `'single'\|'double'\|'off'` | `'single'` | The type of the string delimiter character. |
| `rules` | `RulesConfig` | `{}` | Additional linter rules to be added to the global configuration. |

#### Built-in Ignore Globs

This package defines ignore globs for the following files and directories:

- `node_modules/**/*`
- `dist/**/*` (standard build output directory)
- `output/**/*` (output directory for tests etc.)
- `coverage/**/*` (Vitest coverage results)
- `.nuxt/**/*` and `.output/**/*` (NuxtJS output directories)

#### `defineConfig` Example

```ts
// stylelint.config.js
import { defineConfig } from '@open-xchange/linter-presets/stylelint'

export default defineConfig({
  ignores: ['external/**/*.scss'],
  license: './license.txt',
  stylistic: { indent: 2, quotes: 'single' },
})
```
