Update linters

This commit is contained in:
Adam Stachowicz 2022-04-26 01:26:57 +02:00
parent 5fbfacf5ce
commit 1e595eaa76
13 changed files with 72 additions and 84 deletions

View File

@ -48,6 +48,7 @@ module.exports = {
"vue/html-self-closing": "off", "vue/html-self-closing": "off",
"vue/require-component-is": "off", // not allow is="style" https://github.com/vuejs/eslint-plugin-vue/issues/462#issuecomment-430234675 "vue/require-component-is": "off", // not allow is="style" https://github.com/vuejs/eslint-plugin-vue/issues/462#issuecomment-430234675
"vue/attribute-hyphenation": "off", // This change noNL to "no-n-l" unexpectedly "vue/attribute-hyphenation": "off", // This change noNL to "no-n-l" unexpectedly
"vue/multi-word-component-names": "off",
"no-multi-spaces": [ "error", { "no-multi-spaces": [ "error", {
ignoreEOLComments: true, ignoreEOLComments: true,
}], }],

View File

@ -123,7 +123,7 @@
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "~5.0.1", "@actions/github": "~5.0.1",
"@babel/eslint-parser": "~7.15.8", "@babel/eslint-parser": "~7.17.0",
"@babel/preset-env": "^7.15.8", "@babel/preset-env": "^7.15.8",
"@types/bootstrap": "~5.1.9", "@types/bootstrap": "~5.1.9",
"@vitejs/plugin-legacy": "~1.6.4", "@vitejs/plugin-legacy": "~1.6.4",
@ -135,16 +135,16 @@
"core-js": "~3.18.3", "core-js": "~3.18.3",
"cross-env": "~7.0.3", "cross-env": "~7.0.3",
"dns2": "~2.0.1", "dns2": "~2.0.1",
"eslint": "~7.32.0", "eslint": "~8.14.0",
"eslint-plugin-vue": "~7.18.0", "eslint-plugin-vue": "~8.7.1",
"jest": "~27.2.5", "jest": "~27.2.5",
"jest-puppeteer": "~6.0.3", "jest-puppeteer": "~6.0.3",
"npm-check-updates": "^12.5.5", "npm-check-updates": "^12.5.9",
"postcss-html": "^1.3.1", "postcss-html": "^1.3.1",
"puppeteer": "~13.1.3", "puppeteer": "~13.1.3",
"sass": "~1.42.1", "sass": "~1.42.1",
"stylelint": "~14.2.0", "stylelint": "~14.7.1",
"stylelint-config-standard": "~24.0.0", "stylelint-config-standard": "~25.0.0",
"typescript": "~4.4.4", "typescript": "~4.4.4",
"vite": "~2.6.14", "vite": "~2.6.14",
"wait-on": "^6.0.1" "wait-on": "^6.0.1"

View File

@ -58,7 +58,7 @@ class Database {
"patch-monitor-expiry-notification.sql": true, "patch-monitor-expiry-notification.sql": true,
"patch-status-page-footer-css.sql": true, "patch-status-page-footer-css.sql": true,
"patch-added-mqtt-monitor.sql": true, "patch-added-mqtt-monitor.sql": true,
} };
/** /**
* The final version should be 10 after merged tag feature * The final version should be 10 after merged tag feature

View File

@ -33,7 +33,7 @@ const monitorStatus = new PrometheusClient.Gauge({
}); });
class Prometheus { class Prometheus {
monitorLabelValues = {} monitorLabelValues = {};
constructor(monitor) { constructor(monitor) {
this.monitorLabelValues = { this.monitorLabelValues = {

View File

@ -7,7 +7,7 @@ const { UptimeKumaServer } = require("./uptime-kuma-server");
class Proxy { class Proxy {
static SUPPORTED_PROXY_PROTOCOLS = [ "http", "https", "socks", "socks5", "socks4" ] static SUPPORTED_PROXY_PROTOCOLS = [ "http", "https", "socks", "socks5", "socks4" ];
/** /**
* Saves and updates given proxy entity * Saves and updates given proxy entity

View File

@ -136,13 +136,6 @@ app.use(function (req, res, next) {
next(); next();
}); });
/**
* Total WebSocket client connected to server currently, no actual use
*
* @type {number}
*/
let totalClient = 0;
/** /**
* Use for decode the auth object * Use for decode the auth object
* @type {null} * @type {null}
@ -248,17 +241,11 @@ try {
sendInfo(socket); sendInfo(socket);
totalClient++;
if (needSetup) { if (needSetup) {
log.info("server", "Redirect to setup page"); log.info("server", "Redirect to setup page");
socket.emit("setup"); socket.emit("setup");
} }
socket.on("disconnect", () => {
totalClient--;
});
// *************************** // ***************************
// Public Socket API // Public Socket API
// *************************** // ***************************
@ -1228,7 +1215,7 @@ try {
for (let i = 0; i < monitorListData.length; i++) { for (let i = 0; i < monitorListData.length; i++) {
// Only starts importing the monitor if the import option is "overwrite", "keep" or "skip" but the notification doesn't exists // Only starts importing the monitor if the import option is "overwrite", "keep" or "skip" but the notification doesn't exists
if ((importHandle == "skip" && monitorNameListString.includes(monitorListData[i].name) == false) || importHandle == "keep" || importHandle == "overwrite") { if ((importHandle === "skip" && monitorNameListString.includes(monitorListData[i].name) === false) || importHandle === "keep" || importHandle === "overwrite") {
// Define in here every new variable for monitors which where implemented after the first version of the Import/Export function (1.6.0) // Define in here every new variable for monitors which where implemented after the first version of the Import/Export function (1.6.0)
// --- Start --- // --- Start ---
@ -1325,7 +1312,7 @@ try {
await updateMonitorNotification(bean.id, notificationIDList); await updateMonitorNotification(bean.id, notificationIDList);
// If monitor was active start it immediately, otherwise pause it // If monitor was active start it immediately, otherwise pause it
if (monitorListData[i].active == 1) { if (monitorListData[i].active === 1) {
await startMonitor(socket.userID, bean.id); await startMonitor(socket.userID, bean.id);
} else { } else {
await pauseMonitor(socket.userID, bean.id); await pauseMonitor(socket.userID, bean.id);

View File

@ -132,7 +132,7 @@ exports.mqttAsync = function (hostname, topic, okMessage, options = {}) {
}); });
client.on("message", (messageTopic, message) => { client.on("message", (messageTopic, message) => {
if (messageTopic == topic) { if (messageTopic === topic) {
client.end(); client.end();
clearTimeout(timeoutID); clearTimeout(timeoutID);
if (okMessage != null && okMessage !== "" && message.toString() !== okMessage) { if (okMessage != null && okMessage !== "" && message.toString() !== okMessage) {

View File

@ -5,8 +5,8 @@
<script> <script>
import dayjs from "dayjs"; import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime"; import relativeTime from "dayjs/plugin/relativeTime";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone"; // dependent on utc plugin import timezone from "dayjs/plugin/timezone"; // dependent on utc plugin
import utc from "dayjs/plugin/utc";
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(timezone); dayjs.extend(timezone);
dayjs.extend(relativeTime); dayjs.extend(relativeTime);

View File

@ -47,8 +47,8 @@
<script> <script>
import HeartbeatBar from "../components/HeartbeatBar.vue"; import HeartbeatBar from "../components/HeartbeatBar.vue";
import Uptime from "../components/Uptime.vue";
import Tag from "../components/Tag.vue"; import Tag from "../components/Tag.vue";
import Uptime from "../components/Uptime.vue";
import { getMonitorRelativeURL } from "../util.ts"; import { getMonitorRelativeURL } from "../util.ts";
export default { export default {
@ -105,7 +105,7 @@ export default {
// Simple filter by search text // Simple filter by search text
// finds monitor name, tag name or tag value // finds monitor name, tag name or tag value
if (this.searchText != "") { if (this.searchText !== "") {
const loweredSearchText = this.searchText.toLowerCase(); const loweredSearchText = this.searchText.toLowerCase();
result = result.filter(monitor => { result = result.filter(monitor => {
return monitor.name.toLowerCase().includes(loweredSearchText) return monitor.name.toLowerCase().includes(loweredSearchText)
@ -170,12 +170,6 @@ export default {
} }
} }
.dark {
.footer {
// background-color: $dark-bg;
}
}
@media (max-width: 770px) { @media (max-width: 770px) {
.list-header { .list-header {
margin: -20px; margin: -20px;

View File

@ -18,10 +18,10 @@
<script lang="ts"> <script lang="ts">
import { BarController, BarElement, Chart, Filler, LinearScale, LineController, LineElement, PointElement, TimeScale, Tooltip } from "chart.js"; import { BarController, BarElement, Chart, Filler, LinearScale, LineController, LineElement, PointElement, TimeScale, Tooltip } from "chart.js";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import "chartjs-adapter-dayjs"; import "chartjs-adapter-dayjs";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import { LineChart } from "vue-chart-3"; import { LineChart } from "vue-chart-3";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import { DOWN } from "../util.ts"; import { DOWN } from "../util.ts";
@ -217,7 +217,7 @@ export default {
watch: { watch: {
// Update chart data when the selected chart period changes // Update chart data when the selected chart period changes
chartPeriodHrs: function (newPeriod) { chartPeriodHrs: function (newPeriod) {
if (newPeriod == "0") { if (newPeriod === "0") {
newPeriod = null; newPeriod = null;
this.heartbeatList = null; this.heartbeatList = null;
this.$root.storage().removeItem(`chart-period-${this.monitorId}`); this.$root.storage().removeItem(`chart-period-${this.monitorId}`);
@ -241,7 +241,7 @@ export default {
// And mirror latest change to this.heartbeatList // And mirror latest change to this.heartbeatList
this.$watch(() => this.$root.heartbeatList[this.monitorId], this.$watch(() => this.$root.heartbeatList[this.monitorId],
(heartbeatList) => { (heartbeatList) => {
if (this.chartPeriodHrs != 0) { if (this.chartPeriodHrs !== 0) {
const newBeat = heartbeatList.at(-1); const newBeat = heartbeatList.at(-1);
if (newBeat && dayjs.utc(newBeat.time) > dayjs.utc(this.heartbeatList.at(-1)?.time)) { if (newBeat && dayjs.utc(newBeat.time) > dayjs.utc(this.heartbeatList.at(-1)?.time)) {
this.heartbeatList.push(heartbeatList.at(-1)); this.heartbeatList.push(heartbeatList.at(-1));

View File

@ -1,13 +1,14 @@
<template> <template>
<div class="tag-wrapper rounded d-inline-flex" <div
:class="{ 'px-3': size == 'normal', class="tag-wrapper rounded d-inline-flex"
'py-1': size == 'normal', :class="{ 'px-3': size == 'normal',
'm-2': size == 'normal', 'py-1': size == 'normal',
'px-2': size == 'sm', 'm-2': size == 'normal',
'py-0': size == 'sm', 'px-2': size == 'sm',
'm-1': size == 'sm', 'py-0': size == 'sm',
}" 'm-1': size == 'sm',
:style="{ backgroundColor: item.color, fontSize: size == 'sm' ? '0.7em' : '1em' }" }"
:style="{ backgroundColor: item.color, fontSize: size == 'sm' ? '0.7em' : '1em' }"
> >
<span class="tag-text">{{ displayText }}</span> <span class="tag-text">{{ displayText }}</span>
<span v-if="remove != null" class="ps-1 btn-remove" @click="remove(item)"> <span v-if="remove != null" class="ps-1 btn-remove" @click="remove(item)">
@ -34,7 +35,7 @@ export default {
}, },
computed: { computed: {
displayText() { displayText() {
if (this.item.value == "") { if (this.item.value === "") {
return this.item.name; return this.item.name;
} else { } else {
return `${this.item.name}: ${this.item.value}`; return `${this.item.name}: ${this.item.value}`;

View File

@ -34,18 +34,20 @@
label="name" label="name"
> >
<template #option="{ option }"> <template #option="{ option }">
<div class="mx-2 py-1 px-3 rounded d-inline-flex" <div
style="margin-top: -5px; margin-bottom: -5px; height: 24px;" class="mx-2 py-1 px-3 rounded d-inline-flex"
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }" style="margin-top: -5px; margin-bottom: -5px; height: 24px;"
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }"
> >
<span> <span>
{{ option.name }}</span> {{ option.name }}</span>
</div> </div>
</template> </template>
<template #singleLabel="{ option }"> <template #singleLabel="{ option }">
<div class="py-1 px-3 rounded d-inline-flex" <div
style="height: 24px;" class="py-1 px-3 rounded d-inline-flex"
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }" style="height: 24px;"
:style="{ color: textColor(option), backgroundColor: option.color + ' !important' }"
> >
<span>{{ option.name }}</span> <span>{{ option.name }}</span>
</div> </div>
@ -53,10 +55,11 @@
</vue-multiselect> </vue-multiselect>
<div v-if="newDraftTag.select?.name == null" class="d-flex mb-2"> <div v-if="newDraftTag.select?.name == null" class="d-flex mb-2">
<div class="w-50 pe-2"> <div class="w-50 pe-2">
<input v-model="newDraftTag.name" class="form-control" <input
:class="{'is-invalid': validateDraftTag.nameInvalid}" v-model="newDraftTag.name" class="form-control"
:placeholder="$t('Name')" :class="{'is-invalid': validateDraftTag.nameInvalid}"
@keydown.enter.prevent="onEnter" :placeholder="$t('Name')"
@keydown.enter.prevent="onEnter"
/> />
<div class="invalid-feedback"> <div class="invalid-feedback">
{{ $t("Tag with this name already exist.") }} {{ $t("Tag with this name already exist.") }}
@ -75,17 +78,19 @@
deselect-label="" deselect-label=""
> >
<template #option="{ option }"> <template #option="{ option }">
<div class="mx-2 py-1 px-3 rounded d-inline-flex" <div
style="height: 24px; color: white;" class="mx-2 py-1 px-3 rounded d-inline-flex"
:style="{ backgroundColor: option.color + ' !important' }" style="height: 24px; color: white;"
:style="{ backgroundColor: option.color + ' !important' }"
> >
<span>{{ option.name }}</span> <span>{{ option.name }}</span>
</div> </div>
</template> </template>
<template #singleLabel="{ option }"> <template #singleLabel="{ option }">
<div class="py-1 px-3 rounded d-inline-flex" <div
style="height: 24px; color: white;" class="py-1 px-3 rounded d-inline-flex"
:style="{ backgroundColor: option.color + ' !important' }" style="height: 24px; color: white;"
:style="{ backgroundColor: option.color + ' !important' }"
> >
<span>{{ option.name }}</span> <span>{{ option.name }}</span>
</div> </div>
@ -94,10 +99,11 @@
</div> </div>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<input v-model="newDraftTag.value" class="form-control" <input
:class="{'is-invalid': validateDraftTag.valueInvalid}" v-model="newDraftTag.value" class="form-control"
:placeholder="$t('value (optional)')" :class="{'is-invalid': validateDraftTag.valueInvalid}"
@keydown.enter.prevent="onEnter" :placeholder="$t('value (optional)')"
@keydown.enter.prevent="onEnter"
/> />
<div class="invalid-feedback"> <div class="invalid-feedback">
{{ $t("Tag with this value already exist.") }} {{ $t("Tag with this value already exist.") }}
@ -123,8 +129,8 @@
<script> <script>
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import VueMultiselect from "vue-multiselect"; import VueMultiselect from "vue-multiselect";
import Tag from "../components/Tag.vue";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import Tag from "../components/Tag.vue";
const toast = useToast(); const toast = useToast();
export default { export default {
@ -159,14 +165,14 @@ export default {
tagOptions() { tagOptions() {
const tagOptions = this.existingTags; const tagOptions = this.existingTags;
for (const tag of this.newTags) { for (const tag of this.newTags) {
if (!tagOptions.find(t => t.name == tag.name && t.color == tag.color)) { if (!tagOptions.find(t => t.name === tag.name && t.color === tag.color)) {
tagOptions.push(tag); tagOptions.push(tag);
} }
} }
return tagOptions; return tagOptions;
}, },
selectedTags() { selectedTags() {
return this.preSelectedTags.concat(this.newTags).filter(tag => !this.deleteTags.find(monitorTag => monitorTag.id == tag.id)); return this.preSelectedTags.concat(this.newTags).filter(tag => !this.deleteTags.find(monitorTag => monitorTag.id === tag.id));
}, },
colorOptions() { colorOptions() {
return [ return [
@ -192,7 +198,7 @@ export default {
let nameInvalid = false; let nameInvalid = false;
let valueInvalid = false; let valueInvalid = false;
let invalid = true; let invalid = true;
if (this.deleteTags.find(tag => tag.name == this.newDraftTag.select?.name && tag.value == this.newDraftTag.value)) { if (this.deleteTags.find(tag => tag.name === this.newDraftTag.select?.name && tag.value === this.newDraftTag.value)) {
// Undo removing a Tag // Undo removing a Tag
nameInvalid = false; nameInvalid = false;
valueInvalid = false; valueInvalid = false;
@ -202,9 +208,9 @@ export default {
nameInvalid = true; nameInvalid = true;
invalid = true; invalid = true;
} else if (this.newTags.concat(this.preSelectedTags).filter(tag => ( } else if (this.newTags.concat(this.preSelectedTags).filter(tag => (
tag.name == this.newDraftTag.select?.name && tag.value == this.newDraftTag.value tag.name === this.newDraftTag.select?.name && tag.value === this.newDraftTag.value
) || ( ) || (
tag.name == this.newDraftTag.name && tag.value == this.newDraftTag.value tag.name === this.newDraftTag.name && tag.value === this.newDraftTag.value
)).length > 0) { )).length > 0) {
// Try to add a tag with existing name and value // Try to add a tag with existing name and value
valueInvalid = true; valueInvalid = true;
@ -250,7 +256,7 @@ export default {
deleteTag(item) { deleteTag(item) {
if (item.new) { if (item.new) {
// Undo Adding a new Tag // Undo Adding a new Tag
this.newTags = this.newTags.filter(tag => !(tag.name == item.name && tag.value == item.value)); this.newTags = this.newTags.filter(tag => !(tag.name === item.name && tag.value === item.value));
} else { } else {
// Remove an Existing Tag // Remove an Existing Tag
this.deleteTags.push(item); this.deleteTags.push(item);
@ -266,9 +272,9 @@ export default {
addDraftTag() { addDraftTag() {
console.log("Adding Draft Tag: ", this.newDraftTag); console.log("Adding Draft Tag: ", this.newDraftTag);
if (this.newDraftTag.select != null) { if (this.newDraftTag.select != null) {
if (this.deleteTags.find(tag => tag.name == this.newDraftTag.select.name && tag.value == this.newDraftTag.value)) { if (this.deleteTags.find(tag => tag.name === this.newDraftTag.select.name && tag.value === this.newDraftTag.value)) {
// Undo removing a tag // Undo removing a tag
this.deleteTags = this.deleteTags.filter(tag => !(tag.name == this.newDraftTag.select.name && tag.value == this.newDraftTag.value)); this.deleteTags = this.deleteTags.filter(tag => !(tag.name === this.newDraftTag.select.name && tag.value === this.newDraftTag.value));
} else { } else {
// Add an existing Tag // Add an existing Tag
this.newTags.push({ this.newTags.push({
@ -345,7 +351,7 @@ export default {
tagId = newTagResult.id; tagId = newTagResult.id;
// Assign the new ID to the tags of the same name & color // Assign the new ID to the tags of the same name & color
this.newTags.map(tag => { this.newTags.map(tag => {
if (tag.name == newTag.name && tag.color == newTag.color) { if (tag.name === newTag.name && tag.color === newTag.color) {
tag.id = newTagResult.id; tag.id = newTagResult.id;
} }
}); });

View File

@ -361,13 +361,12 @@
</template> </template>
<script> <script>
import VueMultiselect from "vue-multiselect";
import { useToast } from "vue-toastification";
import CopyableInput from "../components/CopyableInput.vue";
import NotificationDialog from "../components/NotificationDialog.vue"; import NotificationDialog from "../components/NotificationDialog.vue";
import ProxyDialog from "../components/ProxyDialog.vue"; import ProxyDialog from "../components/ProxyDialog.vue";
import TagsManager from "../components/TagsManager.vue"; import TagsManager from "../components/TagsManager.vue";
import CopyableInput from "../components/CopyableInput.vue";
import { useToast } from "vue-toastification";
import VueMultiselect from "vue-multiselect";
import { genSecret, isDev } from "../util.ts"; import { genSecret, isDev } from "../util.ts";
const toast = useToast(); const toast = useToast();
@ -540,7 +539,7 @@ export default {
} }
for (let i = 0; i < this.$root.notificationList.length; i++) { for (let i = 0; i < this.$root.notificationList.length; i++) {
if (this.$root.notificationList[i].isDefault == true) { if (this.$root.notificationList[i].isDefault === true) {
this.monitor.notificationIDList[this.$root.notificationList[i].id] = true; this.monitor.notificationIDList[this.$root.notificationList[i].id] = true;
} }
} }