ESLint Configuration
Detailed guide for configuring ESLint with JS Style Kit
Overview
JS Style Kit provides a comprehensive ESLint configuration using the modern ESLint v9 flat config format. This configuration includes sensible defaults for JavaScript and TypeScript projects, with optional support for React, testing frameworks, and code organization.
Basic Setup
Create an eslint.config.js
file in your project root:
If your project doesn’t use ESM, create an eslint.config.mjs
file instead:
Add the linting scripts to your package.json
:
Configuration Options
The eslintConfig()
function accepts a configuration object with the following options:
Function Style Configuration
Controls how functions should be written throughout your codebase. Some configurations are auto-fixable, but some may require manual adjustment.
TypeScript Configuration
TypeScript support is enabled by default. You can:
React Configuration
React support is disabled by default.
JSDoc Configuration
JSDoc validation is enabled by default, but requirement rules are off:
Sorting Configuration
Code organization rules from Perfectionist are enabled by default:
Testing Configuration
Testing support is enabled by default with Vitest configuration:
Storybook Configuration
Storybook support is disabled by default.
Additional Rules
Adding Ignores
By default, JS Style Kit ignores node_modules
and dist
directories. You can add additional paths to ignore:
Custom ESLint Configurations
You can extend the base configuration by providing additional ESLint config objects as rest parameters:
Migrating from ESLint Legacy Config
If you’re coming from a legacy ESLint configuration (.eslintrc.js
or other formats), you’ll need to adapt to the new flat config format. Here are some key differences:
- The configuration file is now named
eslint.config.js
oreslint.config.mjs
- The format is different, using an array of configuration objects rather than a nested object
- Plugins, parsers, and other extensions are imported directly rather than being referenced by string names
JS Style Kit handles most of this complexity for you, so you can focus on the configuration options that matter for your project.
For more details on ESLint flat config, see the ESLint documentation.