|
| 1 | +# ESLint Config |
| 2 | + |
| 3 | +ESLint configuration tailored for Redux projects. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +#### NPM |
| 8 | + |
| 9 | +```bash |
| 10 | +npm install --save-dev @reduxjs/eslint-config |
| 11 | +``` |
| 12 | + |
| 13 | +#### Yarn |
| 14 | + |
| 15 | +```bash |
| 16 | +yarn add --dev @reduxjs/eslint-config |
| 17 | +``` |
| 18 | + |
| 19 | +#### PNPM |
| 20 | + |
| 21 | +```bash |
| 22 | +pnpm add --save-dev @reduxjs/eslint-config |
| 23 | +``` |
| 24 | + |
| 25 | +#### Bun |
| 26 | + |
| 27 | +```bash |
| 28 | +bun add --dev @reduxjs/eslint-config |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +**ECMAScript Modules (ESM) usage inside a file like `eslint.config.mts` or `eslint.config.mjs`**: |
| 34 | + |
| 35 | +```ts |
| 36 | +import { reduxESLintConfig } from '@reduxjs/eslint-config' |
| 37 | + |
| 38 | +export default reduxESLintConfig |
| 39 | +``` |
| 40 | + |
| 41 | +**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using `require`)**: |
| 42 | + |
| 43 | +```ts |
| 44 | +const { reduxESLintConfig } = require('@reduxjs/eslint-config') |
| 45 | + |
| 46 | +module.exports = reduxESLintConfig |
| 47 | +``` |
| 48 | + |
| 49 | +**CommonJS (CJS) usage inside a file like `eslint.config.cjs` or `eslint.config.cts` (using dynamic import)**: |
| 50 | + |
| 51 | +```ts |
| 52 | +module.exports = (async () => |
| 53 | + (await import('@reduxjs/eslint-config')).reduxESLintConfig)() |
| 54 | +``` |
| 55 | + |
| 56 | +**CommonJS (CJS) usage inside a file like `eslint.config.cts` (using import and export assignment)**: |
| 57 | + |
| 58 | +```ts |
| 59 | +import ReduxESLintConfig = require('@reduxjs/eslint-config') |
| 60 | +import reduxESLintConfig = ReduxESLintConfig.reduxESLintConfig |
| 61 | + |
| 62 | +export = reduxESLintConfig |
| 63 | +``` |
| 64 | + |
| 65 | +Navigating ESLint's configuration options can occasionally feel overwhelming, especially when trying to take advantage of TypeScript's strong typing for better IntelliSense support. To alleviate this complexity and enhance your development experience, we also provide a function called `createESLintConfig` that you can import and use to create your own ESLint configuration. This function already includes the default `reduxESLintConfig` and you can pass in an array of flat configs as additional overrides. |
| 66 | + |
| 67 | +**ECMAScript Modules (ESM) usage inside a file like `eslint.config.mts` or `eslint.config.mjs`**: |
| 68 | + |
| 69 | +```ts |
| 70 | +import { createESLintConfig } from '@reduxjs/eslint-config' |
| 71 | + |
| 72 | +export default createESLintConfig([ |
| 73 | + { |
| 74 | + rules: { |
| 75 | + 'no-console': [0], |
| 76 | + }, |
| 77 | + }, |
| 78 | + { |
| 79 | + // ...Other additional overrides |
| 80 | + }, |
| 81 | +]) |
| 82 | +``` |
| 83 | + |
| 84 | +**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using `require`)**: |
| 85 | + |
| 86 | +```ts |
| 87 | +const { createESLintConfig } = require('@reduxjs/eslint-config') |
| 88 | + |
| 89 | +module.exports = createESLintConfig([ |
| 90 | + { |
| 91 | + rules: { |
| 92 | + 'no-console': [0], |
| 93 | + }, |
| 94 | + }, |
| 95 | + { |
| 96 | + // ...Other additional overrides |
| 97 | + }, |
| 98 | +]) |
| 99 | +``` |
| 100 | + |
| 101 | +**CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using dynamic import)**: |
| 102 | + |
| 103 | +```ts |
| 104 | +module.exports = (async () => |
| 105 | + (await import('@reduxjs/eslint-config')).createESLintConfig([ |
| 106 | + { |
| 107 | + rules: { |
| 108 | + 'no-console': [0], |
| 109 | + }, |
| 110 | + }, |
| 111 | + { |
| 112 | + // ...Other additional overrides |
| 113 | + }, |
| 114 | + ]))() |
| 115 | +``` |
| 116 | + |
| 117 | +**CommonJS (CJS) usage inside a file like `eslint.config.cts` (using import and export assignment)**: |
| 118 | + |
| 119 | +```ts |
| 120 | +import ReduxESLintConfig = require('@reduxjs/eslint-config') |
| 121 | +import createESLintConfig = ReduxESLintConfig.createESLintConfig |
| 122 | + |
| 123 | +export = createESLintConfig([ |
| 124 | + { |
| 125 | + rules: { |
| 126 | + 'no-console': [0], |
| 127 | + }, |
| 128 | + }, |
| 129 | + { |
| 130 | + // ...Other additional overrides |
| 131 | + }, |
| 132 | +]) |
| 133 | +``` |
0 commit comments