-
Notifications
You must be signed in to change notification settings - Fork 5.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
Deno fmt should ignore the node_modules directory? #4459
Comments
I don't think we should disable that. Deno doesn't do magic, and this would be arbitrary magic. |
Deno is agnostic of node. To Deno that's just a folder full of Scripts |
I agree... if you tell Deno to format stuff in a path, it will... format stuff in that path. Potentially, I could see how repeating some sort of glob path and having the ability to ignore, like |
|
Why would you put a node_modules folder in a deno project? |
I think the default This is totally different behavior from other well-known formatters. |
IMO, without an argument, only support the current directory, makes sense and there is precedence. |
👍 to fmt (and test) following .gitignore (perhaps .npmignore too 😳 ). Unfortunately external (non-deno) tools do like to dump stuff into node_modules. I don't agree this is "magic" in the same the same way as node-style module resolution in run is magic. This is pragmatic and could be well-defined in the subcommand. |
👎 for following |
This "magic" argument makes sense for
These tools/subcommands already look in the entire directory! |
Magic resolution or behaviour is bad, no matter the context. The easiest thing to do is limit to the current directory when no argument is passed. Then there is no surprises, but if someone says "go look in here" then Deno will. Simple.
You are missing my point. Deno shouldn't interpret/couple to something it doesn't own the semantics of. |
I agree. If you choose to place a node_module folder in a deno project it must be treated like everything else. I do see it as the natural behavour what its doing now where Input regarding .gitignore files: Its much faster to run the files tracked by git instead of finding all the files and removing the .gitignore ones. If it can be any inspiration for anyone you get the complete list of files checked in with
(no, im not suggesting we start using prettier - its just an example 😄 ) |
I'm sorry for late reply and thanks for many comments! First of all, I was trying to use npm modules with Node polyfill (e.g. like this: https://github.com/davidbailey00/deno-babel-demo). When I run So IMO I think it would be useful to have a way to ignore certain files 😄 |
I'm not particularly against ignoring node_modules folder. The Deno philosophy is to not have special logic for module resolution, but I'm not sure that needs to extend to "deno fmt". As far as I'm concerned it could also read |
@ry I semi-agree with that because currently Node is the only big platform that handles JS modules. However in the future that situation might change and in that case it would be convenient for the user to specify which folders may require Dprint formatting, instead of hardcoding this folders in Deno. |
Respecting |
I think this should extend beyond the node_modules folder as documentation could be kept in the same repo and to make it ignore a directory is much better than only node_modules. For example, ignoring the |
I like what is going on in #3827 Solving this issue could also be done by adding a parameter like |
I don't think deno fmt should magically ignore things, but there should be some option for excluding paths based on pattern, be it via command line argument or a configuration file of some sort (which will be either specifyable in cmd args or implicitly detected). I think higher level tools, like IDEs, should be able to utilize deno fmt and stich it with logic relevant to them, i.e. the IDE will parse the .gitignore file and pass the exclusions list to deno fmt. |
@lucacasonato Just saw you were cleaning issues. I think this can be closed since |
This is still a massive pain e.g. in a project that happens to include several node projects (or examples) where the node_modules are nested in deeper subdirectories (so not clear how you even pass that to --ignore). I don't understand the use case where you would want to format a node_modules directory. * a fact of life for the forseeable? Edit: Also in light of #12295. |
This issue can be closed! (Thanks to deno devs) just add to your config file "fmt": {
"files": {
"exclude": ["node_modules"]
}
}, Same goes for |
We should make this default when |
|
Yeah we'd have to give the flag to |
I guess the only obstacle is what are expectations for this flag. |
IMO It should be the default.
Still stands. No-one wants to do this (same with lint). |
There are probably lots of 'known' things you would never want to be included in any given operation, but IMO tools that implicitly reach around for things beyond their own concerns by default are not well composable. But we now have |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Given there is now precedent in #14138 can this be re-opened ? 😉 |
@dsherret let's just do it now? |
I think so. It would be updating this line and changing the function name: Line 726 in 2724235
|
@dsherret why "maybe 2.0" label? I think we can just land it in the next minor. |
@bartlomieju yeah, that's what I think. I removed that label (didn't add it) 😄 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
When running
deno fmt
without arguments, files in thenode_modules
directory are formatted.The text was updated successfully, but these errors were encountered: