Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.11 KB

relative-url-style.md

File metadata and controls

38 lines (27 loc) · 1.11 KB

Enforce consistent relative URL style

This rule is part of the recommended config.

🔧💡 This rule is auto-fixable and provides suggestions.

When using a relative URL in new URL(), the URL should either never or always use the ./ prefix consistently.

Fail

const url = new URL('./foo', base);

Pass

const url = new URL('foo', base);

Options

Type: string
Default: 'never'

  • 'never' (default)
    • Never use a ./ prefix.
  • 'always'
    • Always add a ./ prefix to the relative URL when possible.
// eslint unicorn/relative-url-style: ["error", "always"]
const url = new URL('foo', base); // Fail
const url = new URL('./foo', base); // Pass