This is repository with my eslint configs for multiple purposes that are used (or will be used) in my other projects.
yarn add -D @dtrw/eslint-config@~6.0.0 eslintor
npm i -D @dtrw/eslint-config@~6.0.0 eslint// eslint.config.js
import { config, prepareConfig } from '@dtrw/eslint-config'; // config re-exported from eslint/config
export default prepareConfig(configuration)
//or
export default config(
...prepareConfig(configuration),
...moreFlatConfigs
);prepareConfig accepts up to three arguments:
prepareConfig(providedConfigs?, ignores?, baseConfig?)| Argument | Type | Default | Description |
|---|---|---|---|
providedConfigs |
object |
{} |
Feature configs to enable (see keys below) |
ignores |
string[] or (defaults: string[]) => string[] |
['node_modules/', 'dist/', 'coverage/', '.vercel/'] |
Glob patterns for files ESLint should ignore. Pass a function to modify the defaults. |
baseConfig |
object |
— | Experimental options passed to the base config (see base) |
Each key can be set to true to enable the config with default options, or to an options object for additional configuration. All keys are optional.
| Key | Options | Description |
|---|---|---|
cypress |
(none) | Enables Cypress test linting |
jest |
{ mode?: 'jest' | 'vitest' } |
Enables Jest / Vitest test linting |
json |
{ additionalFiles?: { json?: string[], jsonc?: string[], json5?: string[] } } |
Enables JSON / JSONC / JSON5 linting |
lodash |
(none) | Enables Lodash best-practice rules |
node |
(none) | Enables Node.js-specific rules |
react |
{ a11y?: boolean, nextjs?: boolean } |
Enables React linting, with optional accessibility and Next.js support |
testingLibrary |
(none) | Enables Testing Library and jest-dom rules |
Always enabled. Applies to all JS and TS files (**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).
Plugins: @eslint/js, typescript-eslint, eslint-plugin-import-x, eslint-plugin-promise, @stylistic/eslint-plugin
baseConfig options:
| Option | Type | Default | Description |
|---|---|---|---|
nextResolver |
boolean |
true |
Use the TypeScript import resolver from eslint-import-resolver-typescript. Set to false to use the legacy resolver instead. |
Applies to Cypress spec files (**/*.cy.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).
Plugins: eslint-plugin-cypress
No configuration options.
Applies to test files (**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}) and mock files (**/__mocks__/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).
Plugins: eslint-plugin-jest
Options:
| Option | Type | Default | Description |
|---|---|---|---|
mode |
'jest' | 'vitest' |
'jest' |
Set to 'vitest' to configure the plugin for use with Vitest instead of Jest |
Applies to JSON files. Strict JSON rules apply to **/*.json files (except well-known JSONC files such as tsconfig.json and .vscode/**/*.json). JSONC rules apply to **/*.jsonc and known JSONC files. JSON5 rules apply to **/*.json5.
Plugins: @eslint/json, eslint-plugin-jsonc
Options:
| Option | Type | Default | Description |
|---|---|---|---|
additionalFiles.json |
string[] |
[] |
Additional glob patterns to treat as strict JSON |
additionalFiles.jsonc |
string[] |
[] |
Additional glob patterns to treat as JSONC |
additionalFiles.json5 |
string[] |
[] |
Additional glob patterns to treat as JSON5 |
Applies to all JS and TS files (**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).
Plugins: eslint-plugin-lodash
No configuration options.
Applies to all JS and TS files (**/*.{js,cjs,mjs,ts,cts,mts}).
Plugins: eslint-plugin-n, eslint-plugin-security-node
No configuration options.
Applies to all JS and TS files (**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}). JSX-specific rules additionally apply to **/*.{jsx,tsx}.
Plugins: @eslint-react/eslint-plugin, @stylistic/eslint-plugin (JSX rules)
Options:
| Option | Type | Default | Description |
|---|---|---|---|
a11y |
boolean |
false |
Enable accessibility (a11y) rules via eslint-plugin-jsx-a11y |
nextjs |
boolean |
false |
Enable Next.js rules via @next/eslint-plugin-next |
Applies to test files (**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).
Plugins: eslint-plugin-jest-dom, eslint-plugin-testing-library
No configuration options.