npm package: @liberfi.io/eslint-config
Description: Shared ESLint configuration for the Liberfi React SDK monorepo. Provides a single flat config that covers TypeScript, React, code style, and monorepo boundary enforcement, consumed at the root level so individual packages need no ESLint setup.
Latest version: 0.1.140

# @liberfi.io/eslint-config

Shared ESLint configuration for the Liberfi React SDK monorepo. Provides a single flat config that covers TypeScript, React, code style, and monorepo boundary enforcement, consumed at the root level so individual packages need no ESLint setup.

## Design Philosophy

- **Centralised, root-level config** — One config at the monorepo root; packages inherit it without duplicating setup.
- **Modern flat config** — Uses ESLint v9+ `defineConfig` and flat config arrays, no legacy `.eslintrc`.
- **Warnings over errors** — Most rules are `"warn"` to keep the DX unblocking while still surfacing issues; only critical rules (monorepo boundaries) are `"error"`.
- **Prettier-last** — `eslint-config-prettier` is applied last to disable formatting rules that conflict with Prettier.

## Installation

This is a workspace-internal package. It is already included as a root-level dev dependency:

```bash
pnpm add -D @liberfi.io/eslint-config --workspace
```

### Peer Dependencies

The consuming project must have `eslint` installed (v9+).

## API Reference

### Default Export

The package exports a flat config array via `index.mjs`:

```javascript
import customEslintConfig from "@liberfi.io/eslint-config";
```

**Type:** `FlatConfig[]` — an array of ESLint flat config objects ready to pass to `defineConfig`.

### Included Plugins & Configs

| Plugin / Config               | Purpose                                          |
| ----------------------------- | ------------------------------------------------ |
| `typescript-eslint`           | TypeScript-aware linting (recommended preset)    |
| `eslint-plugin-react`         | React best practices (recommended + jsx-runtime) |
| `eslint-plugin-react-hooks`   | Rules of Hooks enforcement                       |
| `eslint-plugin-react-refresh` | React Refresh / HMR compatibility                |
| `@stylistic/eslint-plugin`    | Code style rules                                 |
| `eslint-plugin-monorepo-cop`  | Prevents cross-package relative imports          |
| `eslint-config-prettier`      | Disables rules that conflict with Prettier       |
| `globals`                     | Browser globals                                  |

### Key Rules

| Rule                                              | Severity | Notes                                     |
| ------------------------------------------------- | -------- | ----------------------------------------- |
| `no-console`                                      | warn     | Allows `console.warn` and `console.error` |
| `@typescript-eslint/no-explicit-any`              | warn     |                                           |
| `@typescript-eslint/no-unused-vars`               | warn     |                                           |
| `@typescript-eslint/no-namespace`                 | off      |                                           |
| `@typescript-eslint/ban-ts-comment`               | off      |                                           |
| `react/prop-types`                                | off      | TypeScript handles prop validation        |
| `react-hooks/rules-of-hooks`                      | warn     |                                           |
| `monorepo-cop/no-relative-import-outside-package` | error    | Enforces package boundaries               |
| `react-refresh/only-export-components`            | off      |                                           |

### Global Ignores

The config ignores: `build/`, `dist/`, `node_modules/`, `public/`, `__test__/`, `storybook-static/`, `*.js`, `*.cjs`, `*.d.ts`.

## Usage Examples

### Root `eslint.config.mjs`

```javascript
import { defineConfig } from "eslint/config";
import customEslintConfig from "@liberfi.io/eslint-config";

export default defineConfig(customEslintConfig);
```

### With additional project-specific overrides

```javascript
import { defineConfig } from "eslint/config";
import customEslintConfig from "@liberfi.io/eslint-config";

export default defineConfig([
  ...customEslintConfig,
  {
    rules: {
      "no-console": "error",
    },
  },
]);
```

## Future Improvements

- Remove unused dependencies (`@eslint/js`, `eslint-config-eslint`, `eslint-config-turbo`, `eslint-plugin-import`).
- Remove duplicate rule declarations in `index.mjs`.
- Remove phantom `tailwindcss/no-custom-classname` rule (plugin is not active).
- Clean up commented-out code blocks.
- Add Tailwind CSS v4 plugin support when available.
- Consider exporting a configurable function instead of a static array for consumer flexibility.
- Raise `react-hooks/rules-of-hooks` to `"error"` (violations cause runtime bugs).