Skip to content

Alt tag warning for image element is not correct #812

Open
@tminhduc2811

Description

@tminhduc2811

Hi, I'm using image props with an interface as below and eslint is showing a warning Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images.

interface ImageProps {
  src: string
  width: number
  height: number
  alt: string
  priority?: boolean
}

const ImageList = ({ images, imgClassName }: { images: ImageProps[], imgClassName: string }) => {
  return (
    <Carousel responsive={CAROUSEL_RESPONSIVE} renderDotsOutside ssr>
      {images.map((image, index) => <Image key={index} className={imgClassName} {...image} />)}
    </Carousel>

  )
}

Correct me if I'm wrong but In this case, the alt tag is guaranteed by the interface and eslint shouldn't show the warning.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions