noPlaywrightEval
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since:
v2.4.2 - Diagnostic Category:
lint/nursery/noPlaywrightEval - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
playwright/no-eval
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noPlaywrightEval": "error" } } }}Description
Section titled “Description”Disallow usage of page.$eval() and page.$$eval().
These methods are discouraged in favor of locator.evaluate() and locator.evaluateAll().
Locator-based evaluation is more reliable and follows Playwright’s recommended patterns.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”await page.$eval('.foo', el => el.textContent);code-block.js:1:7 lint/nursery/noPlaywrightEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected use of page.$eval().
> 1 │ await page.$eval(‘.foo’, el => el.textContent);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Locator-based evaluation is more reliable and follows Playwright’s recommended patterns.
ℹ Use locator.evaluate() instead.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
const texts = await page.$$eval('.foo', els => els.map(el => el.textContent));code-block.js:1:21 lint/nursery/noPlaywrightEval ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Unexpected use of page.$$eval().
> 1 │ const texts = await page.$$eval(‘.foo’, els => els.map(el => el.textContent));
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Locator-based evaluation is more reliable and follows Playwright’s recommended patterns.
ℹ Use locator.evaluateAll() instead.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
const text = await page.locator('.foo').evaluate(el => el.textContent);const texts = await page.locator('.foo').evaluateAll(els => els.map(el => el.textContent));Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.