@liberfi.io/eslint-config 0.1.16 → 0.1.18
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/DESIGN-REVIEW.md +68 -0
- package/README.md +102 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/DESIGN-REVIEW.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Design Review — `@liberfi.io/eslint-config`
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
The `@liberfi.io/eslint-config` package centralises ESLint configuration for the entire monorepo using the modern flat config format. It integrates typescript-eslint, React, React Hooks, React Refresh, Prettier, Stylistic, and monorepo-cop into a single shareable config. The architecture is sound — one config consumed at the root level — but the implementation suffers from unused dependencies, duplicate rules, dead commented-out code, and a phantom tailwind rule reference. These issues add noise and could cause confusion or silent errors.
|
|
6
|
+
|
|
7
|
+
## What's Done Well
|
|
8
|
+
|
|
9
|
+
1. **Centralised, root-level config** — The config is consumed only at the root via `eslint.config.mjs`, so individual packages don't need their own ESLint setup. This is the cleanest pattern for monorepo linting.
|
|
10
|
+
2. **Modern flat config** — Uses `defineConfig` and flat config arrays instead of the legacy `.eslintrc` format, aligning with ESLint v9+ direction.
|
|
11
|
+
3. **Good plugin selection** — Covers the key areas: TypeScript type checking (`typescript-eslint`), React best practices (`eslint-plugin-react`, `react-hooks`, `react-refresh`), code style (`@stylistic`, `prettier`), and monorepo hygiene (`monorepo-cop`).
|
|
12
|
+
4. **Sensible severity levels** — Most rules are set to `"warn"` rather than `"error"`, keeping the developer experience unblocking while still surfacing issues.
|
|
13
|
+
5. **Prettier integration** — `eslint-config-prettier` is applied last, correctly disabling formatting rules that conflict with Prettier.
|
|
14
|
+
6. **Monorepo boundary enforcement** — `monorepo-cop/no-relative-import-outside-package` at `"error"` level prevents cross-package relative imports.
|
|
15
|
+
|
|
16
|
+
## Areas for Improvement
|
|
17
|
+
|
|
18
|
+
1. **Unused dependencies in `package.json`** — Three packages are declared as dependencies but never imported in `index.mjs`: `@eslint/js`, `eslint-config-eslint`, `eslint-config-turbo`, and `eslint-plugin-import`. These inflate install time and create confusion about what's actually used. **Recommendation**: Remove all four from `dependencies`. If they're kept for future use, move them to comments in `package.json` or a TODO file.
|
|
19
|
+
|
|
20
|
+
2. **Duplicate rules in the same block** — The following rules appear twice in the `rules` object, with the second declaration silently overriding the first:
|
|
21
|
+
- `@typescript-eslint/no-unused-vars` (both `"warn"`)
|
|
22
|
+
- `@typescript-eslint/ban-ts-comment` (`"warn"` then `"off"`)
|
|
23
|
+
- `@typescript-eslint/no-empty-object-type` (both `"warn"`)
|
|
24
|
+
|
|
25
|
+
The `ban-ts-comment` duplication is particularly problematic: it's set to `"warn"` then overridden to `"off"`, making the intent unclear. **Recommendation**: Remove the duplicates; keep only the intended final value for each rule.
|
|
26
|
+
|
|
27
|
+
3. **Phantom `tailwindcss/no-custom-classname` rule** — This rule references the tailwind plugin, which is commented out. Depending on ESLint's handling, this either silently does nothing or throws an error when the plugin namespace isn't registered. **Recommendation**: Remove the rule. Re-add it when Tailwind v4 support lands.
|
|
28
|
+
|
|
29
|
+
4. **Excessive commented-out code** — Large blocks of dead code (import plugin config, turbo config, tailwind config, `__dirname` setup) make the file hard to read. **Recommendation**: Remove commented-out blocks. Preserve intent via short TODO comments (one line each) and link to relevant issues if needed.
|
|
30
|
+
|
|
31
|
+
5. **`eslint.config.fix.mjs` has dead tailwind comments** — The root `eslint.config.fix.mjs` contains a large commented-out block for tailwind rules. Same issue as above. **Recommendation**: Clean up in the same pass.
|
|
32
|
+
|
|
33
|
+
6. **`apps/storybook` references non-existent `eslint-config-custom`** — `apps/storybook/eslint.config.js` imports from `eslint-config-custom`, which doesn't exist in the workspace. This is likely a leftover from a rename. **Recommendation**: Update it to import from `@liberfi.io/eslint-config`, or remove the file if storybook should use the root config.
|
|
34
|
+
|
|
35
|
+
7. **No README.md** — No documentation on what rules are enabled, how to consume the config, or design rationale. **Recommendation**: Add a README per the project's package-readme standards.
|
|
36
|
+
|
|
37
|
+
8. **Config is not parameterisable** — The exported config is a static array; consumers cannot customise it (e.g., add project-specific ignores or rule overrides) without spreading and modifying. **Recommendation**: Consider exporting a function that accepts options (e.g., `{ tailwind: boolean, strict: boolean }`) for flexibility, or document the spread-and-override pattern in the README.
|
|
38
|
+
|
|
39
|
+
9. **`react-hooks/rules-of-hooks` set to `"warn"` instead of `"error"`** — Violating the rules of hooks causes runtime bugs, not style issues. This should almost always be `"error"`. **Recommendation**: Change to `"error"`.
|
|
40
|
+
|
|
41
|
+
## Best Practices Checklist
|
|
42
|
+
|
|
43
|
+
| Practice | Status |
|
|
44
|
+
| ---------------------------- | ---------------------------------------------------- |
|
|
45
|
+
| Decoupling & boundaries | Yes — single shared config at root |
|
|
46
|
+
| Single responsibility | Yes — only provides ESLint config |
|
|
47
|
+
| Inversion of control | Could improve — static config, not parameterisable |
|
|
48
|
+
| DRY / single source of truth | Could improve — duplicate rules, dead code |
|
|
49
|
+
| Dependency hygiene | No — 4 unused dependencies declared |
|
|
50
|
+
| API design | Could improve — no customisation API, no docs |
|
|
51
|
+
| State & side effects | N/A |
|
|
52
|
+
| Presentational vs container | N/A |
|
|
53
|
+
| Type safety | N/A |
|
|
54
|
+
| Testability | N/A |
|
|
55
|
+
| Error handling & feedback | Could improve — phantom rule may cause silent errors |
|
|
56
|
+
| Documentation | No — missing README |
|
|
57
|
+
| Accessibility | N/A |
|
|
58
|
+
| Performance & bundle | Could improve — unused deps increase install time |
|
|
59
|
+
|
|
60
|
+
## Review History
|
|
61
|
+
|
|
62
|
+
| Date | Summary |
|
|
63
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| 2026-03-04 | Initial design review. Identified unused dependencies (4), duplicate rules (3), phantom tailwind rule, excessive dead code, missing README, non-parameterisable config, and storybook referencing non-existent package. |
|
|
65
|
+
|
|
66
|
+
## Conclusion
|
|
67
|
+
|
|
68
|
+
The package successfully centralises ESLint configuration for the monorepo with a modern flat config approach and a well-chosen plugin set. The primary issues are hygiene-related: unused dependencies, duplicate rules, and dead commented-out code that obscure the actual configuration. Cleaning these up, adding a README, and fixing the phantom tailwind rule reference would significantly improve maintainability. The `react-hooks/rules-of-hooks` severity should be raised to `"error"` to prevent runtime bugs.
|
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).
|