feat: add vue 3 eslint rules and fix issues

This commit is contained in:
Alex Grozav 2023-07-04 09:28:08 +03:00
parent 34fbff0828
commit e0276b12ef
19 changed files with 38 additions and 31 deletions

View file

@ -4,7 +4,7 @@
module.exports = {
plugins: ['vue'],
extends: ['plugin:vue/essential', '@vue/typescript', './base'],
extends: ['plugin:vue/vue3-essential', '@vue/typescript', './base'],
env: {
browser: true,
@ -37,6 +37,12 @@ module.exports = {
'vue/no-unused-components': 'error',
'vue/multi-word-component-names': 'off',
// TODO: fix these
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
// TODO: remove these
'vue/no-mutating-props': 'warn',
'vue/no-side-effects-in-computed-properties': 'warn',

View file

@ -4,7 +4,7 @@
:placement="placement"
:size="size"
trigger="click"
@click.native.stop
@click.stop
@command="onCommand"
@visible-change="onVisibleChange"
>

View file

@ -164,7 +164,7 @@ export default defineComponent({
}
function onUpdateItemSize(item: { [key: string]: string }) {
nextTick(() => {
void nextTick(() => {
const itemId = item[props.itemKey];
const itemRef = itemRefs.value[itemId] as HTMLElement;
const previousSize = itemSizeCache.value[itemId];
@ -186,7 +186,7 @@ export default defineComponent({
function onWindowResize() {
if (wrapperRef.value) {
wrapperHeight.value = wrapperRef.value.offsetHeight;
nextTick(() => {
void nextTick(() => {
updateItemSizeCache(visibleItems.value);
});
}

View file

@ -88,7 +88,7 @@ export default defineComponent({
this.canScrollRight = scrollWidth - width > this.scrollPosition;
}
},
destroyed() {
unmounted() {
if (this.resizeObserver) {
this.resizeObserver.disconnect();
}

View file

@ -68,7 +68,7 @@ export default defineComponent({
observer.observe(this.$refs.root as HTMLDivElement);
}
},
beforeDestroy() {
beforeUnmount() {
if (this.enabled) {
this.observer?.disconnect(); // eslint-disable-line
}

View file

@ -78,7 +78,7 @@ export default defineComponent({
this.observer.observe(body, { attributes: true });
}
},
destroyed() {
unmounted() {
if (this.observer) {
this.observer.disconnect();
}

View file

@ -68,7 +68,7 @@ export default defineComponent({
this.observer.observe(body, { attributes: true });
}
},
destroyed() {
unmounted() {
if (this.observer) {
this.observer.disconnect();
}

View file

@ -65,7 +65,7 @@ export default defineComponent({
this.observer.observe(body, { attributes: true });
}
},
destroyed() {
unmounted() {
if (this.observer) {
this.observer.disconnect();
}

View file

@ -20,6 +20,7 @@
import { defineComponent } from 'vue';
import { copyPaste } from '@/mixins/copyPaste';
import { useToast } from '@/composables';
import { i18n } from '@/plugins/i18n';
export default defineComponent({
mixins: [copyPaste],
@ -36,13 +37,13 @@ export default defineComponent({
copyButtonText: {
type: String,
default(): string {
return this.$locale.baseText('generic.copy');
return i18n.baseText('generic.copy');
},
},
toastTitle: {
type: String,
default(): string {
return this.$locale.baseText('generic.copiedToClipboard');
return i18n.baseText('generic.copiedToClipboard');
},
},
toastMessage: {

View file

@ -349,7 +349,9 @@ export default defineComponent({
async startAutoRefreshInterval() {
if (this.autoRefresh) {
await this.loadAutoRefresh();
this.autoRefreshTimeout = setTimeout(() => this.startAutoRefreshInterval(), 4000);
this.autoRefreshTimeout = setTimeout(() => {
void this.startAutoRefreshInterval();
}, 4000);
}
},
stopAutoRefreshInterval() {
@ -363,13 +365,13 @@ export default defineComponent({
this.uiStore.executionSidebarAutoRefresh = this.autoRefresh;
this.stopAutoRefreshInterval(); // Clear any previously existing intervals (if any - there shouldn't)
this.startAutoRefreshInterval();
void this.startAutoRefreshInterval();
},
onDocumentVisibilityChange() {
if (document.visibilityState === 'hidden') {
this.stopAutoRefreshInterval();
void this.stopAutoRefreshInterval();
} else {
this.startAutoRefreshInterval();
void this.startAutoRefreshInterval();
}
},
async loadAutoRefresh(): Promise<void> {
@ -449,7 +451,7 @@ export default defineComponent({
return [];
}
try {
return await this.workflowsStore.loadCurrentWorkflowExecutions(this.requestFilter);
return this.workflowsStore.loadCurrentWorkflowExecutions(this.requestFilter);
} catch (error) {
if (error.errorCode === NO_NETWORK_ERROR_CODE) {
this.showMessage(

View file

@ -115,7 +115,7 @@
<script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue';
import type { Component, PropType } from 'vue';
import type { PropType } from 'vue';
import type { IUpdateInformation } from '@/Interface';
import type {

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, getCurrentInstance, onMounted, defineComponent, h } from 'vue';
import type { VNode, PropType } from 'vue';
import type { PropType } from 'vue';
import type {
INodeCreateElement,
ActionTypeDescription,

View file

@ -418,7 +418,7 @@ export default defineComponent({
this.avgOutputRowHeight = 0;
this.avgInputRowHeight = 0;
setTimeout(this.ndvStore.setNDVSessionId, 0);
setTimeout(() => this.ndvStore.setNDVSessionId(), 0);
void this.$externalHooks().run('dataDisplay.nodeTypeChanged', {
nodeSubtitle: this.getNodeSubtitle(node, this.activeNodeType, this.getCurrentWorkflow()),
});

View file

@ -261,7 +261,7 @@ export default defineComponent({
}, 0);
},
loading() {
setTimeout(this.onResultsEnd, 0); // in case of filtering
setTimeout(() => this.onResultsEnd(), 0); // in case of filtering
},
},
});

View file

@ -449,11 +449,11 @@
<el-pagination
background
:hide-on-single-page="true"
:current-page.sync="currentPage"
:current-page="currentPage"
:pager-count="5"
:page-size="pageSize"
layout="prev, pager, next"
@current-change="onCurrentPageChange"
@update:current-page="onCurrentPageChange"
:total="dataCount"
>
</el-pagination>
@ -1134,7 +1134,8 @@ export default defineComponent({
unlinkRun() {
this.$emit('unlinkRun');
},
onCurrentPageChange() {
onCurrentPageChange(value) {
this.currentPage = value;
this.$telemetry.track('User changed ndv page', {
node_type: this.activeNode?.type,
workflow_id: this.workflowsStore.workflowId,

View file

@ -26,10 +26,11 @@
:data="jsonData"
:deep="10"
:showLength="true"
:selected-value.sync="selectedJsonPath"
:selectedValue="selectedJsonPath"
rootPath=""
selectableType="single"
class="json-data"
@update:selectedValue="selectedJsonPath = $event"
>
<template #renderNodeKey="{ node }">
<span

View file

@ -24,8 +24,8 @@ import {
highlightActiveLineGutter,
keymap,
lineNumbers,
ViewUpdate,
} from '@codemirror/view';
import type { ViewUpdate } from '@codemirror/view';
import {
MSSQL,
MySQL,

View file

@ -23,7 +23,7 @@
v-touch:end="touchEnd"
>
<n8n-sticky
:content.sync="node.parameters.content"
:content="node.parameters.content"
:height="node.parameters.height"
:width="node.parameters.width"
:scale="nodeViewScale"
@ -190,6 +190,7 @@ export default defineComponent({
}
},
onInputChange(content: string) {
this.node.parameters.content = content;
this.setParameters({ content });
},
onResizeStart() {

View file

@ -1,5 +0,0 @@
declare module 'vue-json-pretty' {
import { Component } from 'vue';
const vueJsonPretty: Component;
export default vueJsonPretty;
}