-
Notifications
You must be signed in to change notification settings - Fork 15
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
the creeping scourge of tooling config files in project root directories #79
Comments
Would this new subdirectory also include |
@styfle Whether any given tool uses the subdirectory is up to the maintainers of that tool. For npm in particular, this seems like perhaps a risky move, given there are many assumptions across userland tools about where |
(It's not really npm's to move, either... they aren't the only consumers of it, obv) |
Moving |
Moving eslint config would be problematic for the same reason, since it composes up the hierarchy, and describes the current folder. |
what if a folder such as |
Then how would I lint my JS config files inside |
I don’t think that’s an unsolvable problem. |
It’s a problem that doesn’t need to exist tho. I think it might make sense to come up with a conventional location for some kinds of config files - project-level ones, mainly - but not for directory-level ones, like eslint/babel/npmrc/gitattributes perhaps/etc. |
@ljharb well @boneskull on the other hand, IDEs could be made to show dotfiles in a pseudo-directory. I agree that this becomes a bit disorienting, especially when I have a bunch of project folders open in my workspace and I'm scrolling between them. |
Yes, i would assume my config file would match the node version eslint runs in, but my actual files would match the node versions my production code targets - iow i think that’s the most common case. |
this issue mentions "user-specific" and "project-specific" config files, I would argue, while those are important and the noise ratio is quite high per project, however a more important vector to consider is "org-specific" config files. regardless of team size, small and large teams might be in a situation where they have to manage hundreds of projects (up to thousands in case of enterprises), those projects might be independent repositories or a collection of mono-repos with many packages and/components within. a potentially more inclusive approach to consider here, is having a central external spot for all config files, that apply by default to each project / repo, and any local file is considered inheritance / override, thus the Patten becomes:
this would massively shrink the configuration footprint, for both individuals and teams. some challenges with this approach:
some good relevant references here (though still rely on a local file) |
a config tho that lives outside the repo won’t be easily shareable across multiple devs. |
I would argue eslint, semantic-release, renovate bot and others have done a good, positive job of setting a pattern here (they use packages) that make it easily shareable |
Totally! But those all use per-directory config files, even if they reference a shared config. You’d still need a way to target an individual directory with its own config, which is what eslint config flies already achieve. Moving them into another folder adds complexity because that folder needs its own settings too. |
yep, agreed. I don't have a good answer / follow up to be honest. I wanted to at least have a mention of a 3rd "vector" beyond user and project to be included in case someone has some further patterns to surface I've solved this problem in the past by using Docker as the build tool, a central "org-wide" image (named "build-essentials") that hosts all the actual dev dependencies (webpack, eslint, etc..) with a single Dockerfile per repo that it inherits "FROM build-essentials", repos optionally have overriding local configs, but the defaults are all includdd in the build-essentials image. I also realize "use docker image dependencies" is not necessarily the approach sought here, but worth a mention as a reference how I tackled this in the past for a very large team (~400+ humans, ~800+ projects) |
If someone wants to add support for this pattern to their module, I created shannonmoeller/find-config back in 2015 for exactly this reason. Glad to see this idea being championed agin. |
fwiw, with eslint, I avoid putting eslintrc files in multiple directories, and instead use the |
I think a potential alternate perspective: Putting all those files config files into |
If you take a look at many projects, these files are rarely changed. It is very common for you to see 10 files at the root of a project which haven't been changed in 4 years, when the
It can, use less tools. I kid a bit, but seriously the number of config files is IMO a "smell". There are some reasons which are valid and bring enough value to a project to make it worth it, but shifting complexity from a number of files into less files most likely will not remove the complexity. The only way is to actually remove the complexity by removing the tools or some feature of those tools.
This is one great point, if you can make great defaults or easily shareable configs, this problem is reduced. This is basically the only reason I use |
Personally I like putting config in package.json for tools that support it. Some people don't like those extra bytes winding up in the published package though so it would be nice if npm had a built in way to exclude some keys in package.json from publishing. Or maybe if you use something like https://github.com/romefrontend/rome, but it's hard to imagine Rome will be able to beat all these other specialty tools at their own game. |
I get the impression half the reason Sindre Sorhus made |
Quite honestly, a solution I'd prefer to see: instead of trying to force a best practice on the ecosystem, support defining this in package.json. Have a |
Another direction to pursue, as opposed to trying to change "there's config files in the root" (since there are often good reasons for it), would be asking github if there's a way to hide those dotted config files on first view of the repo page (with a "show config files" button, or something). |
Toggling visibility of dotfiles on github is a bad idea as it would be a convenient place to hide malicious code. It also doesn't catch files like |
I agree. If the target is to ease the project navigation I'm not sure that suggesting a new plugin/tool to be installed in the IDE would be the solution. I would use the Tools should read that path (if any) to get the config. Regarding
I think that all remain as is: the user will add that file in the right dir
For this approach, instead, I can think only to a new |
The issue fails to show that a problem exists. It essentially just says "X is bad." I believe that changes should be made only for reasons. Please give reasons. |
There are strong advantages to having config files in the project's root directory:
In absence of compelling reasons to make the suggested change, it would be good to close this issue. |
There's been some great ideas, insights & criticisms surfaced already... so, why not throw my 2 cents in for good measure. First & foremost, I think its honorable for us to try to tackle this issue holistically (*virtual pat on back to our community). Second, I think it would be helpful to redefine/clarify the questions we're looking to answer & problem we'd like to solve for from the original post (especially to Questions:
Thoughts:
I'm open to discussing this further, including outlining any next steps, IF we can get some more interest/input by more tooling maintainers. Otherwise, I think we might want to spend more time/energy on other issues. |
It doesn't scale. There is a reason github started supporting the Its as plain and simple as that. Here is the not-stupid suggestion. eslint and vslint and friends are not going to have any actual trouble moving their current paradigm to using this. if you can check for a file in all parents, you can check for a file in a subfolder of all parents just as easily. and if you want to lint your This is a system that will scale, every potential issue raised stems from a lack of vision, given how easily they can be solved.
If you are intelligent enough to make a linter, you are intelligent enough to abstract away the folder a config is actually in, and the folder a config applies to. I really don't know why everybody is trying to bring up excuses. |
My preference would be something like:
This allows some nice defaults.... if you leave default_config_path off, if the config doesn't exist in the root, it'll check .config, otherwise it'll ignore anything not in .config, unless overridden. |
I don't think we're going to be able to get consensus on a new config directory. Getting all tools to allow you to customize the location of the config file seems more realistic. We'll direct our efforts at specific tools that don't allow this today. |
I don't see the problem... File-list too long to fit on screen ? Annoying? On unix inspired systems files and folders will be hidden if the first character of the name is a . dot Or have the tree folder become a "billboard" ? For example Github listing the files on the project front page. |
If you already got enough of clutter in project directory and you are the maintainer of any tool with config, check https://dot-config.github.io/ and see yourself as welcomed to join the movement. Start would be hard and I suspect that early adopters will be less mainstream tools, but once we pass a dozen I suspect it will likely explode as I doubt that the number of those loving 100 files in project root is big. |
@wmstack I think you are missing the point about Sadly the cool feature that vscode introduced to collapse set of files like a folder will make is less likely to agree on getting the root cleaned. Unfortunately they decided to call this feature file nesting instead of using the far more popular terms like folding, collapsing or grouping, making it very hard to find and configure. |
The only possible way to reduce config clutter is to create a config-manager tool that parses well-organized config folders/files and compiles them to the correct location (project root) when needed.. Potentially, it could reduce the number of root config files from like 16 to 3 or 4. But we also need to consider: Would it really be neater? Splitting up your configurations between root .config could potentially just make it harder for people reading your project to figure out what's going on. Either the config-manager's config is extremely neat or it would have to auto-generate some "project configuration description" that totally describes everything going on in all the config files. The problem is, the way things are now seems to work pretty well. Sure it looks bad, but it just works. That said, it might be one of those "once you feel it you never go back" situations where someone makes a config-manager and suddenly everyone in the industry NEEDS it. |
Hey guys.I have been trying to find a solution to minimise count of configs for 2 days and here is my conclusion. Currently there is no opportunity to specify config file for the most of popular IDE plugins like ButYou can easily move everything related to webpack configuration, or any other configs/sub-configs which are used inside the // package.json
"jest": {
"setupFiles": [
"./configs/jest-setup.js" // you are able to store `jest-setup.js` everywhere!
]
} So you can easily relieve your root. BUTYou do not need it anymore. https://marketplace.visualstudio.com/items?itemName=JeremyFunk.hidefiles |
Splitting this out from #71 which was rather broad. There are (at least) two separate issues there; one is where user-specific config files should live, and another is where project-specific config files should live. This issue is about project-specific config files.
The files we're talking about are configuration files for development dependencies and are committed to VCS.
Many projects suffer from the problem of too many config files in the project root, as @iansu tweeted:
We put config files in the project root because we put config files in the project root. There is no reason other than a lack of an alternative convention.
We can do better than this. The idea is we aim for a "critical mass" of popular tooling authors moving their project-specific configuration to a subdirectory (e.g.,
.config/
). If we can agree on a subdirectory, and change our tools to support the new subdirectory, we will significantly reduce this problem. It's our hope (though not a strict requirement) that the convention we agree upon will be flexible enough to reach beyond the JS ecosystem. For instance, your.travis.yml
andnetlify.toml
could live in this directory as well, if this idea becomes popular enough.We should get buy-in from maintainers of popular tools; if these tools adopt the new subdirectory, it's likely the ecosystem will slowly follow suit.
cc @nodejs/tooling @nodejs/package-maintenance
The text was updated successfully, but these errors were encountered: