コンテンツにスキップ

noPlaywrightEval

このコンテンツはまだ日本語訳がありません。

biome.json
{
"linter": {
"rules": {
"nursery": {
"noPlaywrightEval": "error"
}
}
}
}

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.

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));