turn off object-curly-newline, it makes const { a, b, c, d } = require(...) ugly

This commit is contained in:
LouisLam 2021-07-30 22:11:14 +08:00
parent 60aa67892d
commit 06377af7e5
2 changed files with 28 additions and 31 deletions

View File

@ -36,22 +36,7 @@ module.exports = {
}], }],
"curly": "error", "curly": "error",
"object-curly-spacing": ["error", "always"], "object-curly-spacing": ["error", "always"],
"object-curly-newline": ["error", { "object-curly-newline": "off",
"ObjectExpression": {
"minProperties": 1,
},
"ObjectPattern": {
"multiline": true,
"minProperties": 2,
},
"ImportDeclaration": {
"multiline": true,
},
"ExportDeclaration": {
"multiline": true,
//'minProperties': 2,
},
}],
"object-property-newline": "error", "object-property-newline": "error",
"comma-spacing": "error", "comma-spacing": "error",
"brace-style": "error", "brace-style": "error",

View File

@ -6,22 +6,12 @@ dayjs.extend(utc)
dayjs.extend(timezone) dayjs.extend(timezone)
const axios = require("axios"); const axios = require("axios");
const { Prometheus } = require("../prometheus"); const { Prometheus } = require("../prometheus");
const { const { debug, UP, DOWN, PENDING } = require("../../src/util");
debug, UP, DOWN, PENDING, const { tcping, ping, checkCertificate } = require("../util-server");
} = require("../../src/util");
const {
tcping, ping, checkCertificate,
} = require("../util-server");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { BeanModel } = require("redbean-node/dist/bean-model"); const { BeanModel } = require("redbean-node/dist/bean-model");
const { Notification } = require("../notification") const { Notification } = require("../notification")
// Use Custom agent to disable session reuse
// https://github.com/nodejs/node/issues/3940
const customAgent = new https.Agent({
maxCachedSessions: 0,
});
/** /**
* status: * status:
* 0 = DOWN * 0 = DOWN
@ -53,12 +43,28 @@ class Monitor extends BeanModel {
type: this.type, type: this.type,
interval: this.interval, interval: this.interval,
keyword: this.keyword, keyword: this.keyword,
ignoreTls: Boolean(this.ignoreTls), ignoreTls: this.getIgnoreTls(),
upsideDown: Boolean(this.upsideDown), upsideDown: this.getUpsideDown(),
notificationIDList, notificationIDList,
}; };
} }
/**
* Parse to boolean
* @returns {boolean}
*/
getIgnoreTls() {
return Boolean(this.ignoreTls)
}
/**
* Parse to boolean
* @returns {boolean}
*/
getUpsideDown() {
return Boolean(this.upsideDown);
}
start(io) { start(io) {
let previousBeat = null; let previousBeat = null;
let retries = 0; let retries = 0;
@ -90,11 +96,17 @@ class Monitor extends BeanModel {
try { try {
if (this.type === "http" || this.type === "keyword") { if (this.type === "http" || this.type === "keyword") {
let startTime = dayjs().valueOf(); let startTime = dayjs().valueOf();
// Use Custom agent to disable session reuse
// https://github.com/nodejs/node/issues/3940
let res = await axios.get(this.url, { let res = await axios.get(this.url, {
headers: { headers: {
"User-Agent": "Uptime-Kuma", "User-Agent": "Uptime-Kuma",
}, },
httpsAgent: customAgent, httpsAgent: new https.Agent({
maxCachedSessions: 0,
rejectUnauthorized: ! this.getIgnoreTls(),
}),
}); });
bean.msg = `${res.status} - ${res.statusText}` bean.msg = `${res.status} - ${res.statusText}`
bean.ping = dayjs().valueOf() - startTime; bean.ping = dayjs().valueOf() - startTime;