<!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->

<!-- title -->

# @kitschpatrol/eslint-config

<!-- /title -->

<!-- badges -->

[![NPM Package @kitschpatrol/eslint-config](https://img.shields.io/npm/v/@kitschpatrol/eslint-config.svg)](https://npmjs.com/package/@kitschpatrol/eslint-config)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<!-- /badges -->

<!-- description -->

**ESLint configuration for @kitschpatrol/shared-config.**

<!-- /description -->

## Overview

It's a shared [ESLint](https://eslint.org) config, plus a command-line tool `kpi-eslint` to perform ESLint-related project initialization, linting, and fixing.

<!-- recommendation -->

> [!IMPORTANT]
>
> **You can use this package on its own, but it's recommended to use [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) instead for a single-dependency and single-package approach to linting and fixing your project.**
>
> This package is included as a dependency in [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config), which also automatically invokes the command line functionality in this package via its `kpi` command

<!-- /recommendation -->

## Setup

To use just this ESLint config in isolation:

1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:

   ```sh
   pnpm dlx @kitschpatrol/repo-config init
   ```

2. Install and initialize the required TypeScript `tsconfig.json` configuration in your project root:

   ```sh
   pnpm add -D @kitschpatrol/typescript-config
   pnpm dlx @kitschpatrol/typescript-config init
   ```

3. Add the package:

   ```sh
   pnpm add -D @kitschpatrol/eslint-config
   ```

4. Add the starter `eslint.config.ts` config files to your project root, and add any overrides you'd like:

   ```sh
   pnpm exec eslint-kpi init
   ```

## Usage

The ESLint binary should be picked up automatically by VS Code plugins.

You can call it directly, or use the script bundled with the config.

Integrate with your `package.json` scripts as you see fit, for example:

```json
{
  "scripts": {
    "lint": "eslint-config lint",
    "fix": "eslint-config fix"
  }
}
```

### CLI

<!-- cli-help -->

#### Command: `kpi-eslint`

Kitschpatrol's ESLint shared configuration tools.

This section lists top-level commands for `kpi-eslint`.

Usage:

```txt
kpi-eslint <command>
```

| Command        | Argument    | Description                                                                                                                                                               |
| -------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `init`         |             | Initialize by copying starter config files to your project root.                                                                                                          |
| `lint`         | `[files..]` | Lint your project with ESLint. Matches files below the current working directory by default.                                                                              |
| `fix`          | `[files..]` | Fix your project with ESLint. Matches files below the current working directory by default.                                                                               |
| `print-config` | `[file]`    | Print the effective ESLint configuration. Package-scoped by default, file-scoped if a file argument is provided. Use `@eslint/config-inspector` for a more detailed view. |

| Option              | Description         | Type      |
| ------------------- | ------------------- | --------- |
| `--help`<br>`-h`    | Show help           | `boolean` |
| `--version`<br>`-v` | Show version number | `boolean` |

_See the sections below for more information on each subcommand._

#### Subcommand: `kpi-eslint init`

Initialize by copying starter config files to your project root.

Usage:

```txt
kpi-eslint init
```

| Option              | Description         | Type      |
| ------------------- | ------------------- | --------- |
| `--help`<br>`-h`    | Show help           | `boolean` |
| `--version`<br>`-v` | Show version number | `boolean` |

#### Subcommand: `kpi-eslint lint`

Lint your project with ESLint. Matches files below the current working directory by default.

Usage:

```txt
kpi-eslint lint [files..]
```

| Positional Argument | Description                    | Type    | Default |
| ------------------- | ------------------------------ | ------- | ------- |
| `files`             | Files or glob pattern to lint. | `array` | `"."`   |

| Option              | Description         | Type      |
| ------------------- | ------------------- | --------- |
| `--help`<br>`-h`    | Show help           | `boolean` |
| `--version`<br>`-v` | Show version number | `boolean` |

#### Subcommand: `kpi-eslint fix`

Fix your project with ESLint. Matches files below the current working directory by default.

Usage:

```txt
kpi-eslint fix [files..]
```

| Positional Argument | Description                   | Type    | Default |
| ------------------- | ----------------------------- | ------- | ------- |
| `files`             | Files or glob pattern to fix. | `array` | `"."`   |

| Option              | Description         | Type      |
| ------------------- | ------------------- | --------- |
| `--help`<br>`-h`    | Show help           | `boolean` |
| `--version`<br>`-v` | Show version number | `boolean` |

#### Subcommand: `kpi-eslint print-config`

Print the effective ESLint configuration. Package-scoped by default, file-scoped if a file argument is provided. Use `@eslint/config-inspector` for a more detailed view.

Usage:

```txt
kpi-eslint print-config [file]
```

| Positional Argument | Description                 | Type     |
| ------------------- | --------------------------- | -------- |
| `file`              | File or glob pattern to TK. | `string` |

| Option              | Description         | Type      |
| ------------------- | ------------------- | --------- |
| `--help`<br>`-h`    | Show help           | `boolean` |
| `--version`<br>`-v` | Show version number | `boolean` |

<!-- /cli-help -->

## Notes

Regrettably the `eslint-config init --location package` option is not supported due to ESLint 9's deprecation of support for putting configuration in `package.json`. See ESLint discussion thread [18131](https://github.com/eslint/eslint/discussions/18131).

### Origins

This config is a heavily modified variation on Anthony Fu's [@antfu/eslint-config](https://github.com/antfu/eslint-config). This package is a somewhat leaner approach intended to work with other tools wrapped behind a monolithic CLI instead of handling everything on its own. It mainly leverages the factory / type generation implementation from the original repo, which itself builds on Kevin Deng's [@sxzz/eslint-config](https://github.com/sxzz/eslint-config). See the [modification notes](./modification-notes.md) for more details on what's changed from Anthony's approach.

### References

- [@antfu/eslint-config](https://github.com/antfu/eslint-config)
- [@sxzz/eslint-config](https://github.com/sxzz/eslint-config)
- [linting-setup-using-eslint](https://chris.lu/web_development/tutorials/next-js-static-mdx-blog/linting-setup-using-eslint)
- On [prefer-repository-shorthand](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/223)

<!-- license -->

## License

[MIT](license.txt) © Eric Mika

<!-- /license -->
