flowconfig [ignore] not working

Created on 10 Jan 2018  路  10Comments  路  Source: facebook/flow

I am ignoring test files and gif files using [ignore] of flowconfig but it's not ignoring
Error for GIF file: Malformed Unicode

Project structure

/root
    /node_modules
    /src
        /component
            index.js
            index.test.js
            index.gif
    flowconfig

flowconfig

[ignore]
node_modules
*.test

[libs]
src

[options]
munge_underscores=true
> flow check

Library parse error:
src/components/Loader/loader.gif:0
Malformed unicode

Most helpful comment

At first, why do you have

[libs]
src

in your flow config?

All 10 comments

@govindchowdhari Do you require or import gif somewhere via bundler?

import loader from './index.gif'

using Webpack 2.0 with url-loader

I added a png file to project and getting the same error. Tried adding module mapper in flowconfig but didn't work

flow version 0.57

@govindchowdhari How's your mapper look like?

module.name_mapper.extension='\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)' -> 'RelativeImageStub'
index.js

declare module 'RelativeImageStub' { declare module.exports: string }
import loaderGif from './index.gif'
import noDataImage from './index.png'
class ABC {
  render() {
    return (
      <img src={loaderGif} />
    )
  }
}
export default ABC

At first, why do you have

[libs]
src

in your flow config?

@apsavin I am keeping my definitions in the same JS file and using them across so just referred src/ folder

@govindchowdhari I think it's wrong and leads to errors.

@govindchowdhari, maybe something like that:
./node_modules
./*.test

@apsavin if I remove image reference from code and delete image files then things are working byt keeping definitions in the code file. It fails just for images

@SilencerWeb I added what you suggested but it doesn't work. Actually, flow behavior is different. There are other test files that are ignored. Source has subfolders as well and flow check is giving error for one of the nested folder

From here https://flow.org/en/docs/config/ignore/

The [ignore] section in a .flowconfig file tells Flow to ignore files matching the specified regular expressions when type checking your code

@govindchowdhari
So, does your node_modules valid regular expression? nope
The valid rules:

[ignore]
.*/node_modules/.*
*.test
Was this page helpful?
0 / 5 - 0 ratings