npm package: @rainstormy/presets-eslint
Description: A predefined, opinionated ESLint configuration suitable for any TypeScript project.
Author: Steffen Diswal
Latest version: 1.0.0-rc.0

# General Preset for ESLint

This package provides a predefined, opinionated [ESLint](https://eslint.org) configuration suitable for any [TypeScript](https://www.typescriptlang.org) project.

In addition to the [built-in rules of ESLint](https://eslint.org/docs/latest/rules), this preset configures a subset of rules from the following plugins, which are installed along with the preset package:

* [eslint-plugin-eslint-comments](https://mysticatea.github.io/eslint-plugin-eslint-comments/rules) (with rule names prefixed by `eslint-comments/`)
* [eslint-plugin-functional](https://github.com/eslint-functional/eslint-plugin-functional#rules) (with rule names prefixed by `functional/`)
* [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import#rules) (with rule names prefixed by `import/`)
* [@limegrass/eslint-plugin-import-alias](https://github.com/Limegrass/eslint-plugin-import-alias#configuration) (with rule names prefixed by `import-alias/`)
* [eslint-plugin-no-barrel-files](https://github.com/art0rz/eslint-plugin-no-barrel-files#rules) (with rule names prefixed by `no-barrel-files/`)
* [eslint-plugin-redundant-undefined](https://github.com/a-tarasyuk/eslint-plugin-redundant-undefined#usage) (with rule names prefixed by `redundant-undefined/`)
* [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/rules) (with rule names prefixed by `typescript/`)
* [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn#rules) (with rule names prefixed by `unicorn/`)

## Installation
Install the `@rainstormy/presets-eslint` package and its peer dependencies:

```shell
npm install --save-dev @rainstormy/presets-eslint eslint typescript
```

```shell
pnpm install --save-dev @rainstormy/presets-eslint eslint typescript
```

```shell
yarn add --dev @rainstormy/presets-eslint eslint typescript
```

## Usage
Create or extend a [flat ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`) and export the result of `eslintPresets` as the configuration object.

For example (with the default options in comments):

```javascript
import {
	eslintPresetAmbientTypeScriptModules,
	eslintPresets,
} from "@rainstormy/presets-eslint"

export default eslintPresets({
	// targetFilePatterns: ["**/*.@(js|jsx|ts|tsx)"],
	// tsconfigFiles: "closest-to-each-source-file",
	additionalPresets: [
		eslintPresetAmbientTypeScriptModules({
			// targetFilePatterns: ["**/*.d.ts"],
		}),
	],
})
```

### Override Rules
To override some rules or to install additional plugins, use the spread syntax (`...`) to add a custom configuration object after the preset configuration object.

For example:

```javascript
import { eslintPresets } from "@rainstormy/presets-eslint"

export default [
	...eslintPresets({
		// ...options...
	}),
	{
		files: ["**/*.@(js|jsx|ts|tsx)"],
		rules: {
			"max-lines": "off",
			"prefer-destructuring": "error",
			"typescript/no-magic-numbers": "off",
			"unicorn/prefer-at": "error",
		},
	},
]
```

### Custom `tsconfig.json` Location
By default, ESLint uses the TypeScript configuration file (`tsconfig.json`) that is located closest to each source file being linted.
Use the `tsconfigFiles` option to specify a different TypeScript configuration file or set of files.

For example:

```javascript
import { eslintPresets } from "@rainstormy/presets-eslint"

export default eslintPresets({
	tsconfigFiles: ["./tsconfig.eslint.json"],
	// ...other options...
})
```

### Ignore Files and Directories
To exclude certain files and directories entirely from linting, use the spread syntax (`...`) to add a custom configuration before the preset configuration object.

For example:

```javascript
import { eslintPresets } from "@rainstormy/presets-eslint"

export default [
	{
		ignores: ["coverage/**", "dist/**"],
	},
	...eslintPresets({
		// ...options...
	}),
]
```

Alternatively, you can avoid the need for ignore patterns altogether by explicitly listing the directories you want to include when you run ESLint from the terminal (i.e. opting in to linting instead of opting out).

For example:

```shell
eslint "./src/**/*.{ts,tsx}" "./*.config.{js,ts}" "./*.d.ts"
```