Switch to vercel's biome setup (#543)

This commit is contained in:
Jared Palmer 2024-11-15 13:00:15 -05:00 committed by GitHub
parent b8643353c0
commit 43aa1c6e58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 414 additions and 201 deletions

View file

@ -17,7 +17,7 @@ export function headingRule(level: number) {
return textblockTypeInputRule(
new RegExp(`^(#{1,${level}})\\s$`),
documentSchema.nodes.heading,
() => ({ level })
() => ({ level }),
);
}

View file

@ -49,7 +49,7 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
const matchedNodes = matchNodes(
schema,
diffOldChildren,
diffNewChildren
diffNewChildren,
).sort((a, b) => b.count - a.count);
const bestMatch = matchedNodes[0];
if (bestMatch) {
@ -62,11 +62,11 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
...patchRemainNodes(
schema,
oldBeforeMatchChildren,
newBeforeMatchChildren
)
newBeforeMatchChildren,
),
);
finalLeftChildren.push(
...diffOldChildren.slice(oldStartIndex, oldEndIndex)
...diffOldChildren.slice(oldStartIndex, oldEndIndex),
);
const oldAfterMatchChildren = diffOldChildren.slice(oldEndIndex);
@ -76,17 +76,17 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
...patchRemainNodes(
schema,
oldAfterMatchChildren,
newAfterMatchChildren
)
newAfterMatchChildren,
),
);
} else {
finalLeftChildren.push(
...patchRemainNodes(schema, diffOldChildren, diffNewChildren)
...patchRemainNodes(schema, diffOldChildren, diffNewChildren),
);
}
} else {
finalLeftChildren.push(
...patchRemainNodes(schema, diffOldChildren, diffNewChildren)
...patchRemainNodes(schema, diffOldChildren, diffNewChildren),
);
}
@ -155,7 +155,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
!isTextNode(rightOldNode) && matchNodeType(rightOldNode, rightNewNode);
if (Array.isArray(leftOldNode) && Array.isArray(leftNewNode)) {
finalLeftChildren.push(
...patchTextNodes(schema, leftOldNode, leftNewNode)
...patchTextNodes(schema, leftOldNode, leftNewNode),
);
left += 1;
continue;
@ -165,7 +165,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
const equalityLeft = computeChildEqualityFactor(leftOldNode, leftNewNode);
const equalityRight = computeChildEqualityFactor(
rightOldNode,
rightNewNode
rightNewNode,
);
if (equalityLeft < equalityRight) {
updateLeft = false;
@ -175,21 +175,21 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
}
if (updateLeft) {
finalLeftChildren.push(
patchDocumentNode(schema, leftOldNode, leftNewNode)
patchDocumentNode(schema, leftOldNode, leftNewNode),
);
left += 1;
} else if (updateRight) {
finalRightChildren.unshift(
patchDocumentNode(schema, rightOldNode, rightNewNode)
patchDocumentNode(schema, rightOldNode, rightNewNode),
);
right += 1;
} else {
// Delete and insert
finalLeftChildren.push(
createDiffNode(schema, leftOldNode, DiffType.Deleted)
createDiffNode(schema, leftOldNode, DiffType.Deleted),
);
finalLeftChildren.push(
createDiffNode(schema, leftNewNode, DiffType.Inserted)
createDiffNode(schema, leftNewNode, DiffType.Inserted),
);
left += 1;
}
@ -202,7 +202,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
...oldChildren
.slice(left, left + deleteNodeLen)
.flat()
.map((node) => createDiffNode(schema, node, DiffType.Deleted))
.map((node) => createDiffNode(schema, node, DiffType.Deleted)),
);
}
@ -211,7 +211,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
...newChildren
.slice(left, left + insertNodeLen)
.flat()
.map((node) => createDiffNode(schema, node, DiffType.Inserted))
.map((node) => createDiffNode(schema, node, DiffType.Inserted)),
);
}
@ -233,7 +233,7 @@ export const patchTextNodes = (schema, oldNode, newNode) => {
// Map sentences to unique characters
const { chars1, chars2, lineArray } = sentencesToChars(
oldSentences,
newSentences
newSentences,
);
// Perform the diff
@ -253,7 +253,7 @@ export const patchTextNodes = (schema, oldNode, newNode) => {
const node = createTextNode(
schema,
sentence,
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : []
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : [],
);
return node;
});
@ -427,7 +427,7 @@ export const createNewNode = (oldNode, children) => {
oldNode.type,
oldNode.attrs,
Fragment.fromArray(children),
oldNode.marks
oldNode.marks,
);
};
@ -448,8 +448,8 @@ function mapDocumentNode(node, mapper) {
Fragment.from(
node.content.content
.map((node) => mapDocumentNode(node, mapper))
.filter((n) => n)
)
.filter((n) => n),
),
);
return mapper(copy) || copy;
}

View file

@ -24,7 +24,7 @@ export const buildContentFromDocument = (document: Node) => {
export const createDecorations = (
suggestions: Array<UISuggestion>,
view: EditorView
view: EditorView,
) => {
const decorations: Array<Decoration> = [];
@ -39,8 +39,8 @@ export const createDecorations = (
{
suggestionId: suggestion.id,
type: 'highlight',
}
)
},
),
);
decorations.push(
@ -53,8 +53,8 @@ export const createDecorations = (
{
suggestionId: suggestion.id,
type: 'widget',
}
)
},
),
);
}

View file

@ -45,7 +45,7 @@ function findPositionsInDoc(doc: Node, searchText: string): Position | null {
export function projectWithPositions(
doc: Node,
suggestions: Array<Suggestion>
suggestions: Array<Suggestion>,
): Array<UISuggestion> {
return suggestions.map((suggestion) => {
const positions = findPositionsInDoc(doc, suggestion.originalText);
@ -68,7 +68,7 @@ export function projectWithPositions(
export function createSuggestionWidget(
suggestion: UISuggestion,
view: EditorView
view: EditorView,
): { dom: HTMLElement; destroy: () => void } {
const dom = document.createElement('span');
const root = createRoot(dom);
@ -90,7 +90,7 @@ export function createSuggestionWidget(
state.doc,
currentDecorations.find().filter((decoration: Decoration) => {
return decoration.spec.suggestionId !== suggestion.id;
})
}),
);
decorationTransaction.setMeta(suggestionsPluginKey, {
@ -103,7 +103,7 @@ export function createSuggestionWidget(
const textTransaction = view.state.tr.replaceWith(
suggestion.selectionStart,
suggestion.selectionEnd,
state.schema.text(suggestion.suggestedText)
state.schema.text(suggestion.suggestedText),
);
textTransaction.setMeta('no-debounce', true);