Skip to content
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

[Fix] Revert breaking group change in order #2854

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## [Unreleased]

### Fixed
- [`order`]: revert breaking change to single nested group ([#2854], thanks [@yndajas])

### Changed
- [Docs] remove duplicate fixable notices in docs ([#2850], thanks [@bmish])

Expand Down Expand Up @@ -1082,6 +1085,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
[#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
Expand Down Expand Up @@ -1887,5 +1891,6 @@ for info on changes for earlier releases.
[@wtgtybhertgeghgtwtg]: https://github.com/wtgtybhertgeghgtwtg
[@xM8WVqaG]: https://github.com/xM8WVqaG
[@xpl]: https://github.com/xpl
[@yndajas]: https://github.com/yndajas
[@yordis]: https://github.com/yordis
[@zloirock]: https://github.com/zloirock
4 changes: 0 additions & 4 deletions src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ const types = ['builtin', 'external', 'internal', 'unknown', 'parent', 'sibling'
// Example: { index: 0, sibling: 1, parent: 1, external: 1, builtin: 2, internal: 2 }
// Will throw an error if it contains a type that does not exist, or has a duplicate
function convertGroupsToRanks(groups) {
if (groups.length === 1) {
// TODO: remove this `if` and fix the bug
return convertGroupsToRanks(groups[0]);
}
const rankObject = groups.reduce(function (res, group, index) {
[].concat(group).forEach(function (groupItem) {
if (types.indexOf(groupItem) === -1) {
Expand Down
61 changes: 26 additions & 35 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ context('TypeScript', function () {
};

ruleTester.run('order', rule, {
valid: [
valid: [].concat(
// #1667: typescript type import support

// Option alphabetize: {order: 'asc'}
Expand Down Expand Up @@ -2962,7 +2962,31 @@ context('TypeScript', function () {
},
],
}),
],
isCoreModule('node:child_process') && isCoreModule('node:fs/promises') ? [
ljharb marked this conversation as resolved.
Show resolved Hide resolved
test({
code: `
import express from 'express';
import log4js from 'log4js';
import chpro from 'node:child_process';
// import fsp from 'node:fs/promises';
`,
options: [{
groups: [
[
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
],
}],
}),
] : [],
),
invalid: [].concat(
// Option alphabetize: {order: 'asc'}
test({
Expand Down Expand Up @@ -3218,39 +3242,6 @@ context('TypeScript', function () {
// { message: '`node:fs/promises` import should occur before import of `express`' },
],
}),

test({
code: `
import express from 'express';
yndajas marked this conversation as resolved.
Show resolved Hide resolved
import log4js from 'log4js';
import chpro from 'node:child_process';
// import fsp from 'node:fs/promises';
`,
output: `
import chpro from 'node:child_process';
import express from 'express';
import log4js from 'log4js';
// import fsp from 'node:fs/promises';
`,
options: [{
groups: [
[
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
],
}],
errors: [
{ message: '`node:child_process` import should occur before import of `express`' },
// { message: '`node:fs/promises` import should occur before import of `express`' },
],
}),
] : [],
),
});
Expand Down
Loading