Skip to content

Commit

Permalink
Switch to prettier trailingComma: "all" (#1084)
Browse files Browse the repository at this point in the history
* Switch to prettier `trailingComma: "all"`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pokey and pre-commit-ci[bot] authored Oct 24, 2022
1 parent 2a0f9d1 commit 619d7f7
Show file tree
Hide file tree
Showing 203 changed files with 1,014 additions and 1,009 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "all"
}
26 changes: 13 additions & 13 deletions src/actions/BringMoveSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class BringMoveSwap implements Action {
this.graph.editStyles.displayPendingEditDecorations(
sources,
decorationContext.sourceStyle,
decorationContext.getSourceRangeCallback
decorationContext.getSourceRangeCallback,
),
this.graph.editStyles.displayPendingEditDecorations(
destinations,
decorationContext.destinationStyle
decorationContext.destinationStyle,
),
]);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class BringMoveSwap implements Action {
}

private async performEditsAndComputeThatMark(
edits: ExtendedEdit[]
edits: ExtendedEdit[],
): Promise<MarkEntry[]> {
return flatten(
await runForEachEditor(
Expand All @@ -168,24 +168,24 @@ class BringMoveSwap implements Action {
getSelectionInfo(
editor.document,
selectionFromRange(originalTarget.isReversed, range),
DecorationRangeBehavior.OpenOpen
)
DecorationRangeBehavior.OpenOpen,
),
);

const cursorSelectionInfos = editor.selections.map((selection) =>
getSelectionInfo(
editor.document,
selection,
DecorationRangeBehavior.ClosedClosed
)
DecorationRangeBehavior.ClosedClosed,
),
);

const [updatedEditSelections, cursorSelections]: Selection[][] =
await performEditsAndUpdateFullSelectionInfos(
this.graph.rangeUpdater,
editor,
filteredEdits.map(({ edit }) => edit),
[editSelectionInfos, cursorSelectionInfos]
[editSelectionInfos, cursorSelectionInfos],
);

// NB: We set the selections here because we don't trust vscode to
Expand All @@ -204,8 +204,8 @@ class BringMoveSwap implements Action {
target,
};
});
}
)
},
),
);
}

Expand All @@ -217,14 +217,14 @@ class BringMoveSwap implements Action {
this.graph.editStyles.displayPendingEditDecorations(
thatMark.filter(({ isSource }) => isSource).map(({ target }) => target),
decorationContext.sourceStyle,
getRange
getRange,
),
this.graph.editStyles.displayPendingEditDecorations(
thatMark
.filter(({ isSource }) => !isSource)
.map(({ target }) => target),
decorationContext.destinationStyle,
getRange
getRange,
),
]);
}
Expand All @@ -247,7 +247,7 @@ class BringMoveSwap implements Action {

async run([sources, destinations]: [
Target[],
Target[]
Target[],
]): Promise<ActionReturnValue> {
sources = this.broadcastSource(sources, destinations);

Expand Down
6 changes: 3 additions & 3 deletions src/actions/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ export default class Call implements Action {

async run([sources, destinations]: [
Target[],
Target[]
Target[],
]): Promise<ActionReturnValue> {
ensureSingleTarget(sources);

const { returnValue: texts } = await this.graph.actions.getText.run(
[sources],
{
showDecorations: false,
}
},
);

// NB: We unwrap and then rewrap the return value here so that we don't include the source mark
const { thatSelections: thatMark } =
await this.graph.actions.wrapWithPairedDelimiter.run(
[destinations],
texts[0] + "(",
")"
")",
);

return { thatSelections: thatMark };
Expand Down
4 changes: 2 additions & 2 deletions src/actions/Clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Clear implements Action {
editor: target.editor,
isReversed: target.isReversed,
contentRange: target.contentRange,
})
}),
);

const { thatSelections: thatMark } = await this.graph.actions.remove.run([
Expand All @@ -30,7 +30,7 @@ export default class Clear implements Action {
if (thatMark != null) {
await setSelectionsAndFocusEditor(
editor,
thatMark.map(({ selection }) => selection)
thatMark.map(({ selection }) => selection),
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/actions/CommandAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export default class CommandAction implements Action {

private async runCommandAndUpdateSelections(
targets: Target[],
options: Required<CommandOptions>
options: Required<CommandOptions>,
): Promise<Target[]> {
return flatten(
await runOnTargetsForEachEditor(targets, async (editor, targets) => {
const originalSelections = editor.selections;
const originalEditorVersion = editor.document.version;

const targetSelections = targets.map(
(target) => target.contentSelection
(target) => target.contentSelection,
);

// For command to the work we have to have the correct editor focused
Expand All @@ -60,7 +60,7 @@ export default class CommandAction implements Action {
() =>
commands.executeCommand(options.command, ...options.commandArgs),
editor.document,
[originalSelections, targetSelections]
[originalSelections, targetSelections],
);

// Reset original selections
Expand All @@ -81,21 +81,21 @@ export default class CommandAction implements Action {
selectionToThatTarget({
editor,
selection,
})
}),
);
})
}),
);
}

async run(
[targets]: [Target[]],
options: CommandOptions = {}
options: CommandOptions = {},
): Promise<ActionReturnValue> {
const partialOptions = Object.assign(
{},
defaultOptions,
this.options,
options
options,
);

if (partialOptions.command == null) {
Expand All @@ -107,7 +107,7 @@ export default class CommandAction implements Action {
if (actualOptions.showDecorations) {
await this.graph.editStyles.displayPendingEditDecorations(
targets,
this.graph.editStyles.referenced
this.graph.editStyles.referenced,
);
}

Expand All @@ -123,7 +123,7 @@ export default class CommandAction implements Action {

const thatTargets = await this.runCommandAndUpdateSelections(
targets,
actualOptions
actualOptions,
);

// If necessary focus back original editor
Expand Down
8 changes: 4 additions & 4 deletions src/actions/CutCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ export class Cut implements Action {
editor: target.editor,
contentRange: overflow,
isReversed: target.isReversed,
})
}),
);
});

await Promise.all([
this.graph.editStyles.displayPendingEditDecorations(
targets,
this.graph.editStyles.referenced
this.graph.editStyles.referenced,
),
this.graph.editStyles.displayPendingEditDecorations(
overflowTargets,
this.graph.editStyles.pendingDelete
this.graph.editStyles.pendingDelete,
),
]);

Expand All @@ -44,7 +44,7 @@ export class Cut implements Action {

const { thatSelections: thatMark } = await this.graph.actions.remove.run(
[targets],
options
options,
);

return { thatSelections: thatMark };
Expand Down
4 changes: 2 additions & 2 deletions src/actions/Deselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export default class Deselect implements Action {
!targets.some((target) => {
const intersection = target.contentRange.intersection(selection);
return intersection && (!intersection.isEmpty || selection.isEmpty);
})
}),
);
// The editor requires at least one selection. Keep "primary" selection active
setSelectionsWithoutFocusingEditor(
editor,
newSelections.length > 0
? newSelections
: [new Selection(editor.selection.active, editor.selection.active)]
: [new Selection(editor.selection.active, editor.selection.active)],
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/actions/EditNew/EditNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class EditNew implements Action {
state = await runEditTargets(this.graph, editor, state);

const newSelections = state.targets.map((target, index) =>
selectionFromRange(target.isReversed, state.cursorRanges[index]!)
selectionFromRange(target.isReversed, state.cursorRanges[index]!),
);
await setSelectionsAndFocusEditor(editor, newSelections);

Expand Down
6 changes: 3 additions & 3 deletions src/actions/EditNew/runCommandTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CommandTarget, State } from "./EditNew.types";
export async function runCommandTargets(
graph: Graph,
editor: TextEditor,
state: State
state: State,
): Promise<State> {
const commandTargets: CommandTarget[] = state.targets
.map((target, index) => {
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function runCommandTargets(
graph.rangeUpdater,
() => commands.executeCommand(command),
editor.document,
[state.targets.map(({ contentRange }) => contentRange), state.thatRanges]
[state.targets.map(({ contentRange }) => contentRange), state.thatRanges],
);

// For each of the given command targets, the cursor will go where it ended
Expand All @@ -60,7 +60,7 @@ export async function runCommandTargets(

return {
targets: state.targets.map((target, index) =>
target.withContentRange(updatedTargetRanges[index])
target.withContentRange(updatedTargetRanges[index]),
),
thatRanges: updatedThatRanges,
cursorRanges,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/EditNew/runEditTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { EditTarget, State } from "./EditNew.types";
export async function runEditTargets(
graph: Graph,
editor: TextEditor,
state: State
state: State,
): Promise<State> {
const editTargets: EditTarget[] = state.targets
.map((target, index) => {
Expand All @@ -39,7 +39,7 @@ export async function runEditTargets(
}

const edits = editTargets.map((target) =>
target.target.constructChangeEdit("")
target.target.constructChangeEdit(""),
);

const thatSelections = {
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function runEditTargets(
graph.rangeUpdater,
editor,
edits,
[thatSelections, cursorSelections, editSelections]
[thatSelections, cursorSelections, editSelections],
);

const updatedCursorRanges = [...state.cursorRanges];
Expand Down
4 changes: 2 additions & 2 deletions src/actions/EditNew/runNotebookCellTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ActionReturnValue } from "../actions.types";

export async function runNotebookCellTargets(
graph: Graph,
targets: Target[]
targets: Target[],
): Promise<ActionReturnValue> {
// Can only run on one target because otherwise we'd end up with cursors in
// multiple cells, which is unsupported in VSCode
Expand All @@ -21,7 +21,7 @@ export async function runNotebookCellTargets(
if (command === "jupyter.insertCellAbove") {
thatMark[0].selection = new Selection(
thatMark[0].selection.anchor.translate({ lineDelta: 2 }),
thatMark[0].selection.active.translate({ lineDelta: 2 })
thatMark[0].selection.active.translate({ lineDelta: 2 }),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/ExecuteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class ExecuteCommand implements Action {
async run(
targets: [Target[]],
command: string,
args: CommandOptions = {}
args: CommandOptions = {},
): Promise<ActionReturnValue> {
return this.commandAction.run(targets, { ...args, command });
}
Expand Down
6 changes: 3 additions & 3 deletions src/actions/Fold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class FoldAction implements Action {
}

const singleLineTargets = targets.filter(
(target) => target.contentRange.isSingleLine
(target) => target.contentRange.isSingleLine,
);
const multiLineTargets = targets.filter(
(target) => !target.contentRange.isSingleLine
(target) => !target.contentRange.isSingleLine,
);
// Don't mix multi and single line targets.
// This is probably the result of an "every" command
Expand All @@ -35,7 +35,7 @@ class FoldAction implements Action {
levels: 1,
direction: "down",
selectionLines: selectedTargets.map(
(target) => target.contentRange.start.line
(target) => target.contentRange.start.line,
),
});

Expand Down
4 changes: 2 additions & 2 deletions src/actions/FollowLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class FollowLink implements Action {

await this.graph.editStyles.displayPendingEditDecorations(
targets,
this.graph.editStyles.referenced
this.graph.editStyles.referenced,
);

const link = await getLinkForTarget(target);
Expand All @@ -25,7 +25,7 @@ export default class FollowLink implements Action {
await this.graph.actions.executeCommand.run(
[targets],
"editor.action.revealDefinition",
{ restoreSelection: false }
{ restoreSelection: false },
);
}

Expand Down
Loading

0 comments on commit 619d7f7

Please sign in to comment.