Skip to content

Commit e4e644d

Browse files
authored
Merge pull request #34 from GetResponse/eslint10
feat: migrate to ESLint flat config and bump peer dep to ESLint 9/10
2 parents eed1a6b + ab88fd4 commit e4e644d

27 files changed

Lines changed: 2315 additions & 9948 deletions

.eslintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,85 @@
77

88
---
99

10-
An opinionated ESLint ruleset targeting TypeScript + React web apps
10+
An opinionated ESLint ruleset targeting TypeScript + React web apps.
1111

1212
## Requirements
1313

14-
- ESLint `^8.48.0`
14+
- ESLint `^9.0.0`
15+
- Node `>=18.18`
1516

1617
## Installation
1718

18-
1. Install `eslint` and `@getresponse/eslint-config`:
19+
```bash
20+
npm i -D eslint @getresponse/eslint-config
21+
```
22+
23+
## Usage
24+
25+
Create `eslint.config.js` in your project root:
26+
27+
```js
28+
import config from '@getresponse/eslint-config';
29+
30+
export default config;
31+
```
1932

20-
```bash
21-
npm i -D eslint @getresponse/eslint-config
22-
```
33+
With local overrides:
2334

24-
2. Add `"extends": "@getresponse/eslint-config"` to your ESLint [configuration file](https://eslint.org/docs/latest/user-guide/configuring/configuration-files)
35+
```js
36+
import { defineConfig } from 'eslint/config';
37+
import config from '@getresponse/eslint-config';
38+
39+
export default defineConfig(
40+
config,
41+
{
42+
files: ['src/legacy/**/*.ts'],
43+
rules: {
44+
'@typescript-eslint/no-explicit-any': 'off',
45+
},
46+
},
47+
);
48+
```
2549

2650
## TypeScript project files
2751

28-
Since `@typescript-eslint` v8, all linted `.ts`/`.tsx` files must be included in your `tsconfig.json`. Files outside the project will cause an error when type-aware rules are active. Make sure your `tsconfig.json` (or a dedicated `tsconfig.eslint.json`) covers all files you want to lint:
52+
Rules requiring type information use `projectService` (auto-discovery). The package automatically:
53+
54+
- finds the nearest `tsconfig.json` for each linted file,
55+
- uses `tsconfig.eslint.json` (if present in the project root) as fallback for files outside any project — typical for config files, scripts, and tests.
56+
57+
If you have files outside `src/` you want linted, point them at a dedicated `tsconfig.eslint.json`:
2958

3059
```json
3160
{
32-
"include": ["src/**/*", "tests/**/*"]
61+
"extends": "./tsconfig.json",
62+
"include": ["src/**/*", "tests/**/*", "scripts/**/*"]
3363
}
3464
```
3565

3666
## Dynamic rules
3767

38-
Rules for the following tools are enabled automatically when the corresponding package is detected in your `package.json`:
68+
Plugin rulesets are enabled automatically when the corresponding package is detected in your `package.json`:
3969

4070
- `typescript`
41-
- `react`
71+
- `react` (+ `react-hooks`)
4272
- `jest`
4373
- `@playwright/test` / `playwright`
4474

4575
## Mixins
4676

47-
Additional opt-in rulesets are available:
77+
Additional opt-in rulesets:
4878

4979
```js
50-
// .eslintrc.js
51-
module.exports = {
52-
extends: [
53-
'@getresponse/eslint-config',
54-
'@getresponse/eslint-config/mixins/a11y',
55-
],
56-
};
80+
import { defineConfig } from 'eslint/config';
81+
import config from '@getresponse/eslint-config';
82+
import a11y from '@getresponse/eslint-config/mixins/a11y';
83+
84+
export default defineConfig(config, a11y);
5785
```
5886

59-
| Mixin | Description |
60-
|---|---|
87+
| Mixin | Description |
88+
|------------------------------------------|---|
6189
| `@getresponse/eslint-config/mixins/a11y` | Accessibility rules via `eslint-plugin-jsx-a11y` |
6290

6391
## Rules list

eslint.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import config from '@getresponse/eslint-config';
3+
4+
export default defineConfig(globalIgnores(['dist/**', 'eslint.config.ts']), config);

0 commit comments

Comments
 (0)