facebook / facebook/flow

Ignore parse errors in .json files under node_modules/

Offen
#2,364 11 Kommentare 24 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

An issue I run into weirdly fequently (just ran into it again yesterday while adding Flow support to [Kefir](https://rpominov.github.io/kefir/)) is that some dependency or sub-dependency of a project contains purposefully malformed JSON files (some examples: [bower-json](https://www.npmjs.com/package/bower-json)/test/pkg-bower-json-malformed/bower.json, [config-chain/test/broken.json](https://github.com/dominictarr/config-chain/blob/master/test/broken.json), [npmconf/test/fixtures/package.json](https://github.com/npm/npmconf/blob/master/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](https://github.com/dominictarr/config-chain/pull/28), and some are [in code freeze and not accepting pull requests](https://github.com/npm/npmconf/pull/56) (coincidentally these are 2/3 of the modules mentioned in https://github.com/facebook/flow/issues/869#issuecomment-192548460; 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 https://github.com/facebook/flow/issues/869 that solves most of the issue that prompted that request.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.