adapter-eslint
Runs ESLint via the Node API and generates an eslint.config.js bridge file for IDE integration.
Package: @retemper/lodestar-adapter-eslint
Managed file: eslint.config.js
Config Options
| Option | Type | Description |
|---|---|---|
presets | string[] | Base configs -- 'recommended', 'strict', 'stylistic' (mapped to typescript-eslint) |
plugins | Record<string, unknown> | ESLint plugin packages to include |
rules | Record<string, unknown> | ESLint rules with standard severity/options format |
ignores | string[] | Global ignore patterns |
overrides | { files: string[]; rules: Record<string, unknown> }[] | File-specific rule overrides |
Example
import { eslintAdapter } from '@retemper/lodestar-adapter-eslint';
import importX from 'eslint-plugin-import-x';
import unicorn from 'eslint-plugin-unicorn';
eslintAdapter({
presets: ['strict'],
plugins: { 'import-x': importX, unicorn },
ignores: ['dist/**', 'node_modules/**'],
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'import-x/no-default-export': 'error',
'unicorn/prefer-node-protocol': 'error',
},
overrides: [
{
files: ['**/*.spec.ts'],
rules: { '@typescript-eslint/no-explicit-any': 'off' },
},
],
});Generated Bridge File
verifySetup checks that eslint.config.js exists at the project root with the following content:
import { fromLodestar } from '@retemper/lodestar-adapter-eslint';
export default await fromLodestar();This bridge file delegates to lodestar config at runtime, so IDEs and CI both read the same rules. If the file is missing, a setup violation is reported. If the file exists but its content does not match the expected bridge, a drift violation is reported.
Running lodestar check --fix auto-creates or updates the bridge file to resolve setup violations.
How verifySetup Works
- Checks that
eslint.config.jsexists inrootDir. - Reads the file content and compares it against the expected bridge file content.
- Returns a missing violation if the file does not exist.
- Returns a drift violation (with a diff of expected vs actual) if the content does not match.
- Returns no violations if the bridge file is correct.
Drift means the bridge file was manually edited or generated by another tool. The fix is to let lodestar regenerate it.
How check Works
The adapter uses ESLint's Node API to lint files programmatically:
- Builds a flat config from the adapter options (presets, plugins, rules, overrides).
- Creates an
ESLintinstance withoverrideConfigFile: trueso the bridge file is bypassed during checks. - Runs
eslint.lintFiles()on the configured file patterns. - Maps each ESLint message to a lodestar
Violationwith the original ESLint rule ID prefixed aseslint/{rule-name}.
Severity mapping: ESLint severity 2 becomes 'error', severity 1 becomes 'warn'.
Auto-fix
The adapter implements fix(), which runs ESLint with fix: true enabled. Running lodestar check --fix invokes this to auto-fix applicable ESLint violations, then writes the changes back to disk via ESLint.outputFixes().