Skip to main content

Shareable Configurations

Shareable configs allow you to package and distribute ESLint configurations across multiple projects. They’re perfect for enforcing team standards, company-wide rules, or community best practices.

What is a Shareable Config?

A shareable config is an npm package that exports an ESLint configuration object or array. It enables:
  • Consistent linting across projects
  • Team coding standards
  • Framework-specific configurations
  • Company-wide rule enforcement
  • Easy configuration updates
Popular Shareable Configs:
  • @eslint/js - ESLint’s official JavaScript configs
  • eslint-config-airbnb - Airbnb’s JavaScript style guide
  • eslint-config-standard - JavaScript Standard Style
  • eslint-config-prettier - Disable conflicting Prettier rules

Creating a Shareable Config

1

Create npm Package

Initialize a new package:
2

Create Configuration File

Create index.js as the entry point:
index.js
3

Configure package.json

package.json
4

Publish

Config Naming Conventions

Follow these naming conventions:Unscoped:
  • Begin with eslint-config-
  • Example: eslint-config-myconfig
Scoped:
  • Format: @scope/eslint-config or @scope/eslint-config-name
  • Examples: @company/eslint-config, @company/eslint-config-react

Basic Config Structure

Export an array of configuration objects:
index.js

Single Config Object

You can also export a single configuration:
index.js
When exporting a single object, make sure your documentation clearly shows how to use it with the extends key in eslint.config.js.

Using a Shareable Config

Install and use the config:

Extending Configurations

Build on top of other configs:
index.js

Overriding Settings

Users can override your config:
eslint.config.js

Multiple Configurations

Export multiple configs from one package:
Users can import specific configs:
eslint.config.js

Dynamic Configurations

Generate configs programmatically:
index.js
Usage:
eslint.config.js

Including Plugins

Bundle plugins with your config:
index.js
Dependencies: Add plugins as dependencies (not peerDependencies) in your package.json:

Including Parsers

Bundle custom parsers:
index.js

Real-World Example

Comprehensive config for React projects:
index.js

File-Specific Configs

Provide different configs for different file types:
index.js

Environment-Specific Configs

Create configs for different environments:

Testing Configs

Test your shareable config:
test/config.test.js

Documentation Template

Provide clear documentation:
README.md

Publishing Checklist

1

Package Configuration

  • Correct main entry point
  • Appropriate keywords in package.json
  • peerDependencies for ESLint
  • dependencies for included plugins
2

Documentation

  • Comprehensive README
  • Installation instructions
  • Usage examples
  • Rule documentation
  • Migration guide (if updating)
3

Testing

  • Test config with ESLint
  • Verify all plugins work
  • Test overrides
  • Check edge cases
4

Versioning

  • Follow semantic versioning
  • Maintain changelog
  • Document breaking changes

Maintenance

Version Updates

Update peer dependencies:
package.json

Deprecation

When deprecating rules:

Best Practices

Follow these guidelines:
  1. Keep configs focused - One concern per config
  2. Document thoroughly - Examples for every rule
  3. Test configurations - Verify with real code
  4. Version carefully - Breaking changes need major version bump
  5. Stay updated - Keep plugin dependencies current
  6. Provide overrides - Make configs customizable

Config Organization

Legacy Config Support

Support both flat and legacy formats:
index.js
Users choose format:

Real-World Examples

@eslint/js

Official ESLint JavaScript configs

eslint-config-airbnb

Airbnb’s style guide

eslint-config-standard

JavaScript Standard Style

eslint-config-prettier

Disable Prettier conflicts

Next Steps

Create a Plugin

Package rules with your config

Custom Rules

Add custom rules to your config