Assume some defaults, so that newbies can use flow without fear. They shouldn't see
$ flow
Could not find a .flowconfig in . or any of its parent directories
At the very least we need to know the root directory for the project. Technically touch /path/to/root/.flowconfig (which is basically what flow init does) is sufficient for Flow to run and know that the root of the project is at /path/to/root. If settings don't appear in the .flowconfig we assume the defaults.
We could always assume that the current working directory is the project root if we can't find a .flowconfig, but I'm worried that we're going to end up with flow servers watching lots of random directories. Every time you run flow in the wrong directory it will start up a new server. The .flowconfig's do a good job of marking the places where flow servers should be running
The strategy should be:
See the way NPM does it with .npmrc (NPM also supports global and per-user .npmrc's) - https://github.com/npm/npm/issues/4751
+1.
Wouldn't the root of the project always be the current working directory... at least for all my use cases it is...
Wouldn't the root of the project always be the current working directory
The user may have temporarily cd'd to a subdirectory of a larger project controlled by a single config file.
So, I have the same concern: This is confusing, as a newbie; and moreso, for small projects, I _really_ don't want to munge up an otherwise-three-file repo with a fourth, versioned, .flowconfig file with four empty INI sections, that never gets modified.
Regarding flow servers: why not print a warning, and then use flow check mode _on the current directory_? That's slower, but a lot less confusing for new users. (This means no ‘zombie flow servers’ for random directories.) If you want Faster Flow, then touch .flowconfig and .gitignore it. This doesn't seem to onerous for new users, while still being less confusing than the current behaviour. (=
If .flowconfig is not found, it could instead look for a package.json.
If it makes any difference, I just came here from the top hit of Googling "Could not find a .flowconfig". Using flow just as a prereq for a Sublime 3 javascript plug-in so it would have been more convenient if flow has just auto-created an empty .flowconfig rather than require me to Google the problem to learn I needed to create an empty file.
If automatically creating an empty .flowconfig file breaks in certain environments then at the very least please consider mentioning the solution of manually creating an empty .flowconfig in the error message itself.
Would the Flow team be open to merge a PR implementing the strategy mentioned in https://github.com/facebook/flow/issues/389#issuecomment-96433415 ?
Similarly to how other tools like Babel, ESLint, Jest and Prettier do (to name a few), I would like .flowconfig to be subject to be shared across projects. So, I would like the ability to either have a "flow" key in my package.json pointing to the NPM package that exports such config file:
{
"flow": "@my-company/common-flow-config",
}
or, similarly, something like:
{
"flow": {
"extends": "@my-company/common-flow-config"
},
}
Does this make any sense?
Most helpful comment
If .flowconfig is not found, it could instead look for a package.json.