Skip to content

Commit b431026

Browse files
committed
chore: add README to shared ESLint config + new root type checking script
1 parent bb76797 commit b431026

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

eslint-config/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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`

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
"build:web:ci": "yarn workspaces focus @kleros/kleros-v2-web && yarn workspaces foreach -Ap --include kleros-app --include contracts run build && yarn workspace @kleros/kleros-v2-web build-netlify",
9595
"build:web-devtools:ci": "yarn workspaces focus @kleros/kleros-v2-web-devtools && yarn workspaces foreach -Ap --include contracts run build && yarn workspace @kleros/kleros-v2-web-devtools build-netlify",
9696
"build:contract-docs": "forge doc --build --out contracts/dist",
97-
"start:contract-docs": "forge doc --serve"
97+
"start:contract-docs": "forge doc --serve",
98+
"check-types": "yarn workspaces foreach -A -v run check-types"
9899
},
99100
"alias": {
100101
"process": "process/browser.js",

0 commit comments

Comments
 (0)