Linting
Enforce RouteCraft best practices with ESLint.
Installation
npm install -D eslint @eslint/js typescript-eslint @routecraft/eslint-plugin-routecraft
Configuration
Add the plugin to your ESLint flat config and spread the recommended preset:
// eslint.config.mjs
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import routecraftPlugin from '@routecraft/eslint-plugin-routecraft'
/** @type {import('eslint').Linter.Config[]} */
export default [
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.{js,mjs,cjs,ts}'],
plugins: { '@routecraft/routecraft': routecraftPlugin },
...routecraftPlugin.configs.recommended,
},
]
The recommended preset enables all rules at their default levels. See the Linting reference for the full rule list and defaults.
Presets
The plugin ships two presets:
| Preset | Description |
|---|---|
routecraftPlugin.configs.recommended | Recommended rules at their default levels |
routecraftPlugin.configs.all | All rules enabled as errors |
Use recommended for most projects. Use all if you want to enforce every rule strictly from the start.
Customizing severity
Override individual rules in your config to change severity or disable them:
// eslint.config.mjs
export default [
// ... other configs
{
files: ['**/*.{js,mjs,cjs,ts}'],
plugins: { '@routecraft/routecraft': routecraftPlugin },
...routecraftPlugin.configs.recommended,
rules: {
// Downgrade to a warning
'@routecraft/routecraft/require-named-route': 'warn',
// Elevate to an error
'@routecraft/routecraft/batch-before-from': 'error',
// Turn off entirely
'@routecraft/routecraft/mcp-server-options': 'off',
},
},
]
Valid severity values: 'error', 'warn', 'off' (or 2, 1, 0).
Related
Linting reference
Full rule catalog with defaults and descriptions.