Skip to content

burtek/eslint-config

Repository files navigation

@dtrw/eslint-config

npm version NPM License Release dependencies

This is repository with my eslint configs for multiple purposes that are used (or will be used) in my other projects.

Install

yarn add -D @dtrw/eslint-config@~6.0.0 eslint

or

npm i -D @dtrw/eslint-config@~6.0.0 eslint

Usage

// 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
);

Configuration

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)

providedConfigs keys

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

Docs

base

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.

cypress

Applies to Cypress spec files (**/*.cy.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).

Plugins: eslint-plugin-cypress

No configuration options.

jest

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

json

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

lodash

Applies to all JS and TS files (**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}).

Plugins: eslint-plugin-lodash

No configuration options.

node

Applies to all JS and TS files (**/*.{js,cjs,mjs,ts,cts,mts}).

Plugins: eslint-plugin-n, eslint-plugin-security-node

No configuration options.

react

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

testingLibrary

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.

About

Repository with collection of my custom eslint configs

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors