Skip to content

Commit 9627d49

Browse files
committed
chore(deps): FE-454 Update to ESLint 9
1 parent 2b08126 commit 9627d49

37 files changed

Lines changed: 12115 additions & 4256 deletions

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,18 @@ For installation guide and setup please visit each package's readme.
88

99
[@bigcommerce/eslint-plugin](packages/eslint-plugin)
1010

11-
## ESlint 9 Compatibility
12-
Due to a [significant change](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) in ESLint 9, this configuration set currently **requires** ESLint 8. In order to avoid peer dependency resolution issues, you need to also install `eslint` in your project, using the same version range as that found in [package.json](./package.json).
11+
## ESLint 9 Compatibility
12+
13+
This configuration now **requires ESLint 9** and uses the new [flat config format](https://eslint.org/docs/latest/use/configure/configuration-files).
14+
15+
### Breaking Changes from v2.x
16+
17+
- **ESLint 9 Required**: This version requires ESLint ^9.0.0
18+
- **Flat Config Format**: Configurations now use ESLint's flat config format
19+
- **ES Modules**: All packages now use ES modules (`"type": "module"`)
20+
- **No Patch Required**: The `require('@bigcommerce/eslint-config/patch')` is no longer needed (and won't work)
21+
- **Import Instead of Require**: Use `import` instead of `require` in your config files
22+
23+
### Migration Guide
24+
25+
See the package README files for migration instructions from ESLint 8 to ESLint 9.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"scripts": {
1717
"lint": "eslint . --ext .js",
1818
"release": "lerna publish --sign-git-commit --sign-git-tag --git-remote origin --pre-dist-tag next",
19-
"test": "jest --projects packages/*"
19+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest --projects packages/*"
2020
},
2121
"devDependencies": {
22-
"eslint": "^8.14.0",
22+
"eslint": "^9.0.0",
2323
"jest": "^29.7.0",
2424
"lerna": "^8.1.2",
2525
"typescript": "^5.0.2"

packages/eslint-config/README.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
# @bigcommerce/eslint-config
22

3-
This package is a configuration preset for [ESLint](https://eslint.org/).
4-
3+
This package is a configuration preset for [ESLint](https://eslint.org/) using the new flat config format (ESLint 9+).
54

65
## Install
76

87
```sh
9-
npm install --save-dev eslint prettier
8+
npm install --save-dev eslint@^9.0.0 prettier
109
npm install --save-dev @bigcommerce/eslint-config
1110
```
1211

13-
1412
## Usage
1513

16-
Add `@bigcommerce/eslint-config` to your project's ESLint configuration file. i.e.:
14+
Create an `eslint.config.js` file in your project root:
1715

1816
```js
19-
// .eslintrc.js
20-
require('@bigcommerce/eslint-config/patch');
17+
// eslint.config.js
18+
import config from '@bigcommerce/eslint-config';
2119

22-
module.exports = {
23-
extends: ['@bigcommerce/eslint-config'],
24-
};
20+
export default config;
2521
```
2622

27-
This config also runs prettier via eslint, add the following to your `package.json`
23+
This config also runs prettier via eslint, add the following to your `package.json`:
24+
2825
```json
2926
{
3027
"prettier": "@bigcommerce/eslint-config/prettier"
@@ -33,28 +30,49 @@ This config also runs prettier via eslint, add the following to your `package.js
3330

3431
Stylistic rules are considered `warnings` for better developer experience, however, we recommend
3532
running CI with:
33+
3634
```
3735
eslint --max-warnings 0
3836
```
3937

4038
## Usage with Next.js
4139

42-
Make sure to also extend from next's `core-web-vitals`.
40+
For Next.js projects, you can combine this config with Next.js's built-in ESLint configuration:
4341

4442
```js
45-
// .eslintrc.js
46-
require('@bigcommerce/eslint-config/patch');
43+
// eslint.config.js
44+
import config from '@bigcommerce/eslint-config';
45+
import { FlatCompat } from '@eslint/eslintrc';
46+
47+
const compat = new FlatCompat();
4748

48-
module.exports = {
49-
extends: ['@bigcommerce/eslint-config', 'next/core-web-vitals'],
50-
};
49+
export default [
50+
...config,
51+
...compat.extends('next/core-web-vitals'),
52+
];
5153
```
5254

55+
## Migration from ESLint 8
56+
57+
### Breaking Changes
58+
59+
- **ESLint 9 Required**: This version requires ESLint ^9.0.0
60+
- **Flat Config Format**: Use `eslint.config.js` instead of `.eslintrc.js`
61+
- **ES Modules**: Configuration must use ES module syntax
62+
- **No Patch Required**: Remove `require('@bigcommerce/eslint-config/patch')`
63+
64+
### Migration Steps
65+
66+
1. **Update ESLint**: `npm install --save-dev eslint@^9.0.0`
67+
2. **Update this package**: `npm install --save-dev @bigcommerce/eslint-config@latest`
68+
3. **Delete old config**: Remove `.eslintrc.js` or `.eslintrc.json`
69+
4. **Create new config**: Create `eslint.config.js` with the usage example above
70+
5. **Remove patch import**: Delete any `require('@bigcommerce/eslint-config/patch')` calls
71+
5372
## Release
5473

5574
Please refer to the documentation of [lerna](https://github.com/lerna/lerna) for release options.
5675

57-
5876
## License
5977

6078
MIT

0 commit comments

Comments
 (0)