Skip to content

Commit 60a2125

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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+12188
-4267
lines changed

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.

eslint.config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import globals from 'globals';
2+
3+
import config from './packages/eslint-config/index.js';
4+
5+
const baseConfig = await config;
6+
7+
export default [
8+
{
9+
ignores: ['**/node_modules/**', '**/__snapshots__/**', '**/dist/**', '**/build/**'],
10+
},
11+
...baseConfig,
12+
{
13+
languageOptions: {
14+
globals: {
15+
...globals.node,
16+
},
17+
},
18+
settings: {
19+
'import/resolver': {
20+
node: {
21+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
22+
},
23+
},
24+
'import/core-modules': [
25+
'@typescript-eslint/eslint-plugin',
26+
'@typescript-eslint/parser',
27+
'@typescript-eslint/rule-tester',
28+
],
29+
},
30+
rules: {
31+
// Allow .js extensions in ES module imports
32+
'import/extensions': ['error', 'ignorePackages'],
33+
// Allow __dirname in ES modules
34+
'no-underscore-dangle': ['error', { allow: ['__dirname', '__filename'] }],
35+
// Allow dynamic imports without webpack chunkname
36+
'import/dynamic-import-chunkname': 'off',
37+
},
38+
},
39+
];

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@bigcommerce/eslint",
33
"version": "1.0.1",
44
"description": "Default ESLint configuration used at BigCommerce",
5+
"type": "module",
56
"private": true,
67
"author": "BigCommerce",
78
"license": "MIT",
@@ -16,14 +17,16 @@
1617
"scripts": {
1718
"lint": "eslint . --ext .js",
1819
"release": "lerna publish --sign-git-commit --sign-git-tag --git-remote origin --pre-dist-tag next",
19-
"test": "jest --projects packages/*"
20+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest --projects packages/*"
2021
},
2122
"devDependencies": {
22-
"eslint": "^8.14.0",
23+
"eslint": "^9.0.0",
2324
"jest": "^29.7.0",
2425
"lerna": "^8.1.2",
2526
"typescript": "^5.0.2"
2627
},
27-
"dependencies": {},
28+
"dependencies": {
29+
"globals": "^15.0.0"
30+
},
2831
"packageManager": "[email protected]+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
2932
}

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)