-
Notifications
You must be signed in to change notification settings - Fork 52
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
.editorconfig is not picked up with --baseDir #100
Comments
sorry for late reply. I recommend you to write indent settings to tsfmt.json. typescript-formatter/lib/provider/editorconfig.ts Lines 11 to 14 in 888b51e
|
I'm a bit confused. So it's expected, but not intended? In other words, support for editorconfig with baseDir is desired, but not implemented yet? Would you mind a pull request with a fix? I will have some spare time at the weekend and might wanna fix it, I think it shouldn't be too hard. |
I recommend to you use tsfmt.json in baseDir. |
My comment turned out to be a lot of text, so first I wanted to say that I applied some hack to my emacs which kinda solves this issue for me (thank god emacs is so customizable!). So if you think that this issue is unimportant or that you are right and I'm talking nonsense, then just close this issue. Still, I think I have some valid points so I'm talking about them below: I don't quite understand what makes .editorconfig so special. The same argument that you make can apply to tsfmt.json (or other config sources files). There are editors which use settings from tsfmt.json for formatting. In fact, tsserver does it, so any editor which uses tsserver as backend also uses tsfmt.json (for example, emacs with tide-mode and I believe there is extension for Visual Studio Code to use tsserver as well and probably there are other editors). You say that "editorconfig is directory oriented specifications". Same, I don't understand how it is different from tsfmt.json. Both of them contain a number of formatting settings which are intended to be applied to files in underlying directory. Can't you say that tsfmt.json is a directory oriented specification? May be I just don't understand the purpose of baseDir. So I'll tell you what is the use case for this issue. I'm using spacemacs (it's a customized version of emacs) with typescript configuration layer, and it is set up to use tsfmt to do formatting on file save. It uses tsfmt in a certain way:
So the intention here is that setting baseDir to a certain directory makes tsfmt to behave exactly the same regardless of the fact that the file-to-be-formatted is located somewhere else (in tmp directory in this case). Clearly it is not currently the case with .editorconfig present. As for your recommendation to use tsfmt.json for storing settings, I can't quite follow it, because I work with a team of users of Visual Studio Code, and they use built-in formatting, which doesn't support tsfmt.json. On the contrary, tsfmt does support VSCode settings, so its kinda not a problem except for indentation - it seems that tsfmt doesn't pick up indentation settings from VSCode config (I haven't actually checked it myself but that was my impression as in https://github.com/vvakame/typescript-formatter#read-settings-from-files in the section for VSCode there is no mention of indentation options, only for formatting ones). So we ended up using editorconfig for specifying indentation as it is supported both by VSCode (via plugin) and tsfmt. |
umm... BYW, tsfmt.json is typescript-formatter specific config file.
|
Settings from .editorconfig are not picked up by tsfmt with --baseDir.
Here is file structure I'm using https://gist.github.com/Eoksni/49cbac2c0a6cfd17b1d93b699098ac8a.
Here is what I do
Both files
project\test.ts
andouter\test.ts
are exactly equal, and by applying tsfmt to them with same baseDir I expect the same output, which is not the case here. Notice that settings from tsfmt.json were indeed picked up (space after anonymous function), but settings from .editorconfig were not (indentation should be 2 instead of default 4).The text was updated successfully, but these errors were encountered: