src/content/docs/linter/rules/use-image-size.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JSX and TSX" icon="seti:javascript"> ## Summary - Rule available since: `v2.1.4` - Diagnostic Category: [`lint/correctness/useImageSize`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - This rule belongs to the following domains: - [`qwik`](/linter/domains#qwik) - Sources: - Same as [`qwik/jsx-img`](https://qwik.dev/docs/advanced/eslint/#jsx-img){
"linter": {
"rules": {
"correctness": {
"useImageSize": "error"
}
}
}
}
Enforces that `` elements have both width and height attributes.
This rule ensures that `` elements have width and height attributes.
Images without specified width and height can cause layout shifts as the browser does not know how much space to reserve for them, leading to a poor user experience. It's recommended to always include these attributes to prevent such issues.