|
| 1 | +# @kleros/kleros-v2-eslint-config |
| 2 | + |
| 3 | +Shared ESLint configuration to be used across the Kleros v2 monorepo. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Workspaces that don't need custom rules can use the default config with a one-line `eslint.config.mjs`: |
| 8 | + |
| 9 | +```js |
| 10 | +export { default } from "@kleros/kleros-v2-eslint-config/flat.config.mjs"; |
| 11 | +``` |
| 12 | + |
| 13 | +## Flat-config migration shim |
| 14 | + |
| 15 | +ESLint 9 requires the flat config format (`eslint.config.*`) and no longer reads legacy `.eslintrc` files automatically. `flat.config.mjs` uses `FlatCompat` to translate the legacy `.eslintrc.js` into a flat config, so the existing rules continue to apply. |
| 16 | + |
| 17 | +## What's in the config |
| 18 | + |
| 19 | +### Parser & environments |
| 20 | + |
| 21 | +- **Parser:** `@typescript-eslint/parser` |
| 22 | +- **`parserOptions.ecmaVersion`:** `2020` |
| 23 | +- **Environments enabled:** `browser`, `node`, `es6`, `es2020`, `mocha` |
| 24 | + |
| 25 | +### Extended configs |
| 26 | + |
| 27 | +- `eslint:recommended` — ESLint's built-in baseline rules |
| 28 | +- `plugin:@typescript-eslint/recommended` — TypeScript-aware rules |
| 29 | +- `plugin:prettier/recommended` — runs Prettier as an ESLint rule and disables conflicting style rules |
| 30 | +- `plugin:import/recommended` — import/export hygiene |
| 31 | + |
| 32 | +### Plugins |
| 33 | + |
| 34 | +`@typescript-eslint`, `prettier`, `import`, `n` (Node). |
| 35 | + |
| 36 | +### Custom rule overrides |
| 37 | + |
| 38 | +| Rule | Setting | Why | |
| 39 | +| ------------------------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 40 | +| `no-unused-vars` | `off` | Replaced by the TS-aware variant. | |
| 41 | +| `@typescript-eslint/no-unused-vars` | `error`, with `varsIgnorePattern` / `argsIgnorePattern` | Prefix a name with `_` (e.g. `_unused`, `_1`) or use an `ignored` / `Ignored` suffix to deliberately silence the rule for intentional placeholders. | |
| 42 | +| `prettier/prettier` | `error` | Formatting violations fail lint. | |
| 43 | +| `import/no-unresolved` | `error`, `commonjs: true` | Catches imports that won't resolve at runtime, including CJS `require` paths. | |
| 44 | +| `n/no-unsupported-features/es-syntax` | `error`, `ignores: ["modules"]` | Flags ES syntax not supported by the configured Node target, but allows ES modules. | |
| 45 | +| `n/no-missing-import` | `off` | Resolution is handled by `import/no-unresolved` + the TS resolver. | |
| 46 | + |
| 47 | +### Resolver settings |
| 48 | + |
| 49 | +Imports are resolved via: |
| 50 | + |
| 51 | +- `eslint-import-resolver-typescript` (uses each workspace's `tsconfig.json`) |
| 52 | +- Node resolver, with extensions `.js`, `.jsx`, `.ts`, `.tsx` |
0 commit comments