Rule reference

no-hardcoded-urls

No hardcoded environment URLs

PropertyValue
TierMUST_NOT
Severitywarn
EnforcementESLint (text)
Autofixno
Skillharness
Applies totests/**/*.ts, pages/**/*.ts, fixtures/**/*.ts
Exempt—
Since1.0.0

Why

A literal host pins the test to one environment and leaks internal hostnames into a repository that may become public. baseURL belongs in playwright.config.ts, where the environment picks it.

What to do instead

Use a relative path and let baseURL resolve it: await page.goto(‘/login’). Set baseURL per project in playwright.config.ts from an env var. For API calls, use the request fixture’s configured baseURL rather than a literal host.

Examples

// ✗ no-hardcoded-urls
await page.goto('https://staging.internal.acme.com/login');
// ✓
await page.goto('/login');