deno icon indicating copy to clipboard operation
deno copied to clipboard

`deno fmt` and `deno lint` should ignore hidden directories by default

Open bartlomieju opened this issue 1 year ago • 1 comments

Reproduction in https://github.com/denoland/deno/issues/26519#issuecomment-2439746067 makes it very clear that formatting and linting directories like .next/ is not a good idea.

It takes a long time and makes little sense - the build artifacts are best left alone unless user really means to format them. So I think we should change the default globs for deno fmt and deno lint to exclude hidden directories by default.

The reason to exclude all hidden directories is that if we decide on a list of directories to exclude, we'll have to keep adding to it - .next, .vite, .vitest, etc. 99% of users don't want these directories to be touched by deno fmt, as recently shown in https://github.com/denoland/deno/issues/26402.

bartlomieju avatar Oct 27 '24 00:10 bartlomieju

I don't think this is a good approach, because some projects don't set the build directories as hidden (e.g. Nest JS with the TS dist directory), and it's also feasible that some project could have an actually useful hidden directory. I think it would be better if the include option just worked more predictably. In that linked reproducible example I have just the *.ts files included, but the formatter and linter still try to process other file types too.

mintydev789 avatar Oct 27 '24 08:10 mintydev789

Going to go with https://github.com/denoland/deno/pull/26897 which respects .gitignore file and doesn't fmt/lint files that are ignored - this should cover most cases as various frameworks will produce .gitignore files that exclude and dist/build directories.

bartlomieju avatar Nov 16 '24 15:11 bartlomieju

@bartlomieju Is there a way to opt out of this new behavior (automatically subscribing to .gitignore) without having to list all of the entries again in the deno config include section?

jsejcksn avatar Nov 22 '24 02:11 jsejcksn

@bartlomieju Is there a way to opt out of this new behavior (automatically subscribing to .gitignore) without having to list all of the entries again in the deno config include section?

No, it works the same way as excluding node_modules/ directory and/or vendor directories.

bartlomieju avatar Nov 22 '24 15:11 bartlomieju