Performancewarn by default
astro-doctor/use-astro-imageuse-astro-image
Use <Image> from astro:assets instead of raw <img> tags.
Why
The built-in <Image> component automatically optimizes images (WebP/AVIF conversion, responsive srcset, lazy loading, explicit width/height to prevent layout shift). Plain <img> tags with static sources skip all of this. Source-less placeholders populated at runtime are ignored because they cannot be optimized at build time.
Examples
Incorrect
Raw <img> tag
---
---
<img src="/hero.png" alt="Hero image" />Correct
<Image> from astro:assets
---
import { Image } from 'astro:assets'
import hero from '../assets/hero.png'
---
<Image src={hero} alt="Hero image" width={800} height={400} />Configuration
Override the default severity in your ESLint config:
// eslint.config.js
import astroDoctorPlugin from '@santi020k/eslint-plugin-astro-doctor'
export default [
astroDoctorPlugin.configs.recommended,
{
rules: {
'astro-doctor/use-astro-image': 'error', // or 'warn' or 'off'
},
},
]Or in your doctor.config.ts:
export default {
rules: {
'astro-doctor/use-astro-image': 'error',
},
}All rules
astro-doctor/no-client-load-overuseastro-doctor/use-astro-image(this page)astro-doctor/require-image-dimensionsastro-doctor/no-missing-altastro-doctor/no-set-htmlastro-doctor/no-public-secret-envastro-doctor/prefer-class-listastro-doctor/no-blocking-scriptastro-doctor/no-unprocessed-script-surprisesastro-doctor/no-missing-langastro-doctor/require-island-fallbackastro-doctor/no-process-envastro-doctor/prefer-content-collectionsastro-doctor/no-disabled-origin-checkastro-doctor/no-insecure-session-cookieastro-doctor/no-open-allowed-domainsastro-doctor/prefer-env-schemaastro-doctor/prefer-pnpmastro-doctor/require-action-input-schemaastro-doctor/require-client-router-script-lifecycleastro-doctor/require-content-config