Standardize array bracket spacing

pull/875/head
Louis Lam 3 years ago
parent 46e1a628a7
commit d71c086447

@ -22,40 +22,45 @@ module.exports = {
requireConfigFile: false, requireConfigFile: false,
}, },
rules: { rules: {
"linebreak-style": ["error", "unix"], "linebreak-style": [ "error", "unix" ],
"camelcase": ["warn", { "camelcase": [ "warn", {
"properties": "never", "properties": "never",
"ignoreImports": true "ignoreImports": true
}], }],
"no-unused-vars": ["warn", { "no-unused-vars": [ "warn", {
"args": "none" "args": "none"
}], }],
indent: [ indent: [
"error", "error",
4, 4,
{ {
ignoredNodes: ["TemplateLiteral"], ignoredNodes: [ "TemplateLiteral" ],
SwitchCase: 1, SwitchCase: 1,
}, },
], ],
quotes: ["warn", "double"], quotes: [ "warn", "double" ],
semi: "error", semi: "error",
"vue/html-indent": ["warn", 4], // default: 2 "vue/html-indent": [ "warn", 4 ], // default: 2
"vue/max-attributes-per-line": "off", "vue/max-attributes-per-line": "off",
"vue/singleline-html-element-content-newline": "off", "vue/singleline-html-element-content-newline": "off",
"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
"no-multi-spaces": ["error", { "no-multi-spaces": [ "error", {
ignoreEOLComments: true, ignoreEOLComments: true,
}], }],
"space-before-function-paren": ["error", { "array-bracket-spacing": [ "warn", "always", {
"singleValue": true,
"objectsInArrays": false,
"arraysInArrays": false
}],
"space-before-function-paren": [ "error", {
"anonymous": "always", "anonymous": "always",
"named": "never", "named": "never",
"asyncArrow": "always" "asyncArrow": "always"
}], }],
"curly": "error", "curly": "error",
"object-curly-spacing": ["error", "always"], "object-curly-spacing": [ "error", "always" ],
"object-curly-newline": "off", "object-curly-newline": "off",
"object-property-newline": "error", "object-property-newline": "error",
"comma-spacing": "error", "comma-spacing": "error",
@ -66,36 +71,36 @@ module.exports = {
"space-infix-ops": "warn", "space-infix-ops": "warn",
"arrow-spacing": "warn", "arrow-spacing": "warn",
"no-trailing-spaces": "warn", "no-trailing-spaces": "warn",
"no-constant-condition": ["error", { "no-constant-condition": [ "error", {
"checkLoops": false, "checkLoops": false,
}], }],
"space-before-blocks": "warn", "space-before-blocks": "warn",
//'no-console': 'warn', //'no-console': 'warn',
"no-extra-boolean-cast": "off", "no-extra-boolean-cast": "off",
"no-multiple-empty-lines": ["warn", { "no-multiple-empty-lines": [ "warn", {
"max": 1, "max": 1,
"maxBOF": 0, "maxBOF": 0,
}], }],
"lines-between-class-members": ["warn", "always", { "lines-between-class-members": [ "warn", "always", {
exceptAfterSingleLine: true, exceptAfterSingleLine: true,
}], }],
"no-unneeded-ternary": "error", "no-unneeded-ternary": "error",
"array-bracket-newline": ["error", "consistent"], "array-bracket-newline": [ "error", "consistent" ],
"eol-last": ["error", "always"], "eol-last": [ "error", "always" ],
//'prefer-template': 'error', //'prefer-template': 'error',
"comma-dangle": ["warn", "only-multiline"], "comma-dangle": [ "warn", "only-multiline" ],
"no-empty": ["error", { "no-empty": [ "error", {
"allowEmptyCatch": true "allowEmptyCatch": true
}], }],
"no-control-regex": "off", "no-control-regex": "off",
"one-var": ["error", "never"], "one-var": [ "error", "never" ],
"max-statements-per-line": ["error", { "max": 1 }] "max-statements-per-line": [ "error", { "max": 1 }]
}, },
"overrides": [ "overrides": [
{ {
"files": [ "src/languages/*.js", "src/icon.js" ], "files": [ "src/languages/*.js", "src/icon.js" ],
"rules": { "rules": {
"comma-dangle": ["error", "always-multiline"], "comma-dangle": [ "error", "always-multiline" ],
} }
}, },

@ -1,11 +1,11 @@
const config = {}; const config = {};
if (process.env.TEST_FRONTEND) { if (process.env.TEST_FRONTEND) {
config.presets = ["@babel/preset-env"]; config.presets = [ "@babel/preset-env" ];
} }
if (process.env.TEST_BACKEND) { if (process.env.TEST_BACKEND) {
config.plugins = ["babel-plugin-rewire"]; config.plugins = [ "babel-plugin-rewire" ];
} }
module.exports = config; module.exports = config;

@ -10,15 +10,15 @@ export default defineConfig({
plugins: [ plugins: [
vue(), vue(),
legacy({ legacy({
targets: ["ie > 11"], targets: [ "ie > 11" ],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"] additionalLegacyPolyfills: [ "regenerator-runtime/runtime" ]
}) })
], ],
css: { css: {
postcss: { postcss: {
"parser": postCssScss, "parser": postCssScss,
"map": false, "map": false,
"plugins": [postcssRTLCSS] "plugins": [ postcssRTLCSS ]
} }
}, },
}); });

@ -31,7 +31,7 @@ if (! exists) {
function commit(version) { function commit(version) {
let msg = "Update to " + version; let msg = "Update to " + version;
let res = childProcess.spawnSync("git", ["commit", "-m", msg, "-a"]); let res = childProcess.spawnSync("git", [ "commit", "-m", msg, "-a" ]);
let stdout = res.stdout.toString().trim(); let stdout = res.stdout.toString().trim();
console.log(stdout); console.log(stdout);
@ -39,15 +39,15 @@ function commit(version) {
throw new Error("commit error"); throw new Error("commit error");
} }
res = childProcess.spawnSync("git", ["push", "origin", "master"]); res = childProcess.spawnSync("git", [ "push", "origin", "master" ]);
console.log(res.stdout.toString().trim()); console.log(res.stdout.toString().trim());
} }
function tag(version) { function tag(version) {
let res = childProcess.spawnSync("git", ["tag", version]); let res = childProcess.spawnSync("git", [ "tag", version ]);
console.log(res.stdout.toString().trim()); console.log(res.stdout.toString().trim());
res = childProcess.spawnSync("git", ["push", "origin", version]); res = childProcess.spawnSync("git", [ "push", "origin", version ]);
console.log(res.stdout.toString().trim()); console.log(res.stdout.toString().trim());
} }
@ -56,7 +56,7 @@ function tagExists(version) {
throw new Error("invalid version"); throw new Error("invalid version");
} }
let res = childProcess.spawnSync("git", ["tag", "-l", version]); let res = childProcess.spawnSync("git", [ "tag", "-l", version ]);
return res.stdout.toString().trim() === version; return res.stdout.toString().trim() === version;
} }

@ -29,7 +29,7 @@ const github = require("@actions/github");
owner: issue.owner, owner: issue.owner,
repo: issue.repo, repo: issue.repo,
issue_number: issue.number, issue_number: issue.number,
labels: ["invalid-format"] labels: [ "invalid-format" ]
}); });
// Add the issue closing comment // Add the issue closing comment

@ -41,7 +41,7 @@ if (! exists) {
function commit(version) { function commit(version) {
let msg = "Update to " + version; let msg = "Update to " + version;
let res = childProcess.spawnSync("git", ["commit", "-m", msg, "-a"]); let res = childProcess.spawnSync("git", [ "commit", "-m", msg, "-a" ]);
let stdout = res.stdout.toString().trim(); let stdout = res.stdout.toString().trim();
console.log(stdout); console.log(stdout);
@ -51,7 +51,7 @@ function commit(version) {
} }
function tag(version) { function tag(version) {
let res = childProcess.spawnSync("git", ["tag", version]); let res = childProcess.spawnSync("git", [ "tag", version ]);
console.log(res.stdout.toString().trim()); console.log(res.stdout.toString().trim());
} }
@ -66,7 +66,7 @@ function tagExists(version) {
throw new Error("invalid version"); throw new Error("invalid version");
} }
let res = childProcess.spawnSync("git", ["tag", "-l", version]); let res = childProcess.spawnSync("git", [ "tag", "-l", version ]);
return res.stdout.toString().trim() === version; return res.stdout.toString().trim() === version;
} }

@ -16,23 +16,23 @@ function updateWiki(newVersion) {
safeDelete(wikiDir); safeDelete(wikiDir);
childProcess.spawnSync("git", ["clone", "https://github.com/louislam/uptime-kuma.wiki.git", wikiDir]); childProcess.spawnSync("git", [ "clone", "https://github.com/louislam/uptime-kuma.wiki.git", wikiDir ]);
let content = fs.readFileSync(howToUpdateFilename).toString(); let content = fs.readFileSync(howToUpdateFilename).toString();
// Replace the version: https://regex101.com/r/hmj2Bc/1 // Replace the version: https://regex101.com/r/hmj2Bc/1
content = content.replace(/(git checkout )([^\s]+)/, `$1${newVersion}`); content = content.replace(/(git checkout )([^\s]+)/, `$1${newVersion}`);
fs.writeFileSync(howToUpdateFilename, content); fs.writeFileSync(howToUpdateFilename, content);
childProcess.spawnSync("git", ["add", "-A"], { childProcess.spawnSync("git", [ "add", "-A" ], {
cwd: wikiDir, cwd: wikiDir,
}); });
childProcess.spawnSync("git", ["commit", "-m", `Update to ${newVersion}`], { childProcess.spawnSync("git", [ "commit", "-m", `Update to ${newVersion}` ], {
cwd: wikiDir, cwd: wikiDir,
}); });
console.log("Pushing to Github"); console.log("Pushing to Github");
childProcess.spawnSync("git", ["push"], { childProcess.spawnSync("git", [ "push" ], {
cwd: wikiDir, cwd: wikiDir,
}); });

@ -13,6 +13,7 @@
"install-legacy": "npm install --legacy-peer-deps", "install-legacy": "npm install --legacy-peer-deps",
"update-legacy": "npm update --legacy-peer-deps", "update-legacy": "npm update --legacy-peer-deps",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .", "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint-fix:js": "eslint --ext \".js,.vue\" --fix --ignore-path .gitignore .",
"lint:style": "stylelint \"**/*.{vue,css,scss}\" --ignore-path .gitignore", "lint:style": "stylelint \"**/*.{vue,css,scss}\" --ignore-path .gitignore",
"lint": "npm run lint:js && npm run lint:style", "lint": "npm run lint:js && npm run lint:style",
"dev": "vite --host --config ./config/vite.config.js", "dev": "vite --host --config ./config/vite.config.js",

@ -98,7 +98,7 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove
async function sendProxyList(socket) { async function sendProxyList(socket) {
const timeLogger = new TimeLogger(); const timeLogger = new TimeLogger();
const list = await R.find("proxy", " user_id = ? ", [socket.userID]); const list = await R.find("proxy", " user_id = ? ", [ socket.userID ]);
io.to(socket.userID).emit("proxyList", list.map(bean => bean.export())); io.to(socket.userID).emit("proxyList", list.map(bean => bean.export()));
timeLogger.print("Send Proxy List"); timeLogger.print("Send Proxy List");

@ -30,7 +30,7 @@ const DEFAULT_KEEP_PERIOD = 180;
try { try {
await R.exec( await R.exec(
"DELETE FROM heartbeat WHERE time < DATETIME('now', '-' || ? || ' days') ", "DELETE FROM heartbeat WHERE time < DATETIME('now', '-' || ? || ' days') ",
[parsedPeriod] [ parsedPeriod ]
); );
} catch (e) { } catch (e) {
log(`Failed to clear old data: ${e.message}`); log(`Failed to clear old data: ${e.message}`);

@ -90,7 +90,7 @@ class Monitor extends BeanModel {
} }
async getTags() { async getTags() {
return await R.getAll("SELECT mt.*, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [this.id]); return await R.getAll("SELECT mt.*, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [ this.id ]);
} }
/** /**

@ -40,7 +40,7 @@ class Alerta extends NotificationProvider {
await axios.post(alertaUrl, postData, config); await axios.post(alertaUrl, postData, config);
} else { } else {
let datadup = Object.assign( { let datadup = Object.assign( {
correlate: ["service_up", "service_down"], correlate: [ "service_up", "service_down" ],
event: monitorJSON["type"], event: monitorJSON["type"],
group: "uptimekuma-" + monitorJSON["type"], group: "uptimekuma-" + monitorJSON["type"],
resource: monitorJSON["name"], resource: monitorJSON["name"],

@ -6,7 +6,7 @@ class Apprise extends NotificationProvider {
name = "apprise"; name = "apprise";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let s = childProcess.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL]); let s = childProcess.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL ]);
let output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found"; let output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found";

@ -18,7 +18,7 @@ class Gorush extends NotificationProvider {
let data = { let data = {
"notifications": [ "notifications": [
{ {
"tokens": [notification.gorushDeviceToken], "tokens": [ notification.gorushDeviceToken ],
"platform": platformMapping[notification.gorushPlatform], "platform": platformMapping[notification.gorushPlatform],
"message": msg, "message": msg,
// Optional // Optional

@ -7,7 +7,7 @@ const server = require("./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
@ -21,7 +21,7 @@ class Proxy {
let bean; let bean;
if (proxyID) { if (proxyID) {
bean = await R.findOne("proxy", " id = ? AND user_id = ? ", [proxyID, userID]); bean = await R.findOne("proxy", " id = ? AND user_id = ? ", [ proxyID, userID ]);
if (!bean) { if (!bean) {
throw new Error("proxy not found"); throw new Error("proxy not found");
@ -71,14 +71,14 @@ class Proxy {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
static async delete(proxyID, userID) { static async delete(proxyID, userID) {
const bean = await R.findOne("proxy", " id = ? AND user_id = ? ", [proxyID, userID]); const bean = await R.findOne("proxy", " id = ? AND user_id = ? ", [ proxyID, userID ]);
if (!bean) { if (!bean) {
throw new Error("proxy not found"); throw new Error("proxy not found");
} }
// Delete removed proxy from monitors if exists // Delete removed proxy from monitors if exists
await R.exec("UPDATE monitor SET proxy_id = null WHERE proxy_id = ?", [proxyID]); await R.exec("UPDATE monitor SET proxy_id = null WHERE proxy_id = ?", [ proxyID ]);
// Delete proxy from list // Delete proxy from list
await R.trash(bean); await R.trash(bean);
@ -172,12 +172,12 @@ class Proxy {
*/ */
async function applyProxyEveryMonitor(proxyID, userID) { async function applyProxyEveryMonitor(proxyID, userID) {
// Find all monitors with id and proxy id // Find all monitors with id and proxy id
const monitors = await R.getAll("SELECT id, proxy_id FROM monitor WHERE user_id = ?", [userID]); const monitors = await R.getAll("SELECT id, proxy_id FROM monitor WHERE user_id = ?", [ userID ]);
// Update proxy id not match with given proxy id // Update proxy id not match with given proxy id
for (const monitor of monitors) { for (const monitor of monitors) {
if (monitor.proxy_id !== proxyID) { if (monitor.proxy_id !== proxyID) {
await R.exec("UPDATE monitor SET proxy_id = ? WHERE id = ?", [proxyID, monitor.id]); await R.exec("UPDATE monitor SET proxy_id = ? WHERE id = ?", [ proxyID, monitor.id ]);
} }
} }
} }

@ -108,7 +108,7 @@ if (hostname) {
log.info("server", "Custom hostname: " + hostname); log.info("server", "Custom hostname: " + hostname);
} }
const port = [args.port, process.env.UPTIME_KUMA_PORT, process.env.PORT, 3001] const port = [ args.port, process.env.UPTIME_KUMA_PORT, process.env.PORT, 3001 ]
.map(portValue => parseInt(portValue)) .map(portValue => parseInt(portValue))
.find(portValue => !isNaN(portValue)); .find(portValue => !isNaN(portValue));
@ -1237,7 +1237,7 @@ try {
const exists = proxies.find(item => item.id === proxy.id); const exists = proxies.find(item => item.id === proxy.id);
// Do not process when proxy already exists in import handle is skip and keep // Do not process when proxy already exists in import handle is skip and keep
if (["skip", "keep"].includes(importHandle) && !exists) { if ([ "skip", "keep" ].includes(importHandle) && !exists) {
return; return;
} }

@ -90,7 +90,7 @@ exports.pingAsync = function (hostname, ipv6 = false) {
exports.dnsResolve = function (hostname, resolverServer, rrtype) { exports.dnsResolve = function (hostname, resolverServer, rrtype) {
const resolver = new Resolver(); const resolver = new Resolver();
resolver.setServers([resolverServer]); resolver.setServers([ resolverServer ]);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (rrtype == "PTR") { if (rrtype == "PTR") {
resolver.reverse(hostname, (err, records) => { resolver.reverse(hostname, (err, records) => {
@ -345,7 +345,7 @@ exports.doubleCheckPassword = async (socket, currentPassword) => {
exports.startUnitTest = async () => { exports.startUnitTest = async () => {
console.log("Starting unit test..."); console.log("Starting unit test...");
const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm"; const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm";
const child = childProcess.spawn(npm, ["run", "jest"]); const child = childProcess.spawn(npm, [ "run", "jest" ]);
child.stdout.on("data", (data) => { child.stdout.on("data", (data) => {
console.log(data.toString()); console.log(data.toString());

@ -42,7 +42,7 @@ export default {
default: "No", default: "No",
}, },
}, },
emits: ["yes"], emits: [ "yes" ],
data: () => ({ data: () => ({
modal: null, modal: null,
}), }),

@ -57,7 +57,7 @@ export default {
default: undefined, default: undefined,
}, },
}, },
emits: ["update:modelValue"], emits: [ "update:modelValue" ],
data() { data() {
return { return {
visibility: "password", visibility: "password",

@ -10,7 +10,7 @@ import { sleep } from "../util.ts";
export default { export default {
props: { props: {
value: [String, Number], value: [ String, Number ],
time: { time: {
type: Number, type: Number,
default: 0.3, default: 0.3,

@ -48,7 +48,7 @@ export default {
default: undefined, default: undefined,
}, },
}, },
emits: ["update:modelValue"], emits: [ "update:modelValue" ],
data() { data() {
return { return {
visibility: "password", visibility: "password",

@ -78,7 +78,7 @@ export default {
Confirm, Confirm,
}, },
props: {}, props: {},
emits: ["added"], emits: [ "added" ],
data() { data() {
return { return {
model: null, model: null,

@ -105,7 +105,7 @@ export default {
Confirm, Confirm,
}, },
props: {}, props: {},
emits: ["added"], emits: [ "added" ],
data() { data() {
return { return {
model: null, model: null,

@ -43,7 +43,7 @@ for (let lang in languageList) {
}; };
} }
const rtlLangs = ["fa"]; const rtlLangs = [ "fa" ];
export const currentLocale = () => localStorage.locale export const currentLocale = () => localStorage.locale
|| languageList[navigator.language] && navigator.language || languageList[navigator.language] && navigator.language

@ -89,7 +89,7 @@ export default {
} }
socket = io(wsHost, { socket = io(wsHost, {
transports: ["websocket"], transports: [ "websocket" ],
}); });
socket.on("info", (info) => { socket.on("info", (info) => {
@ -108,7 +108,7 @@ export default {
socket.on("monitorList", (data) => { socket.on("monitorList", (data) => {
// Add Helper function // Add Helper function
Object.entries(data).forEach(([monitorID, monitor]) => { Object.entries(data).forEach(([ monitorID, monitor ]) => {
monitor.getUrl = () => { monitor.getUrl = () => {
try { try {
return new URL(monitor.url); return new URL(monitor.url);

@ -393,17 +393,17 @@ export default {
}, },
bodyPlaceholder() { bodyPlaceholder() {
return this.$t("Example:", [` return this.$t("Example:", [ `
{ {
"key": "value" "key": "value"
}`]); }` ]);
}, },
headersPlaceholder() { headersPlaceholder() {
return this.$t("Example:", [` return this.$t("Example:", [ `
{ {
"HeaderName": "HeaderValue" "HeaderName": "HeaderValue"
}`]); }` ]);
} }
}, },
@ -488,7 +488,7 @@ export default {
upsideDown: false, upsideDown: false,
expiryNotification: false, expiryNotification: false,
maxredirects: 10, maxredirects: 10,
accepted_statuscodes: ["200-299"], accepted_statuscodes: [ "200-299" ],
dns_resolve_type: "A", dns_resolve_type: "A",
dns_resolve_server: "1.1.1.1", dns_resolve_server: "1.1.1.1",
proxyId: null, proxyId: null,

Loading…
Cancel
Save