Skip to content

Latest commit

Β 

History

History
40 lines (27 loc) Β· 1.18 KB

File metadata and controls

40 lines (27 loc) Β· 1.18 KB

Enforce consistent relative URL style

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§πŸ’‘ This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

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

Examples

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

// βœ…
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);

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