Skip to content

Commit a2f59ef

Browse files
Add eslint v 9 support (#20)
* Set eslint version to 9 * Remove @rushstack/eslint-patch dependency We used modern-module-resolution plugin which seems to be no longer needed in newer ESLint versions. See: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-patch#modern-module-resolution-feature * Update @typescript-eslint and eslint-plugin-import While running this eslint-config against belt, these dependencies needed to get updated. * Update README with working example * Update config for setting jest version * Upgraded package versions to avoid conflicting peer dependencies - we needed to upgrade some dependencies to avoid peer dependency conflicts. The older versions of these packages did not support ESlint 9: - eslint-plugin-jest - eslint-plugin-jsx-a11y - eslint-plugin-react - eslint-plugin-testing-library - removed eslint-plugin-react-native-a11y as it's sadly still not compatible with ESlint 9+. The GitHub repo has an open PR that has not been merged (the PR needs some cleanup) - upgraded ESLint from v9 to v10. Since we're already doing a big version upgrade, we might as well go all the way to the latest * Adjusted package.json - change the eslint dev dependency from 10 to 9. Some of our dependencies don't support 10 yet - also upgrade the eslint peer dependency to >= 9 - add the typescript dev dependency: it's equired by @typescript-eslint - make the jest and typescript peer dependencies optional * Updated the postinstall documentation --------- Co-authored-by: Dave Iverson <[email protected]>
1 parent 0cb5ace commit a2f59ef

11 files changed

Lines changed: 1544 additions & 734 deletions

File tree

README.md

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,58 +38,52 @@ The configurations that include Prettier turn off all formatting rules that are
3838

3939
### Example usage:
4040

41-
Following are some example usages of this config (eg. in `.eslintrc.js`).
41+
Following are some example usages of this config (eg. in `eslint.config.mjs`).
4242

4343
React with TypeScript:
4444

45-
```json
46-
{
47-
"extends": [
48-
"@thoughtbot/eslint-config",
49-
"@thoughtbot/eslint-config/typescript"
50-
]
51-
}
45+
```js
46+
extends: compat.extends(
47+
'@thoughtbot/eslint-config',
48+
'@thoughtbot/eslint-config/typescript',
49+
)
5250
```
5351

5452
React Native with TypeScript:
5553

56-
```json
57-
{
58-
"extends": [
59-
"@thoughtbot/eslint-config/native",
60-
"@thoughtbot/eslint-config/typescript"
61-
]
62-
}
54+
```js
55+
extends: compat.extends(
56+
'@thoughtbot/eslint-config/native',
57+
'@thoughtbot/eslint-config/typescript'
58+
)
6359
```
6460

6561
Base web without React or TypeScript
6662

67-
```json
68-
{
69-
"extends": ["@thoughtbot/eslint-config/base"]
70-
}
63+
```js
64+
extends: compat.extends(
65+
'@thoughtbot/eslint-config/base',
66+
)
7167
```
7268

7369
You can override rules from the shared configuration, by setting your
7470
own values within the `rules` property:
7571

76-
```json
77-
{
78-
"extends": "@thoughtbot/eslint-config",
79-
"rules": {
80-
"react/jsx-newline": "warn"
72+
```js
73+
rules: {
74+
'no-console': 'off',
75+
'import/order': 'off',
8176
}
82-
}
8377
```
8478

8579
You might also need to add the following to your ESLint config if you get an error about Jest not being able to detect the version:
8680

87-
```json
88-
{
89-
"settings": {
90-
"jest": { "version": "detect" }
91-
}
92-
}
81+
```js
82+
settings: {
83+
jest: {
84+
version: 'detect',
85+
},
86+
},
9387
```
9488

9589
Consult the [ESLint documentation][eslint-configuration] for more information about configuring ESLint, and take a look at the config files in this repo for more information about the rules and plugins they include.
@@ -98,7 +92,7 @@ Consult the [ESLint documentation][eslint-configuration] for more information ab
9892

9993
## License
10094

101-
thoughtbot ESLint Config is copyright (c) 2023 thoughtbot, inc.
95+
thoughtbot ESLint Config is copyright (c) 2026 thoughtbot, inc.
10296
It is free software, and may be redistributed under the
10397
terms specified in the [LICENSE] file.
10498

base.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
module.exports = {
52
env: {
63
browser: true,

bin/postinstall.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ console.log(
22
`thoughtbot/eslint-config installed! Use it by updating your ESLint configuration with:
33
44
{
5-
"extends": [
6-
"@thoughtbot/eslint-config",
7-
"@thoughtbot/eslint-config/typescript"
8-
]
5+
extends: compat.extends(
6+
'@thoughtbot/eslint-config',
7+
'@thoughtbot/eslint-config/typescript',
8+
)
99
}
1010
1111
Don't forget to also add a script in your package.json file:
1212
1313
"lint": "eslint --max-warnings=0 --ext js,jsx,ts,tsx .",
14-
`
14+
`,
1515
);

index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
module.exports = require('./react.js');

native.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
module.exports = {
52
extends: [
63
'plugin:react-native-a11y/all',

package.json

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,33 @@
2626
"postinstall": "node bin/postinstall.js"
2727
},
2828
"peerDependencies": {
29-
"eslint": ">= 5.7.0",
29+
"eslint": ">= 9",
3030
"jest": ">= 25.0.0",
3131
"typescript": ">= 4.0.0"
3232
},
33+
"peerDependenciesMeta": {
34+
"typescript": {
35+
"optional": true
36+
},
37+
"jest": {
38+
"optional": true
39+
}
40+
},
3341
"devDependencies": {
34-
"eslint": "^8.42.0"
42+
"eslint": "^9.0.0",
43+
"typescript": "^5.9.3"
3544
},
3645
"dependencies": {
37-
"@rushstack/eslint-patch": "^1.3.1",
38-
"@typescript-eslint/eslint-plugin": "^5.59.9",
39-
"@typescript-eslint/parser": "^5.59.9",
46+
"@typescript-eslint/eslint-plugin": "8",
47+
"@typescript-eslint/parser": "8",
4048
"confusing-browser-globals": "^1.0.11",
4149
"eslint-config-prettier": ">= 8.7.0",
4250
"eslint-import-resolver-typescript": "^3.5.5",
43-
"eslint-plugin-import": "^2.27.5",
44-
"eslint-plugin-jest": "^27.2.1",
45-
"eslint-plugin-jsx-a11y": "^6.7.1",
46-
"eslint-plugin-react": "^7.32.2",
51+
"eslint-plugin-import": "^2.32.0",
52+
"eslint-plugin-jest": "^29.13.0",
53+
"eslint-plugin-jsx-a11y": "^6.10.1",
54+
"eslint-plugin-react": "^7.37.5",
4755
"eslint-plugin-react-hooks": "^5.0.0",
48-
"eslint-plugin-react-native-a11y": "^3.3.0",
49-
"eslint-plugin-testing-library": "^5.11.0"
56+
"eslint-plugin-testing-library": "^7.15.4"
5057
}
5158
}

prettier.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
module.exports = {
52
extends: ['prettier'],
63
};

react-base.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
// base used for both React web and React Native
52
module.exports = {
63
env: { jest: true },

react.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
2-
require('@rushstack/eslint-patch/modern-module-resolution');
3-
41
module.exports = {
52
extends: ['./react-base', './prettier'],
63
};

typescript.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('@rushstack/eslint-patch/modern-module-resolution');
2-
31
module.exports = {
42
parser: '@typescript-eslint/parser',
53
extends: [

0 commit comments

Comments
 (0)