npm package: @goliafrs/eslint-config
Description: Eslint configuration.
Latest version: 4.0.0

# @goliafrs/eslint-config

![NPM Version](https://img.shields.io/npm/v/@goliafrs/eslint-config.svg) ![Downloads Total](https://img.shields.io/npm/dt/@goliafrs/eslint-config.svg) ![Downloads Week](https://img.shields.io/npm/dw/@goliafrs/eslint-config.svg)

## Installation

```bash
npm install --save-dev eslint@^10 @goliafrs/eslint-config
```

```bash
pnpm add --save-dev eslint@^10 @goliafrs/eslint-config
```

If you use the TypeScript config, install `typescript` in the consuming project
and keep a working `tsconfig.json` in the project root.

## Requirements

- Node.js >= 20.19.0.
- ESLint >= 10.

## Available Configs

| Name | Files | Purpose |
| ---- | ----- | ------- |
| `javascript` | `**/*.js`, `**/*.jsx`, `**/*.mjs`, `**/*.cjs` | Base JavaScript rules, stylistic rules, import ordering, unused import checks. |
| `typescript` | `**/*.ts`, `**/*.tsx` | Type-aware TypeScript rules on top of the JavaScript preset. |
| `commonjs` | `**/*.cjs` | Sets `sourceType: 'commonjs'` for CommonJS files. |
| `cypress` | `cypress/**/*.js`, `cypress/**/*.ts` | Cypress globals and recommended Cypress rules. |

## Usage

Create an `eslint.config.js` file in the root of your project.

### JavaScript only

```javascript
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([ configs.javascript ])
```

### TypeScript

```javascript
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([ configs.javascript, configs.typescript ])
```

### JavaScript with CommonJS files

```javascript
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([
  configs.javascript,
  configs.commonjs
])
```

### Cypress

```javascript
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([
  configs.javascript,
  configs.cypress
])
```

### TypeScript with Cypress

```javascript
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([
  configs.javascript,
  configs.typescript,
  configs.cypress
])
```

## What This Package Enables

- ESLint recommended JavaScript rules.
- Stylistic formatting rules for JavaScript and TypeScript source files.
- Import ordering and import placement checks.
- `unused-imports/no-unused-imports` as an error.
- `typescript-eslint` recommended and type-checked rules when `configs.typescript` is enabled.
- Cypress recommended rules and globals when `configs.cypress` is enabled.

## Notes

- `configs.typescript` expects TypeScript project information and enables
  `projectService: true`.
- `configs.commonjs` is additive. Use it together with `configs.javascript`
  when your project contains `*.cjs` files.
- `configs.cypress` is additive. Place it after `configs.javascript` or
  `configs.typescript` in your config array.

## Overrides

Disable `unused-imports/no-unused-imports` in a consumer project:

```js
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([
  configs.javascript,
  { rules: { 'unused-imports/no-unused-imports': 'off' } }
])
```

Override any rule for a specific folder:

```js
import { defineConfig } from 'eslint/config'
import configs from '@goliafrs/eslint-config'

export default defineConfig([
  configs.javascript,
  {
    files: [ 'src/legacy/**/*.js' ],
    rules: { 'no-console': 'off' }
  }
])
```