npm package: @lnu/eslint-config
Description: ESLint shareable config with JSDoc rules and modern best practices.
Latest version: 2.0.6

# 📘 @lnu/eslint-config

A modular ESLint Flat Config for JavaScript with optional TypeScript and test framework extensions (Jest, Mocha). Designed for educational use at Linnaeus University.

This package provides a **strict, explicit, and composable linting system** based on ESLint Flat Config.

## ⚡ Requirements

- Node.js >= 20
- ESLint >= 10 (Flat Config only)
- ESM (`"type": "module"` in package.json)

## 📦 Installation

### Base setup (JavaScript only)

```bash
npm install -D @lnu/eslint-config
npm install -D @eslint/js @stylistic/eslint-plugin eslint eslint-plugin-jsdoc eslint-plugin-n eslint-plugin-regexp eslint-plugin-security eslint-plugin-sort-destructure-keys globals
```

### Usage

```js
// eslint.config.js
import config from '@lnu/eslint-config';

export default config;
```

## 🧱 Architecture

This configuration is built using explicit composition.

It consists of:

- **Base config (always included)**
- **Optional extension layers**
  - TypeScript (`/ts`)

### Composition model

```js
import config from '@lnu/eslint-config';
import { tsRules } from '@lnu/eslint-config/ts';

export default [...config, ...tsRules];
```

No implicit configuration layering exists. All optional extensions must be explicitly imported.

## 📦 Core peer dependencies (always required)

These must be installed in the consuming project because ESLint Flat Config does not resolve plugins automatically.

```text
@eslint/js
@stylistic/eslint-plugin
eslint
eslint-plugin-jsdoc
eslint-plugin-n
eslint-plugin-regexp
eslint-plugin-security
eslint-plugin-sort-destructure-keys
globals
```

## 🧩 Optional peer dependencies

### TypeScript

```text
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
```

## 🧩 Optional extensions

These are only required if you use the corresponding layer.

### 🟦 TypeScript

```bash
npm install -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
```

```js
import config from '@lnu/eslint-config';
import { tsRules } from '@lnu/eslint-config/ts';

export default [...config, ...tsRules];
```

## 🚫 Not included

This package intentionally does NOT include:

- Prettier or formatting tools
- Framework configs (React, Vue, etc.)
- Test frameworks by default
- Legacy `.eslintrc` support

All optional concerns must be explicitly added.

## 📦 Exports

```txt
@lnu/eslint-config
@lnu/eslint-config/ts
```

## 🧭 Design principles

- Explicit over implicit
- Composition over inheritance
- No hidden dependencies
- Minimal default surface area
- Opt-in complexity only

## 🧪 Testing (optional setup)

This configuration does not include built-in test framework integrations.

Test frameworks (Jest, Vitest, Mocha) are user-owned concerns and can be integrated using ESLint flat config overrides with globals and file patterns.

---

### ✔️ Recommended setup (framework-agnostic)

### Config

```js
import config from '@lnu/eslint-config';
import globals from 'globals';

export default [
  ...config,
  {
    files: ['**/*.test.js', '**/*.spec.js', '**/__tests__/**/*.js'],
    languageOptions: {
      globals: {
        ...globals.jest,
      },
    },
  },
];
```

### 🧠 Optional note

If you want framework-specific lint rules (e.g. Jest plugin rules), you can install and configure the corresponding ESLint plugin in your project.

This package does not include or depend on any test framework plugins.

## ⚙️ Prettier

This ESLint configuration does not include or depend on any formatting system.

Prettier is supported as an optional, standalone code formatter that runs independently of ESLint.

### Installation

Prettier is not required by this configuration.

```bash
npm install -D prettier
```

### Optional ESLint compatibility layer

If your project uses ESLint rules that conflict with Prettier formatting rules, you may optionally install `eslint-config-prettier`.

```bash
npm install -D eslint-config-prettier
```

If used, it must be placed last in the ESLint flat config:

```js
import config from '@lnu/eslint-config';
import prettier from 'eslint-config-prettier';

export default [...config, prettier];
```

> Note: Only relevant if your ESLint setup includes formatting-related rules that would otherwise conflict with Prettier.

## 📊 Summary

| Feature    | Included    |
| ---------- | ----------- |
| JavaScript | ✔           |
| Node.js    | ✔           |
| Security   | ✔           |
| Regexp     | ✔           |
| JSDoc      | ✔           |
| TypeScript | ➕ (opt-in) |