OptimumCredo.Check.Warning.HardcodedAssetPath (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of low and works with any version of Elixir.

Explanation

Reference static assets through verified routes (~p"/images/logo.png") or static_path/2, not a hard-coded string in src or href. Only HEEx text is inspected. Opt-in, low priority.

Bad

<img src="/images/logo.png" />

Good

<img src={~p"/images/logo.png"} />

Check-Specific Parameters

Use the following parameters to configure this check:

:prefixes

Path prefixes considered static assets.

This parameter defaults to ["/images/", "/assets/", "/css/", "/js/", "/fonts/"].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.