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

.flowconfig should use json #153

Open
darrenderidder opened this Issue Dec 1, 2014 · 27 comments

Comments

Projects
@darrenderidder
Copy link

darrenderidder commented Dec 1, 2014

The config file format should be JSON to allow better tooling integration, rather than an ad-hoc format.

@ghost

This comment has been minimized.

Copy link

ghost commented Dec 1, 2014

+1

@j201

This comment has been minimized.

Copy link

j201 commented Dec 3, 2014

JSON is a bit painful for regex because it doesn't support raw strings. I think the current format is reasonable given its similarity to other dotfiles, but it might be worth looking at alternatives like YAML or just providing a tool on npm that can read a .flowconfig file.

@gabelevi

This comment has been minimized.

Copy link
Contributor

gabelevi commented Dec 4, 2014

I'm 100% open to a different format. JSON with only literals would be pretty easy to support. We do have a JS parser, so as long as we don't need to execute code it should be pretty easy.

@j201 is right, specifying regex's would be a little worse in JSON, but it doesn't seem terrible

@StyMaar

This comment has been minimized.

Copy link

StyMaar commented Dec 7, 2014

I quite agree with j201 about regex. Dealling with double backslashes is really annoying. Regex are cryptic enough without it ... I would rather have a parser on npm as suggested by j201.

@thomasboyt

This comment has been minimized.

Copy link
Contributor

thomasboyt commented Jan 24, 2015

TOML may be a good alternative. It's relatively common (though not as popular as JSON or YAML), very simple, and has parsers for OCaml and JS. It also has a raw string syntax that may make regexes easier (see the bottom of this section).

@gabelevi

This comment has been minimized.

Copy link
Contributor

gabelevi commented Jan 25, 2015

I suppose this would be a good issue to resolve sooner rather than later, as it would be a breaking-ish change (I suppose we could support both for a while).

Do you guys have strong opinions of TOML vs YAML? I do like TOML's simplicity, but there's something to be said for using something that's more mature and well specified. I think I'm leaning towards TOML.

@ghost

This comment has been minimized.

Copy link

ghost commented Aug 4, 2015

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

@monolithed

This comment has been minimized.

Copy link

monolithed commented Sep 6, 2015

+1

@j201

This comment has been minimized.

Copy link

j201 commented Sep 7, 2015

+1 for TOML

@jasonkuhrt

This comment has been minimized.

Copy link

jasonkuhrt commented Oct 9, 2015

YAML. Its very common in a range of communities, though in JS JSON generally rules even though it was optimized for machines and YAML for us. YAML is supported by testem, eslint, and surely more.

+1 for YAML.

-- EDIT June 2017: I would no longer advocate for YAML even though I prefer the format. JSON would allow configuration to go into package.json. This is the ideal consolidation I think

@khizarvaio

This comment has been minimized.

Copy link

khizarvaio commented Jun 8, 2017

+1

@trevordmiller

This comment has been minimized.

Copy link

trevordmiller commented Jun 16, 2017

Has there been any progress on this? Would be great if JSON config could be supported as both a standalone file and a property in package.json files as Babel, Jest, ESLint, and many other tools in the ecosystem do so you could do something like:

.flowrc.json or whatever the file is called

{
  "include": [
    "../otherdir/src"
  ],
  "ignore": [
    ".*/build/.*"
  ],
  "libs": [
    "./lib"
  ]
},

Or

package.json

{
  "name": "some-app",
  "version": "1.0.0",
  "scripts": {
    ...
  },
  "flow": {
    "include": [
      "../otherdir/src"
    ],
    "ignore": [
      ".*/build/.*"
    ],
    "libs": [
      "./lib"
    ]
  },
  "babel": {
    ...
  },
  "jest": {
    ...
  },
  "devDependencies": {
    ...
  },
  "dependencies": {
    ...
  }
}
@TiddoLangerak

This comment has been minimized.

Copy link
Contributor

TiddoLangerak commented Jun 19, 2017

I wrote a small utility to transform JSON files to .flowconfig. If you're interested, you can get it here.

@gabor

This comment has been minimized.

Copy link

gabor commented Jul 20, 2017

please think about comments. currently the flowconfig format supports comments in the file, but JSON does not. this would be a painful regression.

@billschaller billschaller added this to Awaiting response in Feature Requests Jul 20, 2017

@kutsan

This comment has been minimized.

Copy link

kutsan commented Jul 21, 2017

@gabor Could be like a normal .js file that exports a JavaScript object (module.exports = {/* options here */}) like ESLint and Webpack did.

@gabor

This comment has been minimized.

Copy link

gabor commented Jul 21, 2017

@kutsan the problem with .js is that Flow is not written in javascript, so running javascript-code might be complicated there (but i don't know the flow-details, so i might be wrong here)

@Couto

This comment has been minimized.

Copy link
Contributor

Couto commented Sep 6, 2017

My two cents on this.

https://github.com/davidtheclark/cosmiconfig is becoming quite popular with JavaScript tools.

It allows for JavaScript files (which allow comments and regular expressions), JSON, and YAML files.
It also allows a "flowconfig" property in the package.json for those who prefer that approach.

I believe that apart from TOML files (which maybe they can accept a PR) this kinda resolves our format problems and increases the flexibility of storing flow's configuration (file or package.json).

This approach has also been adopted by other tools (Jest/Babel/ESLint/Prettier). I'm not sure if they use cosmiconfig but at least they use the same approach.

@dgcoffman

This comment has been minimized.

Copy link

dgcoffman commented Sep 15, 2017

I would really like JavaScript config because I hope to someday provide functions to e.g. module.name_mapper.

@TrySound

This comment has been minimized.

Copy link

TrySound commented Sep 15, 2017

@dgcoffman Do you know flow written in ocaml and compiled? Adding js engine will be quite inefficient.

@krdinesh

This comment has been minimized.

Copy link

krdinesh commented Feb 19, 2018

+1

@RichieAHB

This comment has been minimized.

Copy link

RichieAHB commented Jun 1, 2018

I've closed the issue but I think there is definitely value in having a more JS dev friendly config file ... comments notwithstanding, JSON would be nice for me: #6404

@vjpr

This comment has been minimized.

Copy link

vjpr commented Jun 1, 2018

I vote for .js. Then you can require the config from another location, or dynamically generate it when its used.

@mrkev

This comment has been minimized.

Copy link
Contributor

mrkev commented Jun 5, 2018

@vjpr I personally am a fan of the .js config in web pack because it's makes it easy to derive development and production configurations from one or the other.

Two issues though:

  1. Flow is written in OCaml, and doesn't really have a JS runtime. It would need to start one (ie, node) every time it want's to read the config.

  2. What config would the config be checked with 😛

@johnhaley81

This comment has been minimized.

Copy link

johnhaley81 commented Jun 5, 2018

You can always use Bucklescript :)

@mrkev

This comment has been minimized.

Copy link
Contributor

mrkev commented Jun 5, 2018

@johnhaley81 that will get us OCaml -> JS, not let us run JS in OCaml 😅

@texastoland

This comment has been minimized.

Copy link

texastoland commented Aug 5, 2018

Maybe it's non-trivial but I'd prefer something Cosmiconfig-like that checks

  • "flowConfig": {...} in package.json
  • .flowconfig (existing format or TOML?)
  • .flowconfig.json
  • .flowconfig.yml (or .yaml)

PR's accepted?

@dericgw

This comment has been minimized.

Copy link

dericgw commented Nov 27, 2018

If comments in JSON are a big deal, what about using JSON5? Seems like it has picked up lately with other major tools using it (looking at you VSCode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment