Enable and fix custom eslint rules
This commit is contained in:
parent
ca929a37d1
commit
9f3789e032
8 changed files with 38 additions and 23 deletions
|
|
@ -34,4 +34,19 @@ export default tseslint.config(
|
||||||
|
|
||||||
// Tell the vue parser that it should use the ts parser instead of the js parser.
|
// Tell the vue parser that it should use the ts parser instead of the js parser.
|
||||||
{ files: ["**/*.vue"], languageOptions: { parserOptions: { parser: tseslint.parser } } },
|
{ files: ["**/*.vue"], languageOptions: { parserOptions: { parser: tseslint.parser } } },
|
||||||
|
|
||||||
|
// My own rules.
|
||||||
|
//
|
||||||
|
// https://eslint.org/docs/latest/rules/
|
||||||
|
// https://typescript-eslint.io/rules/
|
||||||
|
// https://eslint.vuejs.org/rules/
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "error",
|
||||||
|
"vue/block-lang": ["error", { script: { lang: "ts" } }],
|
||||||
|
"vue/block-order": ["error", { order: ["script", "template", "style"] }],
|
||||||
|
"vue/component-api-style": ["error", ["script-setup"]],
|
||||||
|
"vue/v-for-delimiter-style": ["error", "of"],
|
||||||
|
},
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ function mkNote(text: string, ...children: string[]): Note {
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSomeNotes() {
|
function createSomeNotes(): void {
|
||||||
notes.clearNotes();
|
notes.clearNotes();
|
||||||
|
|
||||||
const n2n1 = mkNote("n2n1");
|
const n2n1 = mkNote("n2n1");
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ const { floatingStyles } = useFloating(reference, floating, {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
function onAddNewRepo() {
|
function onAddNewRepo(): void {
|
||||||
const id = crypto.randomUUID();
|
const id = crypto.randomUUID();
|
||||||
repos.addRepo({ id, name: id });
|
repos.addRepo({ id, name: id });
|
||||||
console.log(repos.selectedRepo);
|
console.log(repos.selectedRepo);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectRepo(id: string) {
|
function onSelectRepo(id: string): void {
|
||||||
repos.selectRepo(id);
|
repos.selectRepo(id);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,11 @@ watchEffect(() => {
|
||||||
if (mode.value) focusOnThis();
|
if (mode.value) focusOnThis();
|
||||||
});
|
});
|
||||||
|
|
||||||
function focusOnThis() {
|
function focusOnThis(): void {
|
||||||
ui.focusPath = props.path;
|
ui.focusPath = props.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick() {
|
function onClick(): void {
|
||||||
if (!focused.value) {
|
if (!focused.value) {
|
||||||
focusOnThis();
|
focusOnThis();
|
||||||
return;
|
return;
|
||||||
|
|
@ -89,36 +89,36 @@ function onClick() {
|
||||||
ui.toggleOpen(props.path);
|
ui.toggleOpen(props.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPinButtonClick() {
|
function onPinButtonClick(): void {
|
||||||
if (pinned.value) ui.unsetPinned();
|
if (pinned.value) ui.unsetPinned();
|
||||||
else ui.setPinned(props.segment, props.parentId);
|
else ui.setPinned(props.segment, props.parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEditButtonClick() {
|
function onEditButtonClick(): void {
|
||||||
if (!note.value) return;
|
if (!note.value) return;
|
||||||
mode.value = "editing";
|
mode.value = "editing";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEditEditorClose() {
|
function onEditEditorClose(): void {
|
||||||
mode.value = undefined;
|
mode.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEditEditorFinish(text: string) {
|
function onEditEditorFinish(text: string): void {
|
||||||
if (!note.value) return;
|
if (!note.value) return;
|
||||||
note.value.text = text;
|
note.value.text = text;
|
||||||
onEditEditorClose();
|
onEditEditorClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreateButtonClick() {
|
function onCreateButtonClick(): void {
|
||||||
if (!note.value) return;
|
if (!note.value) return;
|
||||||
mode.value = "creating";
|
mode.value = "creating";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreateEditorClose() {
|
function onCreateEditorClose(): void {
|
||||||
mode.value = undefined;
|
mode.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreateEditorFinish(text: string) {
|
function onCreateEditorFinish(text: string): void {
|
||||||
if (!note.value) return;
|
if (!note.value) return;
|
||||||
|
|
||||||
const newNote = notes.createNote(text);
|
const newNote = notes.createNote(text);
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,17 @@ onMounted(() => {
|
||||||
updateTextareaHeight();
|
updateTextareaHeight();
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateTextareaHeight() {
|
function updateTextareaHeight(): void {
|
||||||
if (!textarea.value) return;
|
if (!textarea.value) return;
|
||||||
textarea.value.style.height = "0px";
|
textarea.value.style.height = "0px";
|
||||||
textarea.value.style.height = `${textarea.value.scrollHeight.toFixed()}px`;
|
textarea.value.style.height = `${textarea.value.scrollHeight.toFixed()}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInput() {
|
function onInput(): void {
|
||||||
updateTextareaHeight();
|
updateTextareaHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyPress(ev: KeyboardEvent) {
|
function onKeyPress(ev: KeyboardEvent): void {
|
||||||
if (ev.key === "Escape") {
|
if (ev.key === "Escape") {
|
||||||
emit("close");
|
emit("close");
|
||||||
} else if (ev.key === "Enter" && !ev.shiftKey) {
|
} else if (ev.key === "Enter" && !ev.shiftKey) {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export const useNotesStore = defineStore("notes", () => {
|
||||||
return notes.value.get(id)!; // Re-getting so returned Note is reactive
|
return notes.value.get(id)!; // Re-getting so returned Note is reactive
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearNotes() {
|
function clearNotes(): void {
|
||||||
notes.value.clear();
|
notes.value.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ export const useReposStore = defineStore("repos", () => {
|
||||||
|
|
||||||
const repoIdsByName = computed<string[]>(() => reposByName.value.map((it) => it.id));
|
const repoIdsByName = computed<string[]>(() => reposByName.value.map((it) => it.id));
|
||||||
|
|
||||||
function addRepo(repo: Repo) {
|
function addRepo(repo: Repo): void {
|
||||||
repos.value.set(repo.id, repo);
|
repos.value.set(repo.id, repo);
|
||||||
selectedRepoId.value = repo.id;
|
selectedRepoId.value = repo.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeRepo(id: string | undefined) {
|
function removeRepo(id: string | undefined): void {
|
||||||
if (id === undefined) return;
|
if (id === undefined) return;
|
||||||
const i = repoIdsByName.value.indexOf(id);
|
const i = repoIdsByName.value.indexOf(id);
|
||||||
repos.value.delete(id);
|
repos.value.delete(id);
|
||||||
|
|
@ -38,7 +38,7 @@ export const useReposStore = defineStore("repos", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectRepo(id: string | undefined) {
|
function selectRepo(id: string | undefined): void {
|
||||||
if (id === undefined) return;
|
if (id === undefined) return;
|
||||||
if (repos.value.get(id) === undefined) return;
|
if (repos.value.get(id) === undefined) return;
|
||||||
selectedRepoId.value = id;
|
selectedRepoId.value = id;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export const useUiStore = defineStore("ui", () => {
|
||||||
return openPaths.value.has(path.fmt());
|
return openPaths.value.has(path.fmt());
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOpen(path: UiPath, value: boolean) {
|
function setOpen(path: UiPath, value: boolean): void {
|
||||||
// Don't update openPaths unnecessarily.
|
// Don't update openPaths unnecessarily.
|
||||||
// Just in case vue itself doesn't debounce Set operations.
|
// Just in case vue itself doesn't debounce Set operations.
|
||||||
if (value && !isOpen(path)) {
|
if (value && !isOpen(path)) {
|
||||||
|
|
@ -33,7 +33,7 @@ export const useUiStore = defineStore("ui", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleOpen(path: UiPath) {
|
function toggleOpen(path: UiPath): void {
|
||||||
setOpen(path, !isOpen(path));
|
setOpen(path, !isOpen(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,11 +42,11 @@ export const useUiStore = defineStore("ui", () => {
|
||||||
return pinned.value.segment.eq(segment) && pinned.value.parentId === parentId;
|
return pinned.value.segment.eq(segment) && pinned.value.parentId === parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPinned(segment: Segment, parentId?: string) {
|
function setPinned(segment: Segment, parentId?: string): void {
|
||||||
pinned.value = { segment, parentId };
|
pinned.value = { segment, parentId };
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsetPinned() {
|
function unsetPinned(): void {
|
||||||
pinned.value = undefined;
|
pinned.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue