no-hardcoded-urls
No hardcoded environment URLs
| Property | Value |
|---|---|
| Tier | MUST_NOT |
| Severity | warn |
| Enforcement | ESLint (text) |
| Autofix | no |
| Skill | harness |
| Applies to | tests/**/*.ts, pages/**/*.ts, fixtures/**/*.ts |
| Exempt | — |
| Since | 1.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');