Skip to content

Commit ecf41eb

Browse files
committed
fix: lint issues
1 parent 16a6fbf commit ecf41eb

14 files changed

Lines changed: 31 additions & 22 deletions

File tree

app/components/Toasts/Toasts.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const toasts = useToasts();
44
const toasterComp = useTemplateRef('toasterComp');
55
66
const sortedToasts = computed(() =>
7-
toasts.value.slice().sort((a, b) => a.priority - b.priority),
7+
toasts.value.toSorted((a, b) => a.priority - b.priority),
88
);
99
1010
let toasterElClientRect: DOMRect | undefined;

app/components/With/ListTransitionGroup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function handleArrowsPress(event: KeyboardEvent) {
4545
return;
4646
}
4747

48-
const currentIdx = Array.from(listElement.children)
48+
const currentIdx = [...listElement.children]
4949
.findIndex((node) =>
5050
// event.target will be anchor tag, but it is wrapped in li, which is list element child
5151
node === (event.target as HTMLElement).parentElement,

app/components/Workspace/Contents/List/ContentsList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const folderContents = computed(() => {
7777
const notes = folder.value.notes || [];
7878
const subfolders = folder.value.subfolders || [];
7979
80-
return notes.concat(subfolders) as Array<FolderMinimal | NoteMinimal>;
80+
return [...notes, ...subfolders] as Array<FolderMinimal | NoteMinimal>;
8181
});
8282
8383
function showMenu(target: HTMLElement, item: FolderMinimal | NoteMinimal) {

app/components/Workspace/Shortcuts/Shortcuts.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const commandsDescriptions: Record<SearchActionValues, string> = {
3838
[SearchAction.RefreshNote]: 'Reload only not contents',
3939
[SearchAction.RefreshFolder]: 'Reload only folder contents',
4040
};
41-
const commandsShortcuts = Array.from(commandActionsMin.values())
42-
.map(({ key, name }) => ({ keys: name, desc: commandsDescriptions[key] }))
41+
const commandsShortcuts = Array
42+
.from(commandActionsMin.values(), ({ key, name }) => ({ keys: name, desc: commandsDescriptions[key] }))
4343
.sort(sortByKeysLength);
4444
4545
const replacementsDescriptions: Record<Replacement, string> = {

app/components/Workspace/Sidebar/Sidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function updateFocusableElements() {
2020
return;
2121
}
2222
23-
const elements = Array.from(sidebar.value.querySelectorAll<FocusableElement>('a,button,select'));
23+
const elements = [...sidebar.value.querySelectorAll<FocusableElement>('a,button,select')];
2424
2525
focusableElements.value = elements;
2626
}

app/composables/toaster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function addToQueue(message: ToastInstance['message'], options?: ToastUserOption
1616

1717
const addToastToQueue = () => {
1818
timeout.value = undefined;
19-
toasts.value = toasts.value.concat(toast);
19+
toasts.value = [...toasts.value, toast];
2020
};
2121

2222
if (options?.delay) {

app/composables/use-focus-trap.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export function useFocusTrap(
3838
function getFocusableEls(el: HTMLElement) {
3939
if (scheduled) {
4040
scheduled = false;
41-
cachedEls = Array.from(
42-
el.querySelectorAll(TABBABLE_ELs) as NodeListOf<HTMLElement>,
43-
).filter((el) => !isElementHidden(el));
41+
cachedEls = [...el.querySelectorAll(TABBABLE_ELs) as NodeListOf<HTMLElement>].filter((el) => !isElementHidden(el));
4442
}
4543

4644
return cachedEls;

app/utils/fuzzy-match.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if (import.meta.vitest) {
9898
];
9999

100100
const input = 'm';
101-
const shuffeledList = expectedList.slice().sort(() => Math.random() - Math.random());
101+
const shuffeledList = expectedList.toSorted(() => Math.random() - Math.random());
102102

103103
expect(
104104
shuffeledList.sort((a, b) => fuzzyMatch(input, b) - fuzzyMatch(input, a)),
@@ -115,7 +115,7 @@ if (import.meta.vitest) {
115115
];
116116

117117
const input = 'main';
118-
const shuffeledList = expectedList.slice().sort(() => Math.random() - Math.random());
118+
const shuffeledList = expectedList.toSorted(() => Math.random() - Math.random());
119119

120120
expect(
121121
shuffeledList.sort((a, b) => fuzzyMatch(input, b) - fuzzyMatch(input, a))[0],
@@ -131,7 +131,7 @@ if (import.meta.vitest) {
131131
'must watch',
132132
'future',
133133
'some testing note',
134-
].slice().sort(() => Math.random() - Math.random());
134+
].toSorted(() => Math.random() - Math.random());
135135

136136
expect(
137137
shuffeledList.sort((a, b) => fuzzyMatch(input, b) - fuzzyMatch(input, a))[0],
@@ -150,7 +150,7 @@ if (import.meta.vitest) {
150150
'new',
151151
'chore',
152152
'some testing note',
153-
].slice().sort(() => Math.random() - Math.random());
153+
].toSorted(() => Math.random() - Math.random());
154154

155155
const input = 'sh';
156156
expect(

app/utils/tiptap/extensions/link/helpers/autolink.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export function autolink(options: AutolinkOptions): Plugin {
8181
continue;
8282
}
8383

84-
const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
84+
const lastWordBeforeSpace = wordsBeforeWhitespace.at(-1);
85+
if (!lastWordBeforeSpace) {
86+
continue;
87+
}
88+
8589
const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
8690

8791
if (!lastWordBeforeSpace) {

modules/purge-dev-only-strings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import decomment from 'decomment';
33
import MagicString from 'magic-string';
44
import { isDevelopment } from 'std-env';
55

6+
const DATA_TEST_REGEXP = /data-testId=".*?"/g;
7+
68
// NOTE: taken from - https://github.com/elk-zone/elk/blob/main/modules/purge-comments.ts
79
export default defineNuxtModule({
810
meta: {
@@ -23,7 +25,7 @@ export default defineNuxtModule({
2325

2426
const s = new MagicString(code);
2527

26-
s.replaceAll(/data-testId=".*?"/g, '');
28+
s.replaceAll(DATA_TEST_REGEXP, '');
2729

2830
return {
2931
code: s.toString(),

0 commit comments

Comments
 (0)