Create your own ESLint config and share it across projects
If you've ever worked on multiple projects, you know the pain of copying ESLint configurations between repositories. Every time you set up a new project, you either start from scratch or copy the eslint.config.js file from your last one. There's a better way: publish your own shareable ESLint config package.
Why I love antfu/eslint-config
Discovering @antfu/eslint-config changed how I configure ESLint. The move to "Flat Config" seemed unnecessary to me, until Anthony Fu built a config that makes ESLint simple to set up and extend.
Instead of juggling dozens of plugins, configurations and dependencies, you install one package and you're done. It's zero config by default: you import it, export it, and it respects your .gitignore. It looks at your project and enables the right rules for Vue, TypeScript or plain JavaScript, with opinionated defaults you can override.
It also formats your code, so for most projects you don't need Prettier. Besides JavaScript and TypeScript, it handles JSON, Markdown and YAML, so ESLint manages everything.
For my usual stack (Vue and TypeScript), it's the best starting point for configuring ESLint.
Why create your own ESLint config package?
Extending antfu's config with my own preferences and plugins is simple, since it's designed for composing your own configuration. I'm used to ending lines with semicolons, indenting with 2 spaces and putting the <template> at the top of my .vue files.
But the real value isn't personal taste. It's consistency and reuse. Once you publish your ESLint config as an npm package, you can:
- Add plugins for specific libraries that can't be part of
antfu's core. - Use it in all your repositories, with the same rules everywhere.
- Version your linting rules: update the package, bump it in your projects, and they all get the new rules.
- Share it with your team or make it public.
- Maintain it in one place instead of updating the same rules in 10 projects.
My config: @angelblanco/eslint-config
My configuration, @angelblanco/eslint-config, is available on npm, and the source code is on GitHub:
How to create your own
Creating your own ESLint config is straightforward. Instead of starting from scratch, you can fork mine:
- Fork @angelblanco/eslint-config.
- Register on npm with your GitHub username.
- Update
package.jsonwith your own package name, for example@yourname/eslint-config, and the rest of the details. - Install the dependencies with
pnpm install. - Customize the rules in
index.ts. - Build the JavaScript output with tsup by running
pnpm build. - Publish it with
npm publish --access public. - Install
@yourname/eslint-configin your other repositories and import it in their ESLint config.
The README in my repository has up-to-date installation instructions, usage examples and every rule I changed. Open an issue if you want a hand.
Make it yours
You don't need to reinvent the wheel. Start from something solid like @antfu/eslint-config, adjust it to your taste and publish it. The whole process takes about an hour, and you end up with one versioned linting configuration for all your projects.
If you work with Vue and TypeScript, try antfu's config or mine. If neither is exactly what you want, fork it and make it yours.