Skip to content

editorconfig: Only search for .editorconfig up to the VCS directory#3559

Merged
azz merged 4 commits intoprettier:masterfrom
josephfrazier:editorconfig-root
Dec 26, 2017
Merged

editorconfig: Only search for .editorconfig up to the VCS directory#3559
azz merged 4 commits intoprettier:masterfrom
josephfrazier:editorconfig-root

Conversation

@josephfrazier
Copy link
Copy Markdown
Collaborator

This addresses #3558

I'm not sure if this is the best way to find the "project root", but it
seems better than before.

This addresses prettier#3558

I'm not sure if this is the best way to find the "project root", but it
seems better than before.
@rattrayalex
Copy link
Copy Markdown
Collaborator

Would this impact the behavior of something like
./prettier --write '../../some/where/else/**/*.js'?

What about monorepo/lerna-style projects, which might have something like this:

.editorconfig # establishes baseline
packages/
   foo/
     package.json
     .prettierrc # overrides something specific to foo
   bar/
     package.json
     .prettierrc

I actually don't know prettier's current behavior here, or what's desired.

@azz
Copy link
Copy Markdown
Member

azz commented Dec 24, 2017

I think finding the VCS directory might work?

Something like https://npmjs.com/package/find-project-root? Not sure...

@josephfrazier
Copy link
Copy Markdown
Collaborator Author

Yeah @azz, I think finding the VCS directory would work far better, and handle the cases that @rattrayalex pointed out. One potential issue is that projects that don't use source control wouldn't be able to take advantage of the .editorconfig support, but I imagine that use case is vanishingly small, and being able to format files (taking .editorconfig into account) outside the current directory is far more important.

This uses [find-project-root] to find the nearest directory containing `.git` or `.hg`

See here for context: prettier#3559 (comment)

[find-project-root]: https://github.com/kirstein/find-project-root
@josephfrazier josephfrazier changed the title editorconfig: Only search for .editorconfig up to $PWD editorconfig: Only search for .editorconfig up to the VCS directory Dec 24, 2017
@azz
Copy link
Copy Markdown
Member

azz commented Dec 25, 2017

Actually, any way we could add a test for this?

@rattrayalex
Copy link
Copy Markdown
Collaborator

rattrayalex commented Dec 25, 2017

Do the docs for .editorconfig claim/imply that it must exist at a VCS root? (I also assume that it typically would, so I'd probably be 👍 to this going out regardless).

I'm not sure we need a test if we're using a third-party-package that has tests. looks at npm package ah, it doesn't even have a repo listed.

@azz
Copy link
Copy Markdown
Member

azz commented Dec 25, 2017

Here's the tests: https://github.com/kirstein/find-project-root/blob/master/test/index.spec.js

I'd like to have one integration test for this though to document the expected behaviour.

It's a little hacky in that the .hg file isn't really a Mercurial
repository, but it's enough to illustrate the intent. See here for
context: prettier#3559 (comment)
@josephfrazier
Copy link
Copy Markdown
Collaborator Author

I added a quick test in d9b2447.

I also noticed that the .prettierrc search also doesn't stop at the VCS directory, currently. We should probably fix that too.

@azz azz merged commit 7b211ea into prettier:master Dec 26, 2017
@azz
Copy link
Copy Markdown
Member

azz commented Dec 26, 2017

Thanks! I'm less concerned about prettierrc because that's a more explicit intent.

@josephfrazier
Copy link
Copy Markdown
Collaborator Author

Good point @azz, thanks for merging.

@josephfrazier josephfrazier deleted the editorconfig-root branch December 27, 2017 14:38
@azz azz added this to the 1.10 milestone Jan 7, 2018
@lock lock Bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 18, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants