-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
import/order order has different behavior across node versions - vscode forces xo to run in node v14 #103
Comments
This extensions does not do anything but apply the formatting directly from running the unaltered text of the file through xo. There are many other plugins and settings in VSCode that can reorder imports. Can you verify that running |
@novemberborn I tested on ava - and xo from cli is giving me same results as extension, and it looks to me like it's respecting the rules set up in the |
All I know is that it's a problem when I enable the extension. It doesn't make sense why this would be the only rule that's disregarded though. Perhaps there's something else VSCode does that is applied afterwards? However I don't run into this for projects that use the ESLint extension. |
@novemberborn - I just cloned ava and installed deps - then ran Can you tell me specifically what file is looking incorrect to you? |
Maybe I am confused - maybe you are reporting on the problem that the lint errors are correct, but formatting still leaves another error - and the file doesn't get fully fixed? If you format 2x it will fix the issues completely. This is a bug with the extension, can you confirm that this is the bug that you are experiencing? |
I then save (repeatedly) and the imports reorder to be completely alphabetical. Of course at this point
My workspace configuration:
|
Thanks so much for the detailed steps. This one was really bugging me as I could NOT reproduce your steps. The extension and the cli were 100% consistent for me. However, I figured out the problem. The problem is that The reason it is showing up in vscode and not in the cli for you - I would bet because you are using node v16 for cli but vscode is internally using its own bundled version nodejs which is node v14 (which is what I was using for the cli, and why I didn't see the problem initially). Since for reference see: import-js/eslint-plugin-import#2035 since Whenever I do this, everything works as expected. The eslint extension jumps through more hoops than this extension does to resolve the system versions of node and allows users to give their own path to the node runtime. Because of this bug - I will leave this open and implement the same logic for this extension. However, it may some time until I get to it. For now the best course of action unfortunately is to disable this rule, I will add a note for this behavior on the readme. TL;DR |
Actually - disabling that rule will still require you to rewrite all your imports manually to fix the vscode behavior... I am going to add the runtime option in now. Hold off on doing a rewrite - I will reply here with the correct solution soon so that you will get consisten results. |
This option is in now.
-- |
Wow, thanks for digging into this @spence-s! Kinda weird how that lint rule is Node.js version dependent. |
https://github.com/avajs/ava customizes the import ordering so that it deviates from XO 0.44. When I format AVA code using this extension, the imports are reordered according to the XO rules.
I haven't noticed any other rules being disregarded like this, but that may be due to the files I've been editing.
The text was updated successfully, but these errors were encountered: