@liberfi.io/eslint-config 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +102 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# @liberfi.io/eslint-config
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Design Philosophy
|
|
6
|
+
|
|
7
|
+
- **Centralised, root-level config** — One config at the monorepo root; packages inherit it without duplicating setup.
|
|
8
|
+
- **Modern flat config** — Uses ESLint v9+ `defineConfig` and flat config arrays, no legacy `.eslintrc`.
|
|
9
|
+
- **Warnings over errors** — Most rules are `"warn"` to keep the DX unblocking while still surfacing issues; only critical rules (monorepo boundaries) are `"error"`.
|
|
10
|
+
- **Prettier-last** — `eslint-config-prettier` is applied last to disable formatting rules that conflict with Prettier.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
This is a workspace-internal package. It is already included as a root-level dev dependency:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D @liberfi.io/eslint-config --workspace
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Peer Dependencies
|
|
21
|
+
|
|
22
|
+
The consuming project must have `eslint` installed (v9+).
|
|
23
|
+
|
|
24
|
+
## API Reference
|
|
25
|
+
|
|
26
|
+
### Default Export
|
|
27
|
+
|
|
28
|
+
The package exports a flat config array via `index.mjs`:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import customEslintConfig from "@liberfi.io/eslint-config";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Type:** `FlatConfig[]` — an array of ESLint flat config objects ready to pass to `defineConfig`.
|
|
35
|
+
|
|
36
|
+
### Included Plugins & Configs
|
|
37
|
+
|
|
38
|
+
| Plugin / Config | Purpose |
|
|
39
|
+
| ----------------------------- | ------------------------------------------------ |
|
|
40
|
+
| `typescript-eslint` | TypeScript-aware linting (recommended preset) |
|
|
41
|
+
| `eslint-plugin-react` | React best practices (recommended + jsx-runtime) |
|
|
42
|
+
| `eslint-plugin-react-hooks` | Rules of Hooks enforcement |
|
|
43
|
+
| `eslint-plugin-react-refresh` | React Refresh / HMR compatibility |
|
|
44
|
+
| `@stylistic/eslint-plugin` | Code style rules |
|
|
45
|
+
| `eslint-plugin-monorepo-cop` | Prevents cross-package relative imports |
|
|
46
|
+
| `eslint-config-prettier` | Disables rules that conflict with Prettier |
|
|
47
|
+
| `globals` | Browser globals |
|
|
48
|
+
|
|
49
|
+
### Key Rules
|
|
50
|
+
|
|
51
|
+
| Rule | Severity | Notes |
|
|
52
|
+
| ------------------------------------------------- | -------- | ----------------------------------------- |
|
|
53
|
+
| `no-console` | warn | Allows `console.warn` and `console.error` |
|
|
54
|
+
| `@typescript-eslint/no-explicit-any` | warn | |
|
|
55
|
+
| `@typescript-eslint/no-unused-vars` | warn | |
|
|
56
|
+
| `@typescript-eslint/no-namespace` | off | |
|
|
57
|
+
| `@typescript-eslint/ban-ts-comment` | off | |
|
|
58
|
+
| `react/prop-types` | off | TypeScript handles prop validation |
|
|
59
|
+
| `react-hooks/rules-of-hooks` | warn | |
|
|
60
|
+
| `monorepo-cop/no-relative-import-outside-package` | error | Enforces package boundaries |
|
|
61
|
+
| `react-refresh/only-export-components` | off | |
|
|
62
|
+
|
|
63
|
+
### Global Ignores
|
|
64
|
+
|
|
65
|
+
The config ignores: `build/`, `dist/`, `node_modules/`, `public/`, `__test__/`, `storybook-static/`, `*.js`, `*.cjs`, `*.d.ts`.
|
|
66
|
+
|
|
67
|
+
## Usage Examples
|
|
68
|
+
|
|
69
|
+
### Root `eslint.config.mjs`
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import { defineConfig } from "eslint/config";
|
|
73
|
+
import customEslintConfig from "@liberfi.io/eslint-config";
|
|
74
|
+
|
|
75
|
+
export default defineConfig(customEslintConfig);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### With additional project-specific overrides
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import { defineConfig } from "eslint/config";
|
|
82
|
+
import customEslintConfig from "@liberfi.io/eslint-config";
|
|
83
|
+
|
|
84
|
+
export default defineConfig([
|
|
85
|
+
...customEslintConfig,
|
|
86
|
+
{
|
|
87
|
+
rules: {
|
|
88
|
+
"no-console": "error",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Future Improvements
|
|
95
|
+
|
|
96
|
+
- Remove unused dependencies (`@eslint/js`, `eslint-config-eslint`, `eslint-config-turbo`, `eslint-plugin-import`).
|
|
97
|
+
- Remove duplicate rule declarations in `index.mjs`.
|
|
98
|
+
- Remove phantom `tailwindcss/no-custom-classname` rule (plugin is not active).
|
|
99
|
+
- Clean up commented-out code blocks.
|
|
100
|
+
- Add Tailwind CSS v4 plugin support when available.
|
|
101
|
+
- Consider exporting a configurable function instead of a static array for consumer flexibility.
|
|
102
|
+
- Raise `react-hooks/rules-of-hooks` to `"error"` (violations cause runtime bugs).
|