-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore parse errors in .json files under node_modules/ #2364
Comments
Yes this got me as well. Any way this can be disabled by default? |
Forgive me if this is a dumb question, but why does Flow parse |
@jedwards1211 Flow does this to support |
@vkurchatkin I'm not sure I understand why it needs to actually parse them to do that though. For instance it doesn't give me any errors if I try to use the // @flow
var version: number = require('./package.json').version I assume it does parse |
Any new feedback on this idea? #869 still gets a lot of user attention, and this is possibly a cleaner and easier to implement solution that solves the issues of most if not all commenters there. (I seem to be the only one ever talking about If the solution sounds too over-specific, then maybe a better phrasing of it is "Only report parse errors in |
For someone attempting to integrate Flow into an existing project as his first experience with Flow, this leaves me with a bad taste...would be great to get some maintainer eyeballs on this. |
+1, Flow is parsing a bower.json file that has a comment inside and is throwing errors for me. |
i'm running into this with
i don't understand why it still fails even when i explicitly |
@brandly if you haven't solved this yet, you can accomplish this by doing something like this (notice the .* prefix):
|
Comically, Cypress has
which is a directory full of nothing but JSON syntax errors... all of which Flow so-helpfully complains about. |
browserify/resolve#262 (comment) is an example of this:
I think that might be reasonable? Here's a doc for |
There is a purposely malformed `package.json` file in one of the dependencies (for testing purposes). See issue: facebook/flow#2364.
There is a purposely malformed `package.json` file in one of the dependencies (for testing purposes). We are using `.flowconfig` to ignore this file. See issue: facebook/flow#2364.
…4023) Summary: flow check is failing on this repo right now ``` yarn run v1.22.19 $ flow check Error --------------------------------------- node_modules/resolve/test/resolver/malformed_package_json/package.json:2:1 Unexpected end of input, expected the token `}` 2| Found 1 error error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Error: Process completed with exit code 2. ``` I wish facebook/flow#2364 was addressed that I didn't have to do this :( Pull Request resolved: #4023 Test Plan: Imported from GitHub, without a `Test Plan:` line. **Static Docs Preview: relay** |[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D38072807/V2/relay/)| |**Modified Pages**| Reviewed By: alunyov Differential Revision: D38072807 Pulled By: voideanvalue fbshipit-source-id: 0190e69a7fd61fa1ce3bcd73c57435ba14466235
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.
The text was updated successfully, but these errors were encountered: