Skip to content

noPlaywrightEval (JavaScript)

Language JavaScript (and super languages)
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));