Repository: azat-io/eslint-plugin-perfectionist
Pull request #556 (2025-06-10 12:33:13)

fix: prevent newlines fixes between different partitions
- Related comment: https://github.com/azat-io/eslint-plugin-perfectionist/issues/479#issuecomment-2953160238
- Follow-up of https://github.com/azat-io/eslint-plugin-perfectionist/pull/554

## Description

Users can separate partitions with comments using `partitionByComment`. However, newlines errors and fixes will be raised/applied between two consecutive elements of different partitions.
https://github.com/azat-io/eslint-plugin-perfectionist/pull/554 reduced the occurrences of this happening, but it may still happen in some configurations, such as when partition A depends on the first groups of the `groups` option, and partition B depends on last groups of the `groups` options.

## Code example

```ts
"perfectionist/sort-imports": ["error", {
    groups: [
      "external",
      'sibling'
    ],
    newlinesBetween: "never",
    partitionByComment: true,
    type: "alphabetical"
}]
```

```ts
import a from 'a';

// Siblings

import { c } from './c';
import { b } from './b';
```

Gets linted into ➡️

```ts
import a from 'a';
// Siblings
import { b } from './b';
import { c } from './c';
```
❌ *Newline enforced between partitions above and before // Siblings*

### What is the purpose of this pull request?

- [x] Bug fix


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/azat-io/eslint-plugin-perfectionist/pull/556?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azat+S.) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`05b4797`)](https://app.codecov.io/gh/azat-io/eslint-plugin-perfectionist/commit/05b47975ee7f2769a28a93e7ba3cf9cb010d7231?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azat+S.) to head [(`855115b`)](https://app.codecov.io/gh/azat-io/eslint-plugin-perfectionist/commit/855115b74741e5c08e2e7daf518a206da9bbf838?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azat+S.).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main      #556   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          101       101           
  Lines         8318      8340   +22     
  Branches      1679      1678    -1     
=========================================
+ Hits          8318      8340   +22     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/azat-io/eslint-plugin-perfectionist/pull/556?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azat+S.).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azat+S.).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
azat-io: Nice, thank you!

Patch:
diff --git a/rules/sort-array-includes.ts b/rules/sort-array-includes.ts
index 4c59263..caa955a 100644
--- a/rules/sort-array-includes.ts
+++ b/rules/sort-array-includes.ts
@@ -229,7 +229,7 @@ export let sortArray = <MessageIds extends string>({
         options,
       })
 
-      let sortingNode: SortArrayIncludesSortingNode = {
+      let sortingNode: Omit<SortArrayIncludesSortingNode, 'partitionId'> = {
         isEslintDisabled: isNodeEslintDisabled(element, eslintDisabledLines),
         size: rangeToDiff(element, sourceCode),
         node: element,
@@ -250,7 +250,10 @@ export let sortArray = <MessageIds extends string>({
         accumulator.push([])
       }
 
-      accumulator.at(-1)!.push(sortingNode)
+      accumulator.at(-1)!.push({
+        ...sortingNode,
+        partitionId: accumulator.length,
+      })
 
       return accumulator
     },
diff --git a/rules/sort-classes.ts b/rules/sort-classes.ts
index 4fb1b49..6db8f45 100644
--- a/rules/sort-classes.ts
+++ b/rules/sort-classes.ts
@@ -542,7 +542,7 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
           let overloadSignatureGroupMember =
             overloadSignatureGroups[overloadSignatureGroupMemberIndex]?.at(-1)
 
-          let sortingNode: SortClassSortingNodes = {
+          let sortingNode: Omit<SortClassSortingNodes, 'partitionId'> = {
             dependencyNames: [
               getDependencyName({
                 nodeNameWithoutStartingHash: name.startsWith('#')
@@ -580,7 +580,10 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
             accumulator.push([])
           }
 
-          accumulator.at(-1)!.push(sortingNode)
+          accumulator.at(-1)!.push({
+            ...sortingNode,
+            partitionId: accumulator.length,
+          })
 
           return accumulator
         },
diff --git a/rules/sort-decorators.ts b/rules/sort-decorators.ts
index e28638f..52a591b 100644
--- a/rules/sort-decorators.ts
+++ b/rules/sort-decorators.ts
@@ -211,7 +211,7 @@ let sortDecorators = (
         name,
       })
 
-      let sortingNode: SortDecoratorsSortingNode = {
+      let sortingNode: Omit<SortDecoratorsSortingNode, 'partitionId'> = {
         isEslintDisabled: isNodeEslintDisabled(decorator, eslintDisabledLines),
         size: rangeToDiff(decorator, sourceCode),
         node: decorator,
@@ -231,7 +231,10 @@ let sortDecorators = (
         accumulator.push([])
       }
 
-      accumulator.at(-1)!.push(sortingNode)
+      accumulator.at(-1)!.push({
+        ...sortingNode,
+        partitionId: accumulator.length,
+      })
 
       return accumulator
     },
diff --git a/rules/sort-enums.ts b/rules/sort-enums.ts
index a10735c..15f8276 100644
--- a/rules/sort-enums.ts
+++ b/rules/sort-enums.ts
@@ -161,7 +161,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
           })
 
           let lastSortingNode = accumulator.at(-1)?.at(-1)
-          let sortingNode: SortEnumsSortingNode = {
+          let sortingNode: Omit<SortEnumsSortingNode, 'partitionId'> = {
             numericValue: member.initializer
               ? getExpressionNumberValue(
                   member.initializer,
@@ -191,7 +191,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
             accumulator.push([])
           }
 
-          accumulator.at(-1)!.push(sortingNode)
+          accumulator.at(-1)!.push({
+            ...sortingNode,
+            partitionId: accumulator.length,
+          })
           return accumulator
         },
         [[]],
diff --git a/rules/sort-exports.ts b/rules/sort-exports.ts
index 76aa460..3ca7088 100644
--- a/rules/sort-exports.ts
+++ b/rules/sort-exports.ts
@@ -125,7 +125,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
         options,
       })
 
-      let sortingNode: SortExportsSortingNode = {
+      let sortingNode: Omit<SortExportsSortingNode, 'partitionId'> = {
         isEslintDisabled: isNodeEslintDisabled(node, eslintDisabledLines),
         groupKind: node.exportKind === 'value' ? 'value' : 'type',
         size: rangeToDiff(node, sourceCode),
@@ -134,11 +134,11 @@ export default createEslintRule<Options, MESSAGE_ID>({
         name,
         node,
       }
-      let lastNode = formattedMembers.at(-1)?.at(-1)
+      let lastSortingNode = formattedMembers.at(-1)?.at(-1)
 
       if (
         shouldPartition({
-          lastSortingNode: lastNode,
+          lastSortingNode,
           sortingNode,
           sourceCode,
           options,
@@ -147,7 +147,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
         formattedMembers.push([])
       }
 
-      formattedMembers.at(-1)!.push(sortingNode)
+      formattedMembers.at(-1)!.push({
+        ...sortingNode,
+        partitionId: formattedMembers.length,
+      })
     }
 
     return {
diff --git a/rules/sort-heritage-clauses.ts b/rules/sort-heritage-clauses.ts
index 298d676..a0d9dfb 100644
--- a/rules/sort-heritage-clauses.ts
+++ b/rules/sort-heritage-clauses.ts
@@ -133,6 +133,7 @@ let sortHeritageClauses = (
       ),
       size: rangeToDiff(heritageClause, sourceCode),
       node: heritageClause,
+      partitionId: 0,
       group,
       name,
     }
diff --git a/rules/sort-imports.ts b/rules/sort-imports.ts
index 48d0a17..5b86e12 100644
--- a/rules/sort-imports.ts
+++ b/rules/sort-imports.ts
@@ -143,7 +143,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
       ruleName: id,
       sourceCode,
     })
-    let sortingNodes: SortImportsSortingNode[] = []
+    let sortingNodesWithoutPartitionId: Omit<
+      SortImportsSortingNode,
+      'partitionId'
+    >[] = []
 
     let flatGroups = new Set(options.groups.flat())
     let shouldRegroupSideEffectNodes = flatGroups.has('side-effect')
@@ -271,7 +274,18 @@ export default createEslintRule<Options, MESSAGE_ID>({
           name,
         }) ?? 'unknown'
 
-      sortingNodes.push({
+      let hasMultipleImportDeclarations = isSortable(
+        (node as TSESTree.ImportDeclaration).specifiers,
+      )
+      let size = rangeToDiff(node, sourceCode)
+      if (
+        hasMultipleImportDeclarations &&
+        options.maxLineLength &&
+        size > options.maxLineLength
+      ) {
+        size = name.length + 10
+      }
+      sortingNodesWithoutPartitionId.push({
         isIgnored:
           !options.sortSideEffects &&
           isSideEffect &&
@@ -280,17 +294,11 @@ export default createEslintRule<Options, MESSAGE_ID>({
         isEslintDisabled: isNodeEslintDisabled(node, eslintDisabledLines),
         dependencyNames: computeDependencyNames({ sourceCode, node }),
         dependencies: computeDependencies(node),
-        size: rangeToDiff(node, sourceCode),
         addSafetySemicolonWhenInline: true,
         group,
+        size,
         name,
         node,
-        ...(options.type === 'line-length' &&
-          options.maxLineLength && {
-            hasMultipleImportDeclarations: isSortable(
-              (node as TSESTree.ImportDeclaration).specifiers,
-            ),
-          }),
       })
     }
 
@@ -299,7 +307,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
         let contentSeparatedSortingNodeGroups: SortImportsSortingNode[][][] = [
           [[]],
         ]
-        for (let sortingNode of sortingNodes) {
+        for (let sortingNodeWithoutPartitionId of sortingNodesWithoutPartitionId) {
           let lastGroupWithNoContentBetween =
             contentSeparatedSortingNodeGroups.at(-1)!
           let lastGroup = lastGroupWithNoContentBetween.at(-1)!
@@ -307,7 +315,11 @@ export default createEslintRule<Options, MESSAGE_ID>({
 
           if (
             lastSortingNode &&
-            hasContentBetweenNodes(sourceCode, lastSortingNode, sortingNode)
+            hasContentBetweenNodes(
+              sourceCode,
+              lastSortingNode,
+              sortingNodeWithoutPartitionId,
+            )
           ) {
             lastGroup = []
             lastGroupWithNoContentBetween = [lastGroup]
@@ -316,8 +328,8 @@ export default createEslintRule<Options, MESSAGE_ID>({
             )
           } else if (
             shouldPartition({
+              sortingNode: sortingNodeWithoutPartitionId,
               lastSortingNode,
-              sortingNode,
               sourceCode,
               options,
             })
@@ -326,7 +338,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
             lastGroupWithNoContentBetween.push(lastGroup)
           }
 
-          lastGroup.push(sortingNode)
+          lastGroup.push({
+            ...sortingNodeWithoutPartitionId,
+            partitionId: lastGroupWithNoContentBetween.length,
+          })
         }
 
         for (let sortingNodeGroups of contentSeparatedSortingNodeGroups) {
@@ -517,8 +532,8 @@ export default createEslintRule<Options, MESSAGE_ID>({
 
 let hasContentBetweenNodes = (
   sourceCode: TSESLint.SourceCode,
-  left: SortImportsSortingNode,
-  right: SortImportsSortingNode,
+  left: Pick<SortImportsSortingNode, 'node'>,
+  right: Pick<SortImportsSortingNode, 'node'>,
 ): boolean =>
   sourceCode.getTokensBetween(left.node, right.node, {
     includeComments: false,
diff --git a/rules/sort-jsx-props.ts b/rules/sort-jsx-props.ts
index 1487ded..8c9b0a2 100644
--- a/rules/sort-jsx-props.ts
+++ b/rules/sort-jsx-props.ts
@@ -164,7 +164,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
               name,
             })
 
-            let sortingNode: SortingNode = {
+            let sortingNode: Omit<SortingNode, 'partitionId'> = {
               isEslintDisabled: isNodeEslintDisabled(
                 attribute,
                 eslintDisabledLines,
@@ -187,7 +187,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
               accumulator.push([])
             }
 
-            accumulator.at(-1)!.push(sortingNode)
+            accumulator.at(-1)!.push({
+              ...sortingNode,
+              partitionId: accumulator.length,
+            })
 
             return accumulator
           },
diff --git a/rules/sort-maps.ts b/rules/sort-maps.ts
index d38f87c..1e7fd50 100644
--- a/rules/sort-maps.ts
+++ b/rules/sort-maps.ts
@@ -136,7 +136,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
             options,
           })
 
-          let sortingNode: SortingNode = {
+          let sortingNode: Omit<SortingNode, 'partitionId'> = {
             isEslintDisabled: isNodeEslintDisabled(
               element,
               eslintDisabledLines,
@@ -158,7 +158,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
             formattedMembers.push([])
           }
 
-          formattedMembers.at(-1)!.push(sortingNode)
+          formattedMembers.at(-1)!.push({
+            ...sortingNode,
+            partitionId: formattedMembers.length,
+          })
         }
 
         for (let nodes of formattedMembers) {
diff --git a/rules/sort-modules.ts b/rules/sort-modules.ts
index 3e628c8..8b1c48c 100644
--- a/rules/sort-modules.ts
+++ b/rules/sort-modules.ts
@@ -307,7 +307,7 @@ let analyzeModule = ({
       options,
     })
 
-    let sortingNode: SortingNodeWithDependencies = {
+    let sortingNode: Omit<SortingNodeWithDependencies, 'partitionId'> = {
       isEslintDisabled: isNodeEslintDisabled(node, eslintDisabledLines),
       size: rangeToDiff(node, sourceCode),
       addSafetySemicolonWhenInline,
@@ -330,7 +330,10 @@ let analyzeModule = ({
       formattedNodes.push([])
     }
 
-    formattedNodes.at(-1)?.push(sortingNode)
+    formattedNodes.at(-1)?.push({
+      ...sortingNode,
+      partitionId: formattedNodes.length,
+    })
   }
 
   let sortNodesExcludingEslintDisabled = (
diff --git a/rules/sort-named-exports.ts b/rules/sort-named-exports.ts
index 789e7e2..ecbffe8 100644
--- a/rules/sort-named-exports.ts
+++ b/rules/sort-named-exports.ts
@@ -139,7 +139,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
           options,
         })
 
-        let sortingNode: SortNamedExportsSortingNode = {
+        let sortingNode: Omit<SortNamedExportsSortingNode, 'partitionId'> = {
           isEslintDisabled: isNodeEslintDisabled(
             specifier,
             eslintDisabledLines,
@@ -163,7 +163,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
           formattedMembers.push([])
         }
 
-        formattedMembers.at(-1)!.push(sortingNode)
+        formattedMembers.at(-1)!.push({
+          ...sortingNode,
+          partitionId: formattedMembers.length,
+        })
       }
 
       let groupKindOrder
diff --git a/rules/sort-named-imports.ts b/rules/sort-named-imports.ts
index c0a920b..f8dd8a3 100644
--- a/rules/sort-named-imports.ts
+++ b/rules/sort-named-imports.ts
@@ -136,7 +136,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
           options,
         })
 
-        let sortingNode: SortNamedImportsSortingNode = {
+        let sortingNode: Omit<SortNamedImportsSortingNode, 'partitionId'> = {
           groupKind:
             specifier.type === 'ImportSpecifier' &&
             specifier.importKind === 'type'
@@ -164,7 +164,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
           formattedMembers.push([])
         }
 
-        formattedMembers.at(-1)!.push(sortingNode)
+        formattedMembers.at(-1)!.push({
+          ...sortingNode,
+          partitionId: formattedMembers.length,
+        })
       }
 
       let groupKindOrder
diff --git a/rules/sort-object-types.ts b/rules/sort-object-types.ts
index 6285588..4f71956 100644
--- a/rules/sort-object-types.ts
+++ b/rules/sort-object-types.ts
@@ -302,6 +302,7 @@ export let sortObjectTypeElements = <MessageIds extends string>({
         groupKind: isMemberOptional(typeElement) ? 'optional' : 'required',
         size: rangeToDiff(typeElement, sourceCode),
         addSafetySemicolonWhenInline: true,
+        partitionId: accumulator.length,
         node: typeElement,
         group,
         value,
diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts
index 106f6dc..bca3195 100644
--- a/rules/sort-objects.ts
+++ b/rules/sort-objects.ts
@@ -336,18 +336,19 @@ export default createEslintRule<Options, MESSAGE_ID>({
               dependencyName = property.value.name
             }
 
-            let sortingNode: SortingNodeWithDependencies = {
-              isEslintDisabled: isNodeEslintDisabled(
-                property,
-                eslintDisabledLines,
-              ),
-              size: rangeToDiff(property, sourceCode),
-              dependencyNames: [dependencyName],
-              node: property,
-              dependencies,
-              group,
-              name,
-            }
+            let sortingNode: Omit<SortingNodeWithDependencies, 'partitionId'> =
+              {
+                isEslintDisabled: isNodeEslintDisabled(
+                  property,
+                  eslintDisabledLines,
+                ),
+                size: rangeToDiff(property, sourceCode),
+                dependencyNames: [dependencyName],
+                node: property,
+                dependencies,
+                group,
+                name,
+              }
 
             if (
               shouldPartition({
@@ -360,7 +361,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
               accumulator.push([])
             }
 
-            accumulator.at(-1)!.push(sortingNode)
+            accumulator.at(-1)!.push({
+              ...sortingNode,
+              partitionId: accumulator.length,
+            })
 
             return accumulator
           },
diff --git a/rules/sort-switch-case.ts b/rules/sort-switch-case.ts
index ac2049e..1b73c85 100644
--- a/rules/sort-switch-case.ts
+++ b/rules/sort-switch-case.ts
@@ -67,8 +67,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
             accumulator.at(-1)!.push({
               size: rangeToDiff(caseNode.test, sourceCode),
               name: getCaseName(sourceCode, caseNode),
+              partitionId: accumulator.length,
               isEslintDisabled: false,
               node: caseNode.test,
+              group: 'unknown',
             })
           }
           if (
@@ -120,7 +122,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
         })
       }
 
-      let sortingNodes = switchNode.cases.map(
+      let sortingNodes: SortSwitchCaseSortingNode[] = switchNode.cases.map(
         (caseNode: TSESTree.SwitchCase) => ({
           size: caseNode.test
             ? rangeToDiff(caseNode.test, sourceCode)
@@ -129,6 +131,8 @@ export default createEslintRule<Options, MESSAGE_ID>({
           addSafetySemicolonWhenInline: true,
           isDefaultClause: !caseNode.test,
           isEslintDisabled: false,
+          group: 'unknown',
+          partitionId: 0,
           node: caseNode,
         }),
       )
diff --git a/rules/sort-union-types.ts b/rules/sort-union-types.ts
index 9bd327f..11f871b 100644
--- a/rules/sort-union-types.ts
+++ b/rules/sort-union-types.ts
@@ -235,7 +235,7 @@ export let sortUnionOrIntersectionTypes = <MessageIds extends string>({
 
       let lastGroup = accumulator.at(-1)
       let lastSortingNode = lastGroup?.at(-1)
-      let sortingNode: SortingNode = {
+      let sortingNode: Omit<SortingNode, 'partitionId'> = {
         isEslintDisabled: isNodeEslintDisabled(type, eslintDisabledLines),
         size: rangeToDiff(type, sourceCode),
         node: type,
@@ -256,7 +256,10 @@ export let sortUnionOrIntersectionTypes = <MessageIds extends string>({
         accumulator.push(lastGroup)
       }
 
-      lastGroup?.push(sortingNode)
+      lastGroup?.push({
+        ...sortingNode,
+        partitionId: accumulator.length,
+      })
       return accumulator
     },
     [[]],
diff --git a/rules/sort-variable-declarations.ts b/rules/sort-variable-declarations.ts
index 729132f..ea8414a 100644
--- a/rules/sort-variable-declarations.ts
+++ b/rules/sort-variable-declarations.ts
@@ -112,7 +112,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
           })
 
           let lastSortingNode = accumulator.at(-1)?.at(-1)
-          let sortingNode: SortingNodeWithDependencies = {
+          let sortingNode: Omit<SortingNodeWithDependencies, 'partitionId'> = {
             group: computeGroup({
               customGroupMatcher: customGroup =>
                 doesCustomGroupMatch({
@@ -146,7 +146,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
             accumulator.push([])
           }
 
-          accumulator.at(-1)?.push(sortingNode)
+          accumulator.at(-1)?.push({
+            ...sortingNode,
+            partitionId: accumulator.length,
+          })
 
           return accumulator
         },
diff --git a/types/sorting-node.ts b/types/sorting-node.ts
index 72d53c5..6c25b67 100644
--- a/types/sorting-node.ts
+++ b/types/sorting-node.ts
@@ -1,10 +1,10 @@
 import type { TSESTree } from '@typescript-eslint/types'
 
 export interface SortingNode<Node extends TSESTree.Node = TSESTree.Node> {
-  hasMultipleImportDeclarations?: boolean
   addSafetySemicolonWhenInline?: boolean
   isEslintDisabled: boolean
-  group?: string
+  partitionId: number
+  group: string
   name: string
   size: number
   node: Node
diff --git a/utils/compare.ts b/utils/compare.ts
index 80def70..d6a2b2a 100644
--- a/utils/compare.ts
+++ b/utils/compare.ts
@@ -78,7 +78,7 @@ let computeCompareValue = <T extends SortingNode>({
       sortingFunction = getAlphabeticalSortingFunction(options, nodeValueGetter)
       break
     case 'line-length':
-      sortingFunction = getLineLengthSortingFunction(options, nodeValueGetter)
+      sortingFunction = getLineLengthSortingFunction()
       break
     case 'unsorted':
       return 0
@@ -172,27 +172,10 @@ let getCustomSortingFunction = <T extends SortingNode>(
 }
 
 let getLineLengthSortingFunction =
-  <T extends SortingNode>(
-    { maxLineLength }: { maxLineLength?: number },
-    nodeValueGetter: NodeValueGetterFunction<T>,
-  ): SortingFunction<T> =>
+  <T extends SortingNode>(): SortingFunction<T> =>
   (aNode: T, bNode: T) => {
     let aSize = aNode.size
     let bSize = bNode.size
-
-    if (maxLineLength) {
-      let isTooLong = (size: number, node: T): undefined | boolean =>
-        size > maxLineLength && node.hasMultipleImportDeclarations
-
-      if (isTooLong(aSize, aNode)) {
-        aSize = nodeValueGetter(aNode).length + 10
-      }
-
-      if (isTooLong(bSize, bNode)) {
-        bSize = nodeValueGetter(bNode).length + 10
-      }
-    }
-
     return aSize - bSize
   }
 
diff --git a/utils/get-lines-between.ts b/utils/get-lines-between.ts
index 6d80bfa..ed41836 100644
--- a/utils/get-lines-between.ts
+++ b/utils/get-lines-between.ts
@@ -4,8 +4,8 @@ import type { SortingNode } from '../types/sorting-node'
 
 export let getLinesBetween = (
   source: TSESLint.SourceCode,
-  left: SortingNode,
-  right: SortingNode,
+  left: Pick<SortingNode, 'node'>,
+  right: Pick<SortingNode, 'node'>,
 ): number => {
   let linesBetween = source.lines.slice(
     left.node.loc.end.line,
diff --git a/utils/get-newlines-between-errors.ts b/utils/get-newlines-between-errors.ts
index 0ed5ef7..f9e10c9 100644
--- a/utils/get-newlines-between-errors.ts
+++ b/utils/get-newlines-between-errors.ts
@@ -51,7 +51,10 @@ export let getNewlinesBetweenErrors = <
   right,
   left,
 }: GetNewlinesBetweenErrorsParameters<MessageIds, T>): MessageIds[] => {
-  if (leftGroupIndex > rightGroupIndex) {
+  if (
+    leftGroupIndex > rightGroupIndex ||
+    left.partitionId !== right.partitionId
+  ) {
     return []
   }
 
diff --git a/utils/make-newlines-between-fixes.ts b/utils/make-newlines-between-fixes.ts
index 8d6db1d..f89c9fc 100644
--- a/utils/make-newlines-between-fixes.ts
+++ b/utils/make-newlines-between-fixes.ts
@@ -43,6 +43,10 @@ export let makeNewlinesBetweenFixes = <T extends SortingNode>({
     let sortedSortingNode = sortedNodes.at(i)!
     let nextSortedSortingNode = sortedNodes.at(i + 1)!
 
+    if (sortedSortingNode.partitionId !== nextSortedSortingNode.partitionId) {
+      continue
+    }
+
     let nodeGroupIndex = getGroupIndex(options.groups, sortedSortingNode)
     let nextNodeGroupIndex = getGroupIndex(
       options.groups,
diff --git a/utils/should-partition.ts b/utils/should-partition.ts
index 26cc62b..ebe8913 100644
--- a/utils/should-partition.ts
+++ b/utils/should-partition.ts
@@ -13,10 +13,10 @@ interface ShouldPartitionParameters {
     partitionByComment?: PartitionByCommentOption
     partitionByNewLine?: boolean
   }
-  lastSortingNode: SortingNode | undefined
+  lastSortingNode: Pick<SortingNode, 'node'> | undefined
+  sortingNode: Pick<SortingNode, 'node'>
   tokenValueToIgnoreBefore?: string
   sourceCode: TSESLint.SourceCode
-  sortingNode: SortingNode
 }
 
 export let shouldPartition = ({


Test patch:
diff --git a/test/rules/sort-array-includes.test.ts b/test/rules/sort-array-includes.test.ts
index 0f66724..86a9ae1 100644
--- a/test/rules/sort-array-includes.test.ts
+++ b/test/rules/sort-array-includes.test.ts
@@ -2038,6 +2038,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedArrayIncludesOrder',
+                },
+              ],
+              output: dedent`
+                [
+                  'a',
+
+                  // Partition comment
+
+                  'b',
+                  'c',
+                ].includes(value)
+              `,
+              code: dedent`
+                [
+                  'a',
+
+                  // Partition comment
+
+                  'c',
+                  'b',
+                ].includes(value)
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
   })
 
diff --git a/test/rules/sort-classes.test.ts b/test/rules/sort-classes.test.ts
index c990c2f..7d1cb65 100644
--- a/test/rules/sort-classes.test.ts
+++ b/test/rules/sort-classes.test.ts
@@ -4841,6 +4841,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedClassesOrder',
+                },
+              ],
+              output: dedent`
+                class Class {
+                  a
+
+                  // Partition comment
+
+                  b
+                  c
+                }
+              `,
+              code: dedent`
+                class Class {
+                  a
+
+                  // Partition comment
+
+                  c
+                  b
+                }
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     describe(`${ruleName}(${type}): sorts inline elements correctly`, () => {
diff --git a/test/rules/sort-enums.test.ts b/test/rules/sort-enums.test.ts
index 074e838..35a2598 100644
--- a/test/rules/sort-enums.test.ts
+++ b/test/rules/sort-enums.test.ts
@@ -1803,6 +1803,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'A',
+                      groupName: 'A',
+                    },
+                  ],
+                  groups: ['A', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'B',
+                    left: 'C',
+                  },
+                  messageId: 'unexpectedEnumsOrder',
+                },
+              ],
+              output: dedent`
+                enum Enum {
+                  A = 'A',
+
+                  // Partition comment
+
+                  B = 'B',
+                  C = 'C',
+                }
+              `,
+              code: dedent`
+                enum Enum {
+                  A = 'A',
+
+                  // Partition comment
+
+                  C = 'C',
+                  B = 'B',
+                }
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
   })
 
diff --git a/test/rules/sort-exports.test.ts b/test/rules/sort-exports.test.ts
index e3f224f..cfe6f65 100644
--- a/test/rules/sort-exports.test.ts
+++ b/test/rules/sort-exports.test.ts
@@ -1682,6 +1682,57 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedExportsOrder',
+                },
+              ],
+              output: dedent`
+                export { a } from 'a'
+
+                // Partition comment
+
+                export { b } from 'b'
+                export { c } from 'c'
+              `,
+              code: dedent`
+                export { a } from 'a'
+
+                // Partition comment
+
+                export { c } from 'c'
+                export { b } from 'b'
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     describe(`${ruleName}(${type}): "commentAbove" inside groups`, () => {
diff --git a/test/rules/sort-imports.test.ts b/test/rules/sort-imports.test.ts
index d2cab1c..7a5f4b5 100644
--- a/test/rules/sort-imports.test.ts
+++ b/test/rules/sort-imports.test.ts
@@ -2115,6 +2115,57 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: './b',
+                    left: './c',
+                  },
+                  messageId: 'unexpectedImportsOrder',
+                },
+              ],
+              output: dedent`
+                import a from 'a';
+
+                // Partition comment
+
+                import { b } from './b';
+                import { c } from './c';
+              `,
+              code: dedent`
+                import a from 'a';
+
+                // Partition comment
+
+                import { c } from './c';
+                import { b } from './b';
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
@@ -3812,17 +3863,18 @@ describe(ruleName, () => {
                 // Part: 1
                 import a = aImport.a1.a2;
               `,
+              code: dedent`
+                import a = aImport.a1.a2;
+
+                // Part: 1
+                import aImport from "b";
+              `,
               options: [
                 {
                   ...options,
                   partitionByComment: '^Part',
                 },
               ],
-              code: dedent`
-                import a = aImport.a1.a2;
-                // Part: 1
-                import aImport from "b";
-              `,
             },
           ],
           valid: [],
diff --git a/test/rules/sort-interfaces.test.ts b/test/rules/sort-interfaces.test.ts
index c6c1d04..8bd759b 100644
--- a/test/rules/sort-interfaces.test.ts
+++ b/test/rules/sort-interfaces.test.ts
@@ -2907,6 +2907,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedInterfacePropertiesOrder',
+                },
+              ],
+              output: dedent`
+                interface Interface {
+                  a
+
+                  // Partition comment
+
+                  b
+                  c
+                }
+              `,
+              code: dedent`
+                interface Interface {
+                  a
+
+                  // Partition comment
+
+                  c
+                  b
+                }
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
diff --git a/test/rules/sort-intersection-types.test.ts b/test/rules/sort-intersection-types.test.ts
index fe72a9f..0ccf5cc 100644
--- a/test/rules/sort-intersection-types.test.ts
+++ b/test/rules/sort-intersection-types.test.ts
@@ -1449,6 +1449,59 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedIntersectionTypesOrder',
+                },
+              ],
+              output: dedent`
+                type Type =
+                  & a
+
+                  // Partition comment
+
+                  & b
+                  & c
+              `,
+              code: dedent`
+                type Type =
+                  & a
+
+                  // Partition comment
+
+                  & c
+                  & b
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
diff --git a/test/rules/sort-maps.test.ts b/test/rules/sort-maps.test.ts
index bfa1046..3523ba5 100644
--- a/test/rules/sort-maps.test.ts
+++ b/test/rules/sort-maps.test.ts
@@ -1632,6 +1632,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedMapElementsOrder',
+                },
+              ],
+              output: dedent`
+                new Map([
+                  [a, 'a'],
+
+                  // Partition comment
+
+                  [b, 'b'],
+                  [c, 'c'],
+                ])
+              `,
+              code: dedent`
+                new Map([
+                  [a, 'a'],
+
+                  // Partition comment
+
+                  [c, 'c'],
+                  [b, 'b'],
+                ])
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     describe(`${ruleName}(${type}): allows to use 'useConfigurationIf'`, () => {
diff --git a/test/rules/sort-modules.test.ts b/test/rules/sort-modules.test.ts
index 50b42ab..44f78c5 100644
--- a/test/rules/sort-modules.test.ts
+++ b/test/rules/sort-modules.test.ts
@@ -2551,6 +2551,57 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedModulesOrder',
+                },
+              ],
+              output: dedent`
+                function a() {}
+
+                // Partition comment
+
+                function b() {}
+                function c() {}
+              `,
+              code: dedent`
+                function a() {}
+
+                // Partition comment
+
+                function c() {}
+                function b() {}
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     describe(`${ruleName}(${type}): sorts inline elements correctly`, () => {
diff --git a/test/rules/sort-named-exports.test.ts b/test/rules/sort-named-exports.test.ts
index b137c07..ff28949 100644
--- a/test/rules/sort-named-exports.test.ts
+++ b/test/rules/sort-named-exports.test.ts
@@ -1733,6 +1733,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedNamedExportsOrder',
+                },
+              ],
+              output: dedent`
+                export {
+                  a,
+
+                  // Partition comment
+
+                  b,
+                  c,
+                } from 'module'
+              `,
+              code: dedent`
+                export {
+                  a,
+
+                  // Partition comment
+
+                  c,
+                  b,
+                } from 'module'
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
   })
 
diff --git a/test/rules/sort-named-imports.test.ts b/test/rules/sort-named-imports.test.ts
index 1c33d18..48b9692 100644
--- a/test/rules/sort-named-imports.test.ts
+++ b/test/rules/sort-named-imports.test.ts
@@ -1898,6 +1898,61 @@ describe(ruleName, () => {
         },
       )
     })
+
+    ruleTester.run(
+      `${ruleName}(${type}): ignores newline fixes between different partitions`,
+      rule,
+      {
+        invalid: [
+          {
+            options: [
+              {
+                ...options,
+                customGroups: [
+                  {
+                    elementNamePattern: 'a',
+                    groupName: 'a',
+                  },
+                ],
+                groups: ['a', 'unknown'],
+                newlinesBetween: 'never',
+                partitionByComment: true,
+              },
+            ],
+            errors: [
+              {
+                data: {
+                  right: 'b',
+                  left: 'c',
+                },
+                messageId: 'unexpectedNamedImportsOrder',
+              },
+            ],
+            output: dedent`
+              import {
+                a,
+
+                // Partition comment
+
+                b,
+                c,
+              } from 'module'
+            `,
+            code: dedent`
+              import {
+                a,
+
+                // Partition comment
+
+                c,
+                b,
+              } from 'module'
+            `,
+          },
+        ],
+        valid: [],
+      },
+    )
   })
 
   describe(`${ruleName}: sorting by natural order`, () => {
diff --git a/test/rules/sort-object-types.test.ts b/test/rules/sort-object-types.test.ts
index 8eab288..6506c5f 100644
--- a/test/rules/sort-object-types.test.ts
+++ b/test/rules/sort-object-types.test.ts
@@ -2702,6 +2702,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedObjectTypesOrder',
+                },
+              ],
+              output: dedent`
+                type Type = {
+                  a: string
+
+                  // Partition comment
+
+                  b: string
+                  c: string
+                }
+              `,
+              code: dedent`
+                type Type = {
+                  a: string
+
+                  // Partition comment
+
+                  c: string
+                  b: string
+                }
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
diff --git a/test/rules/sort-objects.test.ts b/test/rules/sort-objects.test.ts
index 770c305..2b17ca9 100644
--- a/test/rules/sort-objects.test.ts
+++ b/test/rules/sort-objects.test.ts
@@ -2556,6 +2556,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedObjectsOrder',
+                },
+              ],
+              output: dedent`
+                let obj = {
+                  a,
+
+                  // Partition comment
+
+                  b,
+                  c,
+                }
+              `,
+              code: dedent`
+                let obj = {
+                  a,
+
+                  // Partition comment
+
+                  c,
+                  b,
+                }
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
diff --git a/test/rules/sort-sets.test.ts b/test/rules/sort-sets.test.ts
index 27105b7..a0a4f92 100644
--- a/test/rules/sort-sets.test.ts
+++ b/test/rules/sort-sets.test.ts
@@ -1985,6 +1985,61 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedSetsOrder',
+                },
+              ],
+              output: dedent`
+                new Set([
+                  'a',
+
+                  // Partition comment
+
+                  'b',
+                  'c',
+                ])
+              `,
+              code: dedent`
+                new Set([
+                  'a',
+
+                  // Partition comment
+
+                  'c',
+                  'b',
+                ])
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
   })
 
diff --git a/test/rules/sort-union-types.test.ts b/test/rules/sort-union-types.test.ts
index f9a237d..9fa4a12 100644
--- a/test/rules/sort-union-types.test.ts
+++ b/test/rules/sort-union-types.test.ts
@@ -1452,6 +1452,59 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedUnionTypesOrder',
+                },
+              ],
+              output: dedent`
+                type Type =
+                  | a
+
+                  // Partition comment
+
+                  | b
+                  | c
+              `,
+              code: dedent`
+                type Type =
+                  | a
+
+                  // Partition comment
+
+                  | c
+                  | b
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
 
     ruleTester.run(
diff --git a/test/rules/sort-variable-declarations.test.ts b/test/rules/sort-variable-declarations.test.ts
index afd9c2e..d8b0517 100644
--- a/test/rules/sort-variable-declarations.test.ts
+++ b/test/rules/sort-variable-declarations.test.ts
@@ -2123,6 +2123,59 @@ describe(ruleName, () => {
           valid: [],
         },
       )
+
+      ruleTester.run(
+        `${ruleName}(${type}): ignores newline fixes between different partitions`,
+        rule,
+        {
+          invalid: [
+            {
+              options: [
+                {
+                  ...options,
+                  customGroups: [
+                    {
+                      elementNamePattern: 'a',
+                      groupName: 'a',
+                    },
+                  ],
+                  groups: ['a', 'unknown'],
+                  newlinesBetween: 'never',
+                  partitionByComment: true,
+                },
+              ],
+              errors: [
+                {
+                  data: {
+                    right: 'b',
+                    left: 'c',
+                  },
+                  messageId: 'unexpectedVariableDeclarationsOrder',
+                },
+              ],
+              output: dedent`
+                let
+                  a,
+
+                  // Partition comment
+
+                  b,
+                  c
+              `,
+              code: dedent`
+                let
+                  a,
+
+                  // Partition comment
+
+                  c,
+                  b
+              `,
+            },
+          ],
+          valid: [],
+        },
+      )
     })
   })