Missing imports not detected

39 views Asked by At

I'm following this guide https://flow.org/en/docs/tools/eslint/ to enable eslint to detect flow related issues, however it seems that while it correctly checks for issues related to flow, it stops checking for missing imports.

Example:

    // @flow
    import React, {useState, useEffect} from "react"
    import {isDefaultImage} from "utils/image-utils"
    import {ImageWrapper} from "./styles"

    type PropsType = {
      src?: string | null,
      size: string,
      text: string,
    }

    const FallbackImage = (props: PropsType) => {
      const {src, size, text} = props

      const [imageUrl, setImageUrl] = useState(null)
      const [fallback, setFallback] = useState(false)

      const onImageError = () => {
        setFallback(true)
      }

      useEffect(() => {
        if (isDefaultImage(src)) {
          setFallback(true)
        } else {
          setFallback(false)
          setImageUrl(src)
        }
      }, [src])

      return (
        <ImageWrapper size={size} fallback={fallback} text={text}>
          {fallback ? null : <img src={imageUrl} alt="" onError={onImageError} />}
        </ImageWrapper>
      )
    }

    export default FallbackImage

Given this component, if I remove the commas from PropsType it correctly throws an error telling me that a comma is expected after a property. However, if I remove the line

import {ImageWrapper} from "./styles"

It doesn't throw any error despite me using a component that isn't imported.

    {
        "files": ["**/*.js", "**/*.jsx"],
        "parser": "hermes-eslint",
        "parserOptions": {
            "sourceType": "module"
        },
        "plugins": ["ft-flow"],
        "extends": ["plugin:ft-flow/recommended"],
        "rules": {
            "no-undef": "error"
        }
     }

How can I tell Eslint to also detect missing imports?

0

There are 0 answers