A modern, TypeScript-first template for building ESLint plugins (Flat Config ready)
This repository is a starter template for creating your own ESLint plugin with:
- ESLint 9 Flat Config support out of the box
- TypeScript with strong typing for rules and options
- Vitest-based rule tests via eslint-vitest-rule-tester
- Rule scaffolding script to generate rule code, tests, and docs
- Auto-generated README rules section via eslint-doc-generator
Use it as a “Use this template” on GitHub or fork and rename.
- Create your repo from this template
- Click “Use this template” on GitHub, or
- Degit locally:
degit christopher-buss/eslint-plugin-template my-plugin
- Install dependencies
pnpm i- Rename the package and plugin
Update these fields to your plugin name (e.g., eslint-plugin-awesome):
package.json→name,description,repository,author,license- README title and badges
The runtime plugin name (used in config) is derived from the package name by
removing the eslint-plugin- prefix. For eslint-plugin-awesome the plugin key
becomes awesome.
- Scaffold your first rule
pnpm create-rule my-new-ruleThis generates:
src/rules/my-new-rule/rule.ts– rule implementationsrc/rules/my-new-rule/rule.spec.ts– testssrc/rules/my-new-rule/documentation.md– rule docs
- Run tests and docs
pnpm test
pnpm eslint-docsThe docs command updates the auto-generated rules list in this README.
Once published to npm as eslint-plugin-awesome, you can enable it in a
project.
// eslint.config.js / eslint.config.mjs / eslint.config.ts
import yourPlugin from "eslint-plugin-awesome";
export default [
// Enable all recommended rules from your plugin
yourPlugin.configs.recommended,
// Or wire it manually
{
plugins: {
awesome: yourPlugin,
},
rules: {
"awesome/my-new-rule": "error",
},
},
];{
"extends": ["plugin:yourname/recommended"]
}Scripts you’ll use during development:
pnpm dev– fast stub build for local iterationpnpm build– type-safe build with d.ts via tsdownpnpm test– run Vitest testspnpm lint– run ESLint on this repopnpm typecheck– runtsc --noEmitpnpm eslint-docs– regenerate README rules listpnpm release– bump version via bumpp
Requirements:
- Node.js >= 20
- pnpm >= 10
- ESLint >= 9.15.0 (peer dep for consumers)
src/
configs/ # Flat config presets (e.g., recommended)
rules/ # Your rules (each in its own folder)
plugin.ts # Plugin host (name, version, rules)
util.ts # Rule creator with docs links
index.ts # Entry combining plugin + configs (default export)
scripts/
create-rule.ts # Scaffolds a new rule (code, tests, docs)
template/ # Rule templates used by the script
{ "extends": ["plugin:awesome/recommended"] }
- The plugin key is computed from your package name (see
src/plugin.ts). src/configs/recommendedis provided for convenience; add your rules there when ready.
pnpm create-rule my-new-ruleWhat happens:
- Creates
src/rules/my-new-rule/withrule.ts,rule.spec.ts,documentation.md. - Attempts to register the rule. If automatic edit cannot be applied, the script prints the exact import and entry you can paste into your plugin/index file.
- Run
pnpm testto validate, thenpnpm eslint-docsto refresh this README.
Typical flow:
pnpm test
pnpm build
pnpm release # chooses the next semver and commits tags
# CI publishes to npmGenerate this section with:
pnpm eslint-docsPRs and issues welcome. If you’re using this as a template, adapt the sections to your needs and replace the badges and links.
MIT © 2025 Christopher Buss