-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adding support for a dedicated configuration file #520
Comments
We're intentionally only using package.json for simplicity and consistency.
Why? We are not big fans of having an endless amount of meta files in our repos. It's IMHO nice to have one place for all config. This is becoming more and more common, with both AVA, ESLint, XO, nyc, standard, etc, tools doing it.
Common practice doesn't necessarily mean it's a good one. |
okay, thanks for the response |
I am. I prefer separation over concentration, and it's handy to just ctrl-c ctrl-v a dotfile. That said, I think no one is really wrong or right and is just a matter of taste. From what I can see, to add support for a dotfile there are just a handful of lines to edit in cli.js, profile.js and test/cli.js. My naive implementation would just grab the config object from Are there any complications I'm overlooking? |
@mattecapu Sorry, we're not interested in having multiple ways to define config. |
Bump. For all my projects, my babel configuration is in a dot file, my eslint config is in a dot file, my editor config is in a dotfile, but my ava config has to be in my This doesn't seem like a hard feature to implement and pretty much every other major tool in the JS ecosystem allows this style. |
This is not going to get implemented until someone can demonstrate an actual need. There are plenty of tools that just use You could conceivably use global installs of My point here, is demonstrate some actual need. "Because I want" is not sufficient. Neither is "because project X does it that way". If not having the option is legitimately preventing you from getting things done, and you demonstrate why, we will happily change our minds. |
There're some annoying things on putting the configuration in package.json instead of dot files. Besides which was already said here, every time I {
"presets": ["es2015", "react", "stage-0"],
"plugins": [
["resolver", {"resolveDirs": ["app"]}]
],
"env": {
"development": {
"plugins": ["react-hot-loader/babel"]
}
}
} to something like this due to package.json auto re-indent: {
"presets": [
"es2015",
"react",
"stage-0"
],
"plugins": [
[
"resolver", {
"resolveDirs": [
"app"
]
}
]
],
"env": {
"development": {
"plugins": [
"react-hot-loader/babel"
]
}
}
} Also, eslintConfig rules are terribly indented in package.json. Because of this I do prefer to keep it on dotfiles, but I can't do this with ava. 😭 |
Here's a concrete use-case. I run a bunch of my integration tests using ava inside a docker container orchestrated via docker-compose. My docker image takes significantly longer (~100x) to rebuild when i modify package.json (since it has to re-run npm install). because i have to define ava defaults in this file, any change to those forces a pretty long and usually unnecessary rebuild. this is a relatively minor inconvenience but i definitely feel the pain when i'm setting up a new project, debugging test timeouts, trying to find an optimal concurrency limit, etc. i can of course specify other defaults on the command line or in custom scripts, but at that point i'm being forced to break from the concept of consolidating these defaults in one place anyways so it seems like having a file like .avarc would just be a better alternative. i'm not gonna be all torn up inside if this never happens, but given that this project places a high value on developer workflow, productivity, and speed it seemed like a reasonable use-case to share. |
There are a bunch of "project X" out there that does have a dotfile for config. It was mentioned that I don't see how adding support for dotfiles will ruin the experience for those who prefer |
@sindresorhus you are opening the door for every meta tool to now store info in package.json, just think about what that might mean :) It probably won't mean much, except small chance of namespace conflicts, and very large package.json files :) |
I was a large proponent of |
If this is implemented I’d recommend looking at cosmiconfig. |
I submitted PR #1627 resolving this issue. It's seriously trivial to implement. Hopefully the maintainers will consider adopting it. I have no interest in maintaining a separate fork for 7 lines of code difference, but find it strange that there has been such a strong pushback against something that has no effect on the library's performance. |
I am cross-posting this from #1627 so it stays with the mainline of discussion. @novemberborn there is a perfectly valid argument from @jtag05. The package.json file has become a dumping ground for configuration. In large projects it makes it huge and unwieldy. Digging through a giant JSON file is not a pleasant experience and is reminiscent of the Java world's XML configs. My team prefers the dotfiles as it neatly separates each tool's configuration that is easily explorable. It is not just because "we are used to it". Every other tool we use manages to support this trivial feature that we value but AVA. It seems absurd that even in the face of community outcry and the presence of a perfectly fine PR the maintainers here ignore the need. |
It's been nearly two years since this issue was first raised, and yes alternative configuration files have seen more adoption since then, as have monorepo projects. I'm not ignoring the need. We're trying hard not to overcomplicate what AVA does and this has also applied to how it's configured. There's some effort involved in revisiting this decision that goes beyond the number of lines of code an implementation takes. To that end: We'd need to consider where AVA would find these alternative files. Currently it finds the closest The current trend seems to be for JS-based configuration files. Would folks be upset if AVA supported Do monorepo folks expect |
I can only speak for myself, but I tend to expect my In regards to the current trend of I think that if you were to take the As far as |
My use cases follow the same logic that @jtag05 has presented. There isn't much of a use case for a |
Why not just use a standard tool like cosmiconfig which handles all these decisions and behavior for you? |
@jtag05 @pho3nixf1re, @danawoodman, thanks, I'm just trying to get a fuller picture. A I'm hesitant in supporting it just so folks can pick different names for the configuration files. And ironically you may want to configure that flag in say the What would be the expected priority order between these various files? E.g. Babel 6 loads |
|
Using a prexisting tool that many projects use is much preferable than a “roll your own” approach in my opinion. Convention is good! |
@sindresorhus are you sure you’re not willing to reconsider your stance on this? As outlined, there are a lot of good reasons to make this change and the only reason not to is “we don’t want multiple ways to configure things”. If you use a tool like cosmiconfig you don’t have to make any decisions as the tool does it for you. This means AVA stays simple because it just says “use cosmiconfig to handle config”. Nearly every major project has a dot file/config file (Babel, Prettier, Mocha, Lerna, nvm, etc.) and I believe it is because there are legitimate reasons to do this. Please reconsider so that users of AVA have options that work for them. Thanks! |
@danawoodman I'm also on the core team. We'll be taking all of this into account and go from there. Meanwhile, please keep the feedback coming! |
@novemberborn, good to know! Would be very excited to see this change. Being able to copy a config file from one project to another sure beats manually editing |
After 2 yrs if you still need this that bad I recommend move to a framework that supports your needs. I opened this issue and have long since left Ava for Jest. |
I've been thinking about this a bit. I can definitely see some interesting use cases for an I see less need for an I propose the following behavior:
Down the line I'd be interested in exploring a Eventually it'd also be good to Thank you @jtag05, @pho3nixf1re and @danawoodman for pushing us on this issue. Please let me know if you're interested in implementing this before I get round to it. |
@novemberborn Although I disagree about the JSON format in an 'rc' file I am fine with the proposal. It solves the need and allows for a lot of future flexibility. Thank you for discussing this with us and coming up with a good compromise on the solution. |
I know this issue is re-opened, but I'd like to add some points
I decided to try Ava today for the first time, because it looks awesome. However, without so much as a Despite how awesome Ava looks, I simply can't use it unless I can tell it where to look for configuration (in the shared package), and I want to avoid unwieldy command line arguments. Furthermore, when configurations are stored in separate files (particularly in JSON form, or they export a JS object), it makes it easier for projects that use the shared config to be able to extend certain configs for their own needs. Freedom of choice is the key here, it allows developer flexibility. In my case, I'm making a setup that allows me to build many JS packages without having to configure each one ever again. Al I have to write in my packages is source with latest language features, and test files. The rest is all abstracted away and shared among all my JS packages. It is only possible (in a clean way) with tools that have configurable config location. @novemberborn thanks for re-opening! |
By the way, hoping this makes it into v1.0.0 so I can come back to try it out later! Mostly everything about Ava seems really awesome, just that the config option is holding me back for now. |
@trusktr while less convenient than a |
That's true, but means the project has to know about Ava. In my case, projects don't know about the tools, and no configs (even re-export types) need to exist in the project. It's completely decoupled. There's only, at maximum, a few package.json scripts that call generic prod, dev, and test commands on my Builder archetype. |
But, true, that could be "good enough" for the time being! |
I'm not sure if this bloated thread needs another +1 comment, but my use cases are:
|
@good-idea well the feature is approved as of #520 (comment) — it's ready for somebody to pick up 😉 |
@novemberborn I'm looking into it right now. I'm a little confused by this line in your comment:
When you say "this file" are you referring to
Is that what you're thinking? |
@good-idea good catch. I meant to give the ambiguity warning if I've also updated the comment to reflect that we should use |
I'm not sure how viable this is currently due to the way pkg-conf is walking up until it finds a
package.json
file, but it would be nice to be able to set ava config in an.avarc
file in the root of the project.I'm not a huge fan of keeping config in my package.json or of overly verbose cli commands in
scripts
config. This is also pretty common practice with other tooling frameworks so I don't think it's too crazy of an idea.I think an initial approach could be to check the current working directory for a
.avarc
file and if not found fall back topkgConf.sync
.I would be more than willing to put together a PR if this seems like something you find appealing.
The text was updated successfully, but these errors were encountered: