Skip to content

Commit

Permalink
fix: split comment after and newlines fixes in two cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Jan 10, 2025
1 parent 9c0864b commit de37084
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
30 changes: 15 additions & 15 deletions utils/make-order-and-comments-after-fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ export let makeOrderAndCommentsAfterFixes = ({
fixer,
nodes,
}: MakeOrderAndCommentsAfterFixesParameters): TSESLint.RuleFix[] => [
...makeOrderFixes({
ignoreFirstNodeHighestBlockComment,
sortedNodes,
sourceCode,
options,
fixer,
nodes,
}),
...makeCommentAfterFixes({
sortedNodes,
sourceCode,
nodes,
fixer,
}),
]
...makeOrderFixes({
ignoreFirstNodeHighestBlockComment,
sortedNodes,
sourceCode,
options,
fixer,
nodes,
}),
...makeCommentAfterFixes({
sortedNodes,
sourceCode,
nodes,
fixer,
}),
]
25 changes: 18 additions & 7 deletions utils/make-order-comments-after-and-newlines-fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import type { TSESLint } from '@typescript-eslint/utils'

import type { SortingNode } from '../types/sorting-node'

import { makeOrderAndCommentsAfterFixes } from './make-order-and-comments-after-fixes'
import { makeCommentAfterFixes } from './make-comment-after-fixes'
import { makeNewlinesFixes } from './make-newlines-fixes'
import { makeOrderFixes } from './make-order-fixes'

interface MakeOrderCommentsAfterAndNewlinesFixesParameters {
options: {
Expand Down Expand Up @@ -42,20 +43,30 @@ export let makeOrderCommentsAfterAndNewlinesFixes = ({
options,
fixer,
nodes,
}: MakeOrderCommentsAfterAndNewlinesFixesParameters): TSESLint.RuleFix[] => [
...makeOrderAndCommentsAfterFixes({
}: MakeOrderCommentsAfterAndNewlinesFixesParameters): TSESLint.RuleFix[] => {
let orderFixes = makeOrderFixes({
ignoreFirstNodeHighestBlockComment,
sortedNodes,
sourceCode,
options,
nodes,
fixer,
})
let commentAfterFixes = makeCommentAfterFixes({
sortedNodes,
sourceCode,
nodes,
}),
...makeNewlinesFixes({
fixer,
})
if (commentAfterFixes.length) {
return [...orderFixes, ...commentAfterFixes]
}
let newlinesFixes = makeNewlinesFixes({
sortedNodes,
sourceCode,
options,
fixer,
nodes,
}),
]
})
return [...orderFixes, ...newlinesFixes]
}

0 comments on commit de37084

Please sign in to comment.