Skip to content

Commit 79c39af

Browse files
authored
Merge pull request #81 from Boehringer-Ingelheim/feature/support-playwright-ct
feat(playwright): disable unbound-method rule for component testing compatibility
2 parents 08157af + 311f68a commit 79c39af

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [7.2.0-support-playwright-ct.1](https://github.com/Boehringer-Ingelheim/eslint-config/compare/v7.1.0...v7.2.0-support-playwright-ct.1) (2025-02-14)
2+
3+
4+
### Features
5+
6+
* **playwright:** disable unbound-method rule for component testing compatibility ([47349c9](https://github.com/Boehringer-Ingelheim/eslint-config/commit/47349c9c9eae8ec6d93e6da51fd62acf3359a12a))
7+
18
# [7.1.0](https://github.com/Boehringer-Ingelheim/eslint-config/compare/v7.0.0...v7.1.0) (2025-02-04)
29

310

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ export default boehringer.config(
156156
);
157157
```
158158

159+
or for specific files only:
160+
161+
```js
162+
import boehringer from '@boehringer-ingelheim/eslint-config';
163+
164+
export default boehringer.config(
165+
boehringer.configs.strict,
166+
{
167+
files: ['src/**/*.test.{ts,tsx}'],
168+
...(await boehringer.configs.playwright)[0],
169+
},
170+
);
171+
```
172+
159173
This shared ESLint configuration is designed to enforce best practices and recommendations when writing tests with Playwright. It extends the [`eslint-plugin-playwright`](https://github.com/playwright-community/eslint-plugin-playwright) configuration and adds the following rules:
160174

161175
- [`playwright/prefer-to-be`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-be.md): enforces the use of `.toBe()` instead of `.toEqual()` when testing for equality.

configs/playwright.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ const tseslint = require('typescript-eslint');
44
module.exports = tseslint.config({
55
...playwright.configs['flat/recommended'],
66
rules: {
7-
...playwright.configs['flat/recommended'].rules,
7+
/**
8+
* At the moment, `eslint-plugin-playwright` does not fully support component testing with type information.
9+
* https://github.com/playwright-community/eslint-plugin-playwright/issues/298
10+
*
11+
* The `mount` function is flagged as an error by the `@typescript-eslint/unbound-method` rule.
12+
* But it is okay to use `mount` in this context for test files.
13+
* https://typescript-eslint.io/rules/unbound-method/#when-not-to-use-it
14+
*
15+
* Hint: `eslint-plugin-jest` has already a customized version of this rule.
16+
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md
17+
*/
18+
'@typescript-eslint/unbound-method': 'off',
19+
820
// eslint-plugin-playwright: https://github.com/playwright-community/eslint-plugin-playwright
21+
...playwright.configs['flat/recommended'].rules,
922
'playwright/prefer-to-be': 'error',
1023
'playwright/prefer-to-have-length': 'error',
1124
'playwright/require-top-level-describe': 'error',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@boehringer-ingelheim/eslint-config",
3-
"version": "7.1.0",
3+
"version": "7.2.0-support-playwright-ct.1",
44
"description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
55
"keywords": [
66
"boehringer",

0 commit comments

Comments
 (0)