Skip to content

Ignore parse errors in .json files under node_modules/ #2364

@Macil

Description

@Macil

An issue I run into weirdly fequently (just ran into it again yesterday while adding Flow support to Kefir) is that some dependency or sub-dependency of a project contains purposefully malformed JSON files (some examples: bower-json/test/pkg-bower-json-malformed/bower.json, config-chain/test/broken.json, npmconf/test/fixtures/package.json), and Flow tries to parse them and reports errors.

I worked around it by adding some [ignore] lines to the .flowconfig, but I think it's bad when I have to configure something specifically to deal with a sub-dependency that I didn't even explicitly choose myself. I figured I'd go through and send a bunch of pull requests to get these modules to npmignore their test/ directories, but some of them are opinionated about putting their tests on npm, and some are in code freeze and not accepting pull requests (coincidentally these are 2/3 of the modules mentioned in #869 (comment); the commenter said they wanted to fix this, but without cooperation from those projects, the fix is going to have to come from Flow).

In the past, Flow had the similar/superset issue that it would try to parse all .js and .json files in the directory tree and it would report parse errors in all of them. The issue was lessened by Flow being changed to only do this with .js files that had the @flow comment and all .json files. Flow no longer assumes that all .js files under node_modules are parseable by it, but it still assumes that all .json files are.

This feature request can be seen as a much more restricted form of #869 that solves most of the issue that prompted that request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions