Skip to content

Commit d96bd87

Browse files
authored
chore(deps): Migrate to FlatConfig (#125)
* (lib) Migrate recommended to FlatConfig * Add a11y configs * Add imports config * Add tests configs * Update dependencies * Update readme * Update eslint doc
1 parent 26f5cd6 commit d96bd87

File tree

21 files changed

+1934
-1517
lines changed

21 files changed

+1934
-1517
lines changed

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
33
"editor.formatOnSave": true,
4-
"editor.codeActionsOnSave": { "source.fixAll": true },
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll": "explicit"
6+
},
57
"eslint.workingDirectories": ["example-app", "packages/eslint-plugin"],
68
"markdownlint.customRules": [
79
"./markdown-lint-custom-rules/no-relative-links.js"
8-
]
10+
],
11+
"eslint.useFlatConfig": true,
12+
"eslint.options": {
13+
"overrideConfigFile": "./eslint.config.js"
14+
}
915
}

example-app/.eslintrc

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

example-app/.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"eslint.useFlatConfig": true,
3+
"eslint.options": {
4+
"overrideConfigFile": "./eslint.config.js"
5+
}
6+
}

example-app/eslint.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const pluginBam = require("@bam.tech/eslint-plugin");
2+
3+
module.exports = [
4+
...pluginBam.configs.recommended,
5+
...pluginBam.configs.a11y,
6+
...pluginBam.configs.import,
7+
...pluginBam.configs.tests,
8+
{
9+
rules: {
10+
"@bam.tech/require-named-effect": "error",
11+
},
12+
},
13+
];

example-app/package.json

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,31 @@
1111
"devDependencies": {
1212
"@bam.tech/eslint-plugin": "portal:../packages/eslint-plugin",
1313
"@bam.tech/typescript-config": "portal:../packages/typescript-config",
14+
"@eslint/js": "^9.17.0",
1415
"@testing-library/react-native": "^12.3.1",
16+
"@types/eslint": "^9.6.1",
1517
"@types/jest": "^29.5.2",
16-
"@types/react": "^18.2.14",
17-
"@typescript-eslint/eslint-plugin": "^6.0.0",
18-
"eslint": "^8.44.0",
19-
"eslint-config-prettier": "^9.0.0",
20-
"eslint-import-resolver-typescript": "^3.6.1",
21-
"eslint-plugin-import": "^2.29.1",
22-
"eslint-plugin-jest": "^28.9.0",
23-
"eslint-plugin-prettier": "^5.0.0",
24-
"eslint-plugin-react": "^7.31.11",
25-
"eslint-plugin-react-hooks": "^4.6.0",
26-
"eslint-plugin-react-native": "^4.0.0",
27-
"eslint-plugin-react-native-a11y": "^3.3.0",
28-
"eslint-plugin-simple-import-sort": "^10.0.0",
29-
"eslint-plugin-testing-library": "^6.0.1",
30-
"eslint-plugin-unused-imports": "^3.0.0",
18+
"@types/react": "^19.0.6",
19+
"@typescript-eslint/eslint-plugin": "^8.19.1",
20+
"eslint": "^9.18.0",
21+
"eslint-config-prettier": "^10.0.1",
22+
"eslint-define-config": "^2.1.0",
23+
"eslint-import-resolver-typescript": "^3.7.0",
24+
"eslint-plugin-import": "^2.31.0",
25+
"eslint-plugin-jest": "^28.10.0",
26+
"eslint-plugin-prettier": "^5.2.0",
27+
"eslint-plugin-react": "^7.37.3",
28+
"eslint-plugin-react-hooks": "^5.1.0",
29+
"eslint-plugin-react-native": "^5.0.0",
30+
"eslint-plugin-react-native-a11y": "^3.5.1",
31+
"eslint-plugin-simple-import-sort": "^12.1.1",
32+
"eslint-plugin-testing-library": "^7.1.1",
33+
"eslint-plugin-unused-imports": "^4.1.0",
34+
"globals": "^15.14.0",
3135
"jest": "^29.5.0",
3236
"prettier": "^3.0.0",
33-
"typescript": "^5.0.0"
37+
"typescript": "^5.0.0",
38+
"typescript-eslint": "^8.19.1"
3439
},
3540
"private": true,
3641
"dependencies": {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"markdownlint-rule-helpers": "^0.23.0",
1616
"prettier": "^3.0.0"
1717
},
18-
"packageManager": "[email protected]"
18+
"packageManager": "[email protected]",
19+
"dependencies": {
20+
"@types/eslint": "^9.6.1"
21+
}
1922
}

packages/eslint-plugin/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/eslint-plugin/README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ yarn add @bam.tech/eslint-plugin --dev
1313
npx install-peerdeps @bam.tech/eslint-plugin --dev --yarn
1414
```
1515

16+
#### Legacy Config (ESLint 8.x and below)
17+
1618
Then update your `.eslintrc` config file:
1719

1820
```json
@@ -28,6 +30,27 @@ Then update your `.eslintrc` config file:
2830
}
2931
```
3032

33+
#### Flat Config
34+
35+
- Install the plugin: `yarn add -D @bam.tech/eslint-plugin`
36+
- Create an `eslint.config.js` file in your project root:
37+
38+
```javascript
39+
const pluginBam = require("@bam.tech/eslint-plugin");
40+
41+
module.exports = [
42+
...pluginBam.configs.recommended,
43+
...pluginBam.configs.a11y,
44+
...pluginBam.configs.import,
45+
...pluginBam.configs.tests,
46+
{
47+
rules: {
48+
"@bam.tech/require-named-effect": "error",
49+
},
50+
},
51+
];
52+
```
53+
3154
### Setting up the plugin on a monorepo
3255

3356
Update your `.vscode/settings.json` by adding the directories of apps using the plugin:
@@ -102,17 +125,14 @@ This plugin exports some custom rules that you can optionally use in your projec
102125

103126
<!-- begin auto-generated rules list -->
104127

105-
💼 Configurations enabled in.\
106-
✅ Set in the `recommended` configuration.\
107-
🧪 Set in the `tests` configuration.\
108128
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
109129

110-
| Name | Description | 💼 | 🔧 |
111-
| :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------- | :-- | :-- |
112-
| [await-user-event](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/await-user-event.md) | Enforces awaiting userEvent calls | 🧪 | 🔧 |
113-
| [no-different-displayname](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/no-different-displayname.md) | Enforce component displayName to match with component name | | 🔧 |
114-
| [prefer-user-event](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/prefer-user-event.md) | Enforces usage of userEvent over fireEvent in tests. | | 🔧 |
115-
| [require-named-effect](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/require-named-effect.md) | Enforces the use of named functions inside a useEffect | | |
130+
| Name | Description | 🔧 |
131+
| :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------- | :-- |
132+
| [await-user-event](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/await-user-event.md) | Enforces awaiting userEvent calls | 🔧 |
133+
| [no-different-displayname](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/no-different-displayname.md) | Enforce component displayName to match with component name | 🔧 |
134+
| [prefer-user-event](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/prefer-user-event.md) | Enforces usage of userEvent over fireEvent in tests. | 🔧 |
135+
| [require-named-effect](https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/require-named-effect.md) | Enforces the use of named functions inside a useEffect | |
116136

117137
<!-- end auto-generated rules list -->
118138

packages/eslint-plugin/docs/rules/await-user-event.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Enforces awaiting userEvent calls (`@bam.tech/await-user-event`)
22

3-
💼 This rule is enabled in the 🧪 `tests` config.
4-
53
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
64

75
<!-- end auto-generated rule header -->

packages/eslint-plugin/docs/rules/no-different-displayname.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Enforce component displayName to match with component name (`@bam.tech/no-different-displayname`)
22

3-
💼 This rule is enabled in the ✅ `recommended` config.
4-
53
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
64

75
<!-- end auto-generated rule header -->

0 commit comments

Comments
 (0)