Skip to content

Commit cc3159a

Browse files
committed
feat: Remove support for global assertFunctionNames
BREAKING CHANGE: `assertFunctionNames` is now only available at the rule level
1 parent 510e71c commit cc3159a

File tree

2 files changed

+14
-53
lines changed

2 files changed

+14
-53
lines changed

README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,45 +91,19 @@ export default [
9191
}
9292
```
9393

94-
## Global Settings
94+
### Aliased Playwright Globals
9595

96-
The plugin reads global settings from your ESLint configuration's shared data
97-
under the `playwright` key. It supports the following settings:
98-
99-
- `additionalAssertFunctionNames`: an array of function names to treat as
100-
assertion functions for the case of rules like `expect-expect`, which enforces
101-
the presence of at least one assertion per test case. This allows such rules
102-
to recognise custom assertion functions as valid assertions. The global
103-
setting applies to all modules. The
104-
[`expect-expect` rule accepts an option by the same name](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/expect-expect.md#additionalassertfunctionnames)
105-
to enable per-module configuration (.e.g, for module-specific custom assert
106-
functions).
107-
108-
You can configure these settings like so:
109-
110-
[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
111-
(**eslint.config.js**)
112-
113-
```javascript
114-
export default [
115-
{
116-
settings: {
117-
playwright: {
118-
additionalAssertFunctionNames: ['assertCustomCondition'],
119-
},
120-
},
121-
},
122-
];
123-
```
124-
125-
[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
126-
(**.eslintrc**)
96+
If you import Playwright globals (e.g. `test`, `expect`) with a custom name, you
97+
can configure this plugin to be aware of these additional names.
12798

12899
```json
129100
{
130101
"settings": {
131102
"playwright": {
132-
"additionalAssertFunctionNames": ["assertCustomCondition"]
103+
"globalAliases": {
104+
"test": ["myTest"],
105+
"expect": ["myExpect"]
106+
}
133107
}
134108
}
135109
}

docs/rules/expect-expect.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,25 @@ test('should work with callbacks/async', async () => {
3535
"playwright/expect-expect": [
3636
"error",
3737
{
38-
"additionalAssertFunctionNames": ["assertCustomCondition"]
38+
"assertFunctionNames": ["assertCustomCondition"]
3939
}
4040
]
4141
}
4242
```
4343

44-
### `additionalAssertFunctionNames`
44+
### `assertFunctionNames`
4545

46-
An array of function names to treat as assertion functions. Only standalone
47-
functions are supported. Configure globally acceptable assert function names
48-
using [the global setting](../global-settings.md). You can also customize assert
49-
function names per-file. For example:
46+
This array option specifies the names of functions that should be considered to
47+
be asserting functions.
5048

5149
```ts
52-
/* eslint playwright/expect-expect: ["error", { "additionalAssertFunctionNames": ["assertScrolledToBottom"] }] */
50+
/* eslint playwright/expect-expect: ["error", { "assertFunctionNames": ["assertScrolledToBottom"] }] */
5351

5452
function assertScrolledToBottom(page) {
5553
// ...
5654
}
5755

58-
describe('scrolling', () => {
59-
test('button click', async ({ page }) => {
60-
// ...
61-
await assertScrolledToBottom(page);
62-
});
63-
64-
test('another way to scroll', async ({ page }) => {
65-
// ...
66-
await assertScrolledToBottom(page);
67-
});
56+
test('should scroll', async ({ page }) => {
57+
await assertScrolledToBottom(page);
6858
});
6959
```
70-
71-
The rule option and the global setting are merged. On a file level, both are
72-
considered.

0 commit comments

Comments
 (0)