fix: lint errors

This commit is contained in:
Baptiste Grob
2021-01-22 11:52:24 +01:00
parent 5d65364885
commit a0909399f8
25 changed files with 74 additions and 75 deletions

View File

@@ -30,7 +30,7 @@ export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
this.state = {
...this.getInitialState(),
...this.state,
}
};
this.addAppEventObserver();
this.addAppStateObserver();
this.templateReady = true;
@@ -83,7 +83,8 @@ export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
}
/** @override */
afterStateChange() {
// eslint-disable-next-line @typescript-eslint/no-empty-function
afterStateChange(): void {
}
/** @returns a promise that resolves after the UI has been updated. */

View File

@@ -7,7 +7,7 @@ import {
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { WebDirective } from '@/types';
class AccountSwitcherCtrl extends PureViewCtrl<{}, {
class AccountSwitcherCtrl extends PureViewCtrl<unknown, {
descriptors: ApplicationDescriptor[];
editingDescriptor?: ApplicationDescriptor
}> {
@@ -38,7 +38,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
reloadApplications() {
this.setState({
descriptors: this.mainApplicationGroup.getDescriptors()
})
});
}
/** @template */
@@ -63,7 +63,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
this.setState({ editingDescriptor: descriptor }).then(() => {
const input = this.inputForDescriptor(descriptor);
input?.focus();
})
});
}
/** @template */
@@ -71,7 +71,7 @@ class AccountSwitcherCtrl extends PureViewCtrl<{}, {
this.mainApplicationGroup.renameDescriptor(
this.state.editingDescriptor!,
this.state.editingDescriptor!.label
)
);
this.setState({ editingDescriptor: undefined });
}

View File

@@ -94,7 +94,7 @@ class ApplicationViewCtrl extends PureViewCtrl<unknown, {
onUpdateAvailable() {
this.$rootScope!.$broadcast(RootScopeMessages.NewUpdateAvailable);
};
}
/** @override */
async onAppEvent(eventName: ApplicationEvent) {

View File

@@ -142,7 +142,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
this.onPanelResizeFinish = this.onPanelResizeFinish.bind(this);
this.onEditorLoad = () => {
this.application!.getDesktopService().redoSearch();
}
};
}
deinit() {
@@ -199,7 +199,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
if (note.lastSyncBegan) {
if (note.lastSyncEnd) {
if (note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime()) {
this.showSavingStatus()
this.showSavingStatus();
} else if (note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime()) {
this.showAllChangesSavedStatus();
}
@@ -412,7 +412,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
await this.application.changeItem(this.note.uuid, (mutator) => {
const noteMutator = mutator as NoteMutator;
noteMutator.prefersPlainEditor = false;
})
});
}
await this.associateComponentWithCurrentNote(component);
}
@@ -471,7 +471,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => {
mutator.addItemAsRelationship(note);
}
)
);
}
if (!this.application.findItem(note.uuid)) {
this.application.alertService!.alert(
@@ -494,7 +494,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
noteMutator.preview_plain = previewPlain;
noteMutator.preview_html = undefined;
}
}, isUserModified)
}, isUserModified);
if (this.saveTimeout) {
this.$timeout.cancel(this.saveTimeout);
}
@@ -549,7 +549,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
this.statusTimeout = this.$timeout(() => {
this.setState({
noteStatus: status
})
});
}, MINIMUM_STATUS_DURATION);
} else {
this.setState({
@@ -702,7 +702,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false,
true,
(mutator) => {
mutator.pinned = !this.note.pinned
mutator.pinned = !this.note.pinned;
}
);
}
@@ -713,7 +713,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false,
true,
(mutator) => {
mutator.locked = !this.note.locked
mutator.locked = !this.note.locked;
}
);
}
@@ -724,7 +724,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false,
true,
(mutator) => {
mutator.protected = !this.note.protected
mutator.protected = !this.note.protected;
}
);
}
@@ -735,7 +735,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false,
true,
(mutator) => {
mutator.hidePreview = !this.note.hidePreview
mutator.hidePreview = !this.note.hidePreview;
}
);
}
@@ -754,7 +754,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
false,
true,
(mutator) => {
mutator.archived = !this.note.archived
mutator.archived = !this.note.archived;
},
/** If we are unarchiving, and we are in the archived tag, close the editor */
this.note.archived && this.appState.selectedTag?.isArchiveTag
@@ -863,7 +863,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => {
mutator.addItemAsRelationship(note);
}
)
);
}
this.application.sync();
this.reloadTags();
@@ -970,7 +970,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
);
await this.setState({
[key]: !currentValue
})
});
this.reloadFont();
if (key === PrefKey.EditorSpellcheck) {
@@ -1061,7 +1061,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
(mutator) => {
mutator.addItemAsRelationship(this.note);
}
)
);
}
}
}
@@ -1120,7 +1120,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
const mutator = m as ComponentMutator;
mutator.removeAssociatedItemId(note.uuid);
mutator.disassociateWithItem(note.uuid);
})
});
}
async associateComponentWithCurrentNote(component: SNComponent) {
@@ -1129,7 +1129,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
const mutator = m as ComponentMutator;
mutator.removeDisassociatedItemId(note.uuid);
mutator.associateWithItem(note.uuid);
})
});
}
registerKeyboardShortcuts() {

View File

@@ -8,15 +8,10 @@ class EditorGroupViewCtrl {
private application!: WebApplication
public editors: Editor[] = []
/* @ngInject */
constructor() {
}
$onInit() {
this.application.editorGroup.addChangeObserver(() => {
this.editors = this.application.editorGroup.editors;
})
});
}
}

View File

@@ -208,7 +208,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
break;
case AppStateEvent.EndedBackupDownload: {
const successMessage = "Successfully saved backup.";
const errorMessage = "Unable to save local backup."
const errorMessage = "Unable to save local backup.";
statusService.setMessage(data.success ? successMessage : errorMessage);
const twoSeconds = 2000;
@@ -297,7 +297,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
theme.package_info.dock_icon
);
}
)
);
this.observerRemovers.push(this.application.streamItems(
ContentType.Component,

View File

@@ -7,7 +7,7 @@ export function notePassesFilter(
filterText: string
) {
let canShowArchived = showArchived;
const canShowArchived = showArchived;
const canShowPinned = !hidePinned;
if (
(note.archived && !canShowArchived) ||

View File

@@ -59,7 +59,7 @@ const DEFAULT_LIST_NUM_NOTES = 20;
const ELEMENT_ID_SEARCH_BAR = 'search-bar';
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
class NotesViewCtrl extends PureViewCtrl<unknown, NotesState> {
private panelPuppet?: PanelPuppet
private reloadNotesPromise?: any
@@ -410,7 +410,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
if (activeNote && activeNote.conflictOf) {
this.application!.changeAndSaveItem(activeNote.uuid, (mutator) => {
mutator.conflictOf = undefined;
})
});
}
if (this.isFiltering()) {
this.application!.getDesktopService().searchText(this.getState().noteFilter.text);
@@ -641,7 +641,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
selectNextNote() {
const displayableNotes = this.displayableNotes();
const currentIndex = displayableNotes.findIndex((candidate) => {
return candidate.uuid === this.activeEditorNote!.uuid
return candidate.uuid === this.activeEditorNote!.uuid;
});
if (currentIndex + 1 < displayableNotes.length) {
this.selectNote(displayableNotes[currentIndex + 1]);
@@ -798,7 +798,7 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
],
onKeyDown: () => {
const searchBar = this.getSearchBar();
if (searchBar) { searchBar.focus(); };
if (searchBar) { searchBar.focus(); }
}
});
}

View File

@@ -36,7 +36,7 @@ type TagState = {
templateTag?: SNTag
}
class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
class TagsViewCtrl extends PureViewCtrl<unknown, TagState> {
/** Passed through template */
readonly application!: WebApplication
@@ -136,7 +136,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
} else {
this.setState({
selectedTag: matchingTag
})
});
}
}
}
@@ -186,14 +186,14 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
const notes = this.application.notesMatchingSmartTag(tag as SNSmartTag)
.filter((note) => {
return !note.archived && !note.trashed;
})
});
noteCounts[tag.uuid] = notes.length;
}
} else {
const notes = this.application.referencesForItem(tag, ContentType.Note)
.filter((note) => {
return !note.archived && !note.trashed;
})
});
noteCounts[tag.uuid] = notes.length;
}
}
@@ -264,7 +264,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
if (tag.conflictOf) {
this.application.changeAndSaveItem(tag.uuid, (mutator) => {
mutator.conflictOf = undefined;
})
});
}
this.application.getAppState().setSelectedTag(tag);
}
@@ -326,7 +326,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
"A tag with this name already exists."
);
return;
};
}
await this.application.changeAndSaveItem<TagMutator>(tag.uuid, (mutator) => {
mutator.title = newTitle;
});
@@ -350,7 +350,7 @@ class TagsViewCtrl extends PureViewCtrl<{}, TagState> {
"A tag with this name already exists."
);
return;
};
}
const insertedTag = await this.application.insertItem(newTag);
const changedTag = await this.application.changeItem<TagMutator>(insertedTag.uuid, (m) => {
m.title = newTitle;