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
not respecting builtin
#2687
Comments
I ran into this with a different built-in import ( If I use a core module like Taking a guess here that |
@shawnmcknight that is not my experience. The above config does not complain about this ordering: import express from 'express';
import log4js from 'log4js';
import chpro from 'node:child_process';
import fsp from 'node:fs/promises'; I would expect all |
@thernstig why do you have the nested array in |
I was able to partially fix this in 1fa2971 - now the same error shows up with a nested group or a flat one - but the ordering still isn't fully correct. |
@ljharb I got that from eslint-config-airbnb-base which I used as a base for creating this issue, so maybe you can answer that. I saw though that https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md does not have the nested array. But I am using eslint-config-airbnb-base so in the end I get my config from there. |
@thernstig the base config has |
@ljharb I took it from eslint-config-airbnb-base, but then just added all items from here to test them all: eslint-plugin-import/docs/rules/order.md Lines 105 to 121 in 683d3a5
Is eslint-config-airbnb-base wrong? |
No, it’s not wrong, i was just curious where the config comes from. |
👋🏻 is the (partial) fix for this correct, particularly this conditional? After updating to 2.28.0 we're seeing I might not be fully understanding the original issue in this thread, but I would've thought it would be solved by de-nesting? It looks like the Airbnb config example is: I note that there's a TODO in the conditional and this is a described as a partial fix, so maybe the new behaviour is intended to be reverted eventually? |
@yndajas that sounds right to me. If the behavior has changed in v2.28.0 then that's a bug that needs fixing. |
@ljharb glad I'm not confused! Shall I open a new issue or leave it with you? |
@yndajas I think this issue probably covers it; a PR would be most helpful :-) |
1fa2971 changed the way groups work when there is only one, leading to single nested groups being treated as though they were unnested. Prior to this, if you wanted to group e.g. builtin and external imports together at the top and everything else together as a second group, a single nested group was the way to do it [It appears that this change was unintentional][1], and was made to try to fix what seems to be a misunderstanding around nested groups ([import-js#2687]). [The docs][2] continue to suggest that nested groups should be "mingled together" and makes no reference to a single nested group with no other groups being an invalid option This therefore reverts the change to how groups work when there is only one. No documentation change should be necessary given this is already the described behaviour [1]: import-js#2687 (comment) [2]: https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
1fa2971 changed the way groups work when there is only one, leading to single nested groups being treated as though they were unnested. Prior to this, if you wanted to group e.g. builtin and external imports together at the top and everything else together as a second group, a single nested group was the way to do it [It appears that this change was unintentional][1], and was made to try to fix what seems to be a misunderstanding around nested groups ([import-js#2687]). [The docs][2] continue to suggest that nested groups should be "mingled together" and makes no reference to a single nested group with no other groups being an invalid option This therefore reverts the change to how groups work when there is only one. No documentation change should be necessary given this is already the described behaviour [1]: import-js#2687 (comment) [2]: https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
1fa2971 changed the way groups work when there is only one, leading to single nested groups being treated as though they were unnested. Prior to this, if you wanted to group e.g. builtin and external imports together at the top and everything else together as a second group, a single nested group was the way to do it [It appears that this change was unintentional][1], and was made to try to fix what seems to be a misunderstanding around nested groups ([import-js#2687]). [The docs][2] continue to suggest that nested groups should be "mingled together" and makes no reference to a single nested group with no other groups being an invalid option This therefore reverts the change to how groups work when there is only one. No documentation change should be necessary given this is already the described behaviour [1]: import-js#2687 (comment) [2]: https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
@thernstig when it's nested like that, all of those groups can be intermingled. The config needs to de-nest the groups in order for their order to be enforced. |
@thernstig per @ljharb, I believe the original issue in this thread would be solved by denesting the
More detailed explanation in my earlier comment Hope that clarifies! |
Per that comment, I'll close this, but can reopen if it doesn't work out. |
Using
"eslint-plugin-import": "2.27.5"
I would expect
util
to be sorted beforelog4js
but this is not the case. Neither isnode:util
.The text was updated successfully, but these errors were encountered: