Skip to content

Commit

Permalink
Fix eslint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-lednev committed Mar 14, 2023
1 parent e5ef871 commit b3ac535
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
38 changes: 21 additions & 17 deletions src/features/ArchiveFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,31 +174,35 @@ export class ArchiveFeature {

private async archiveTasks(tasks: BlockWithRule[], activeFile: ActiveFile) {
await flow(
map(({ rule, task }) => ({
rule,
task: this.textReplacementService.replaceText(task),
})),
map((taskWithRule) => this.metadataService.appendMetadata(taskWithRule)),
map(({ rule, task }: BlockWithRule) => ({
task,
archivePath: rule.archiveToSeparateFile
? this.placeholderService.resolve(
rule.defaultArchiveFileName,
rule.dateFormat
)
: "current-file",
})),
map(
flow(
({ rule, task }) => ({
rule,
task: this.textReplacementService.replaceText(task),
}),
(taskWithRule) => this.metadataService.appendMetadata(taskWithRule),
({ rule, task }: BlockWithRule) => ({
task,
archivePath: rule.archiveToSeparateFile
? this.placeholderService.resolve(
rule.defaultArchiveFileName,
rule.dateFormat
)
: "current-file",
})
)
),
groupBy((task) => task.archivePath),
mapValues((tasks) => tasks.map(({ task }) => task)),
mapValues((tasksWithPaths) => tasksWithPaths.map(({ task }) => task)),
toPairs,
map(async ([archivePath, tasks]) => {
map(async ([archivePath, tasksForPath]) => {
const archiveFile =
archivePath === "current-file"
? activeFile
: await this.getDiskFile(archivePath); // todo: this may be an issue if the rule says to archive a task to this exact file

await this.editFileTree(archiveFile, (tree: Section) =>
this.archiveBlocksToRoot(tasks, tree)
this.archiveBlocksToRoot(tasksForPath, tree)
);
}),
(promises) => Promise.all(promises)
Expand Down
7 changes: 4 additions & 3 deletions src/util/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ export function normalizeNewlinesRecursively(root: Section) {
}
}

export function stripSurroundingNewlines(blocks: Block[]) {
return flow(dropWhile(isEmptyBlock), dropRightWhile(isEmptyBlock))(blocks);
}
export const stripSurroundingNewlines = flow(
dropWhile(isEmptyBlock),
dropRightWhile(isEmptyBlock)
);

function isEmptyBlock(block: Block) {
return block.text.trim().length === 0;
Expand Down

0 comments on commit b3ac535

Please sign in to comment.