Skip to content
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

Don’t ignore dotfiles by default #55

Closed
4 tasks done
remcohaszing opened this issue Dec 1, 2021 · 14 comments
Closed
4 tasks done

Don’t ignore dotfiles by default #55

remcohaszing opened this issue Dec 1, 2021 · 14 comments
Labels
💪 phase/solved Post is done 🧑 semver/major This is a change

Comments

@remcohaszing
Copy link
Member

Initial checklist

Problem

IMO it’s a bad practice to exclude dotfiles from a project’s code quality standards such as remark-lint. I.e. I don’t understand why one wouldn’t want to check the various markdown files in the .github or .gitlab directory.

Currently there appears to be no way to include dotfiles, except by explicitly passing the dotfile to the CLI.

I think this idea originates from ESLint (where I also think it’s a bad idea), but at least ESLint allows to unignore dotfiles by adding the following .eslintignore file:

!.*

This doesn’t work for .remarkignore.

Solution

Don’t ignore dotfiles by default.

Alternatives

Allow to unignore dotfiles.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Dec 1, 2021
@wooorm
Copy link
Member

wooorm commented Dec 1, 2021

  • yeah, idea behind it is that eslint did the same
  • I believe some dependency, node-ignore perhaps, switched at some point to no longer support negated patterns.
  • different tools add dot files for various reasons, .github is a good case where checking them might make sense, but I feel like there are more cases where dotfiles contains garbage that shouldn’t be checked? (similar: node_modules/ often contains packages pulled in from npm, but you can also use it manually to manage your monorepo)

I’d rather add support for negated patterns rather than change the default?

@remcohaszing
Copy link
Member Author

Personally I have yet to find a situation where I want to skip checking for a dotfile. All of my projects explicitly unignore them for ESLint. Also Prettier for example doesn’t ignore dotfiles by default.

@wooorm
Copy link
Member

wooorm commented Dec 1, 2021

prettier takes .gitignore by default though, right?
And folks have these giant gitignore often: https://github.com/github/gitignore/blob/master/Node.gitignore.

@remcohaszing
Copy link
Member Author

prettier takes .gitignore by default though, right?

Nope prettier/prettier#8506

And folks have these giant gitignore often: https://github.com/github/gitignore/blob/master/Node.gitignore.

Personally not a fan 😅

Anyway, this doesn’t ignore dotfiles either.

@wooorm
Copy link
Member

wooorm commented Dec 1, 2021

ah it’s xo, which I was thinking of.

Personally not a fan 😅

Same.

Anyway, this doesn’t ignore dotfiles either.

It ignores many dotfiles. Which is what I’m trying to point out (earlier point):

different tools add dot files for various reasons, .github is a good case where checking them might make sense, but I feel like there are more cases where dotfiles contains garbage that shouldn’t be checked? (similar: node_modules/ often contains packages pulled in from npm, but you can also use it manually to manage your monorepo).

There are some cases where dotfiles should be checked. There are many cases where dotfiles shouldn’t be checked.
You’re proposing to change the default. I think the default should make sense in most cases. I think the default of dotfiles and node_modules/ is most sensical.

Are there common cases, other than .github and .gitlab, which you believe should be checked?

@wooorm
Copy link
Member

wooorm commented Dec 3, 2021

How acceptable do you see the alternative?

@remcohaszing
Copy link
Member Author

I can think of many more cases of dotfiles that I would like to be checked if a linter is available, namely every dotfile I’ve ever checked into source control and has a linter available. I can’t think of any markdown file other than those inside .github/ or .gitlab/, but if they appear, I’d like them to be checked unless they’re explicitly ignored.

Since this isn’t related specifically to markdown, I can think of a practical list of files that should be linted IMO:

  • .babelrc.js
  • .eslintrc.js
  • .lighthouserc.js (it isn’t different from lighthouse.config.js apart from the name)
  • .prettierc.js (it isn’t different from prettier.config.js apart from the name)
  • .stylelintrc.js (it isn’t different from stylelint.config.js apart from the name)
  • etc.

My point is the dot prefix doesn’t make them special. It just means they don’t show up in typical file explorers and ls without flags.

There are some special cases of files which I think should be ignored by default, but this determined by their purpose, not their filename:

  • .git/
  • .hg/
  • .svn/
  • bower_components/ (Is this still relevant)
  • node_modules/

Typically my .{name}ignore matches .gitignore, except maybe some additional special cases are added.


How acceptable do you see the alternative?

I wouldn’t like it, because IMO this means every repository that has issue templates needs an ignore file to unignore dotfiles. However, changing default behaviour would be a breaking change (semver major), whereas adding the ability to unignore files is a feature (semver minor).

@wooorm
Copy link
Member

wooorm commented Dec 3, 2021

I can think of many more cases of dotfiles that I would like to be checked if a linter is available, namely every dotfile I’ve ever checked into source control and has a linter available
Typically my .{name}ignore matches .gitignore, except maybe some additional special cases are added.

Copy/pasting and manually syncing your .gitignore file into every linter’s ignore file (prettierignore, eslintignore, remarkignore) seems like a lot of work to me. Are you saying you’re doing this? I believe most linters allow you to pass the .gitignore file to them. You can do the same with unified-engine?

My point is the dot prefix doesn’t make them special. It just means they don’t show up in typical file explorers and ls without flags.

I think it was a mistake to prefix configuration files with a dot and thus “hide” them. It’s something we’re stuck with though.
A different use case is intermediate files. This isn’t consistent either of course, but looking to the node gitignore list linked earlier, there are many cases: .nyc_output, .grunt, .rpt2_cache/, .rts2_cache_cjs/, .rts2_cache_es/, .rts2_cache_umd/, .cache, .parcel-cache, .next, .nuxt/, .cache/, .vuepress, .serverless, .fusebox, .dynamodb, .vscode-test, .yarn.

Agreed they’re not special but I see correlation. And precedence, with ESLint.

I wouldn’t like it, because IMO this means every repository that has issue templates needs an ignore file to unignore dotfiles. However, changing default behaviour would be a breaking change (semver major), whereas adding the ability to unignore files is a feature (semver minor).

Indeed.

I’m not 100% that .github/ should be checked/formatted by default: issue/PR templates render differently from other markdown files: using a h1 there comes out way too big and line wrapping will persist (<br>s). The form versions of templates seem like a much better idea.

I’m quite happy that .github/ isn’t checked by default for the places that unified has them. I’d probably ignore them if they would be checked by default.

@wooorm
Copy link
Member

wooorm commented Dec 30, 2021

I don’t see a good enough reason to change the default. It seems to be something where some people prefer one or the other.
Both options will mean ignoring things. Whether ignoring intermediate dotfile folders (.nyc_output, .grunt, .rpt2_cache/, .rts2_cache_cjs/, .rts2_cache_es/, .rts2_cache_umd/, .cache, .parcel-cache, .next, .nuxt/, .cache/, .vuepress, .serverless, .fusebox, .dynamodb, .vscode-test, .yarn) or unignoring some dotfile folders (.github, .gitlab). Adding more patterns to the default (like node_modules) is also a slippery slope (e.g., some people do want node_modules checked).
In many cases, you can pass .github or whatever files you want in directly to the engine. For other cases, I’m open to adding support for negated dotfiles (!.*).

@titanism
Copy link

titanism commented Jun 7, 2022

We've found this to be a good solution, since most of our issues were from cosmiconfig's not being linted by XO or eslint:

echo '!.*.js' >> .eslintignore

@djmcgreal-cc
Copy link

Can we unignore files starting with a . already? Sorry it wasn't clear to me from the conversation so far.

@wooorm
Copy link
Member

wooorm commented May 25, 2023

Yeah, pass them (or node_modules) as files or globs explicitly.

P.s. With time I'm leaning a little more towards favouring this. What's everybody else thinking?

@remcohaszing
Copy link
Member Author

I’m still in favour of not ignoring dotfiles by default. Recently I’ve been using Changesets in some projects, which uses markdown files in a .changeset directory. I find it unfortunate those aren’t checked using remark. I still also think the .github and .gitlab directories should be checked. Dotfiles just aren’t special IMO. They can be ignored explicitly if desired just like any other file.

@wooorm wooorm closed this as completed in 2249314 Aug 17, 2023
@wooorm wooorm added 🧑 semver/major This is a change 💪 phase/solved Post is done labels Aug 17, 2023
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Aug 17, 2023
@djmcgreal-cc
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done 🧑 semver/major This is a change
Development

No branches or pull requests

4 participants