-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support for maxLineLength setting in vscode-settings #39
Comments
@Nxt3, thanks for the feedback! Could you provide links about the issues and recommendations? I need to understand them better before making decisions. Basically, |
Sure: #36 (comment) and #29 (comment) |
Yes I'm running into the same problem. If there was a way to have it format so that everything is always on one line and then let prettier handle it that would probably be the fix. |
That's essentially running prettier after this extension, which you said couldn't achieve. |
The other person was posting the issue was saying that if you had the following:
ts-import-sorter would format it like so:
whereas prettier would leave it like this:
so that would imply that there is some extra processing happening in ts-import-sorter to make that happen, right? |
Yes, this extension pre-calculates the line length and if it exceeds the limit, it will wrap the statement. |
That's correct: prettier does not format imports in that way; it's left as one-line regardless of line length. |
Thanks for the reference, that's helpful! So what I recommend now is implementing the compatible behaviour with prettier, if it's found. Otherwise wrap the line. And this shouldn't be a big change so it's more than welcome if you'd like to do it in case you're interested. |
Any chance you could point me to which files to look at? If I found some time I wouldn't mind taking a stab. |
Thanks! One note is that you might want to check whether the following are wrapped or not by prettier: import 'a-veeeeeeery-looooooooooong-veeeeeeery-looooooooooong-script';
import A = require('b-veeeeeeery-looooooooooong-veeeeeeery-looooooooooong-module'); As this extension WILL wrap them. |
This is great, compatibility with Prettier would be awesome! Look forward to this change! |
@Nxt3, have you started anything on this thread? Otherwise I'm going to pick it up soon. Thanks! |
@daidodo I haven't had a chance 🙃 |
No worries, I'll pick it up then. There are some other issues and more in the TODO list if you still want to get your feet wet. |
Prettier StudyDid a few experiments in Prettier Playground Seems Prettier doesn't wrap an long import/export declaration except:
When wrapping, there is ONE name per line. So the extension needs the following to be compatible:
Recommended SolutionAdd a new option
When merging config, Cons:
Alternatives1. An option for not breaking lines for certain casesAdd an option, e.g. Cons:
2. An option to do all the mimicAdd an option, e.g. Cons:
Discussions
@Nxt3 and @karlhorky, please tell me if you have any thoughts! Edit:More studies on PrettierIt doesn't consider long comments when wrapping: import { A, B } from 'a'; // long long comment
export { A, B }; // long long comment
export { A, B } from 'a'; // long long comment
|
That was a nice write-up! Thanks for putting that together. I'm a fan of Option 2 with |
Option 2 was my favourite too as a straightforward solution. But the nitpicking I don't have the data but generally I don't expect people use |
Yeah, although I don't know the project too well, I would also vote for the recommended solution (breaking change, but less confusing). There's been so many times that dealing with confusing APIs has led to hours of pain for me and those around me. Breaking changes mean everyone is affected, but less pain overall (and this extension is relatively "young" still, so breaking changes hurt less). |
@Nxt3 and @karlhorky, I've release v7.0.0 with the recommended solution. Thanks! |
Good catch! Fix is coming. |
@karlhorky Please try v7.0.1. |
Looks good to me, thanks! I've added it to the System Setup Guide for our coding bootcamp at @upleveled and we'll use it together with the students and report any issues :) |
Thanks! I'll close the issue but feel free to reopen or create a new one if you have any questions. |
Forgot to leave some appreciation! This turned out beautifully; makes this extension the first one to get sorting / format correct. Fantastic job and thanks again! |
I've seen it recommended a few places here to use the
maxLineLength: 0
setting when running into issues with prettier.Would it be possible to set this in vscode settings as opposed to the
importSorter
config?The text was updated successfully, but these errors were encountered: