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 = { module.exports = {
plugins: ['vue'], plugins: ['vue'],
extends: ['plugin:vue/essential', '@vue/typescript', './base'], extends: ['plugin:vue/vue3-essential', '@vue/typescript', './base'],
env: { env: {
browser: true, browser: true,
@ -37,6 +37,12 @@ module.exports = {
'vue/no-unused-components': 'error', 'vue/no-unused-components': 'error',
'vue/multi-word-component-names': 'off', '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 // TODO: remove these
'vue/no-mutating-props': 'warn', 'vue/no-mutating-props': 'warn',
'vue/no-side-effects-in-computed-properties': 'warn', 'vue/no-side-effects-in-computed-properties': 'warn',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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