Skip to content

Commit

Permalink
Standardize array bracket spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Apr 17, 2022
1 parent 46e1a62 commit d71c086
Show file tree
Hide file tree
Showing 26 changed files with 73 additions and 67 deletions.
43 changes: 24 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,45 @@ module.exports = {
requireConfigFile: false,
},
rules: {
"linebreak-style": ["error", "unix"],
"camelcase": ["warn", {
"linebreak-style": [ "error", "unix" ],
"camelcase": [ "warn", {
"properties": "never",
"ignoreImports": true
}],
"no-unused-vars": ["warn", {
"no-unused-vars": [ "warn", {
"args": "none"
}],
indent: [
"error",
4,
{
ignoredNodes: ["TemplateLiteral"],
ignoredNodes: [ "TemplateLiteral" ],
SwitchCase: 1,
},
],
quotes: ["warn", "double"],
quotes: [ "warn", "double" ],
semi: "error",
"vue/html-indent": ["warn", 4], // default: 2
"vue/html-indent": [ "warn", 4 ], // default: 2
"vue/max-attributes-per-line": "off",
"vue/singleline-html-element-content-newline": "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/attribute-hyphenation": "off", // This change noNL to "no-n-l" unexpectedly
"no-multi-spaces": ["error", {
"no-multi-spaces": [ "error", {
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",
"named": "never",
"asyncArrow": "always"
}],
"curly": "error",
"object-curly-spacing": ["error", "always"],
"object-curly-spacing": [ "error", "always" ],
"object-curly-newline": "off",
"object-property-newline": "error",
"comma-spacing": "error",
Expand All @@ -66,36 +71,36 @@ module.exports = {
"space-infix-ops": "warn",
"arrow-spacing": "warn",
"no-trailing-spaces": "warn",
"no-constant-condition": ["error", {
"no-constant-condition": [ "error", {
"checkLoops": false,
}],
"space-before-blocks": "warn",
//'no-console': 'warn',
"no-extra-boolean-cast": "off",
"no-multiple-empty-lines": ["warn", {
"no-multiple-empty-lines": [ "warn", {
"max": 1,
"maxBOF": 0,
}],
"lines-between-class-members": ["warn", "always", {
"lines-between-class-members": [ "warn", "always", {
exceptAfterSingleLine: true,
}],
"no-unneeded-ternary": "error",
"array-bracket-newline": ["error", "consistent"],
"eol-last": ["error", "always"],
"array-bracket-newline": [ "error", "consistent" ],
"eol-last": [ "error", "always" ],
//'prefer-template': 'error',
"comma-dangle": ["warn", "only-multiline"],
"no-empty": ["error", {
"comma-dangle": [ "warn", "only-multiline" ],
"no-empty": [ "error", {
"allowEmptyCatch": true
}],
"no-control-regex": "off",
"one-var": ["error", "never"],
"max-statements-per-line": ["error", { "max": 1 }]
"one-var": [ "error", "never" ],
"max-statements-per-line": [ "error", { "max": 1 }]
},
"overrides": [
{
"files": [ "src/languages/*.js", "src/icon.js" ],
"rules": {
"comma-dangle": ["error", "always-multiline"],
"comma-dangle": [ "error", "always-multiline" ],
}
},

Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const config = {};

if (process.env.TEST_FRONTEND) {
config.presets = ["@babel/preset-env"];
config.presets = [ "@babel/preset-env" ];
}

if (process.env.TEST_BACKEND) {
config.plugins = ["babel-plugin-rewire"];
config.plugins = [ "babel-plugin-rewire" ];
}

module.exports = config;
6 changes: 3 additions & 3 deletions config/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export default defineConfig({
plugins: [
vue(),
legacy({
targets: ["ie > 11"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"]
targets: [ "ie > 11" ],
additionalLegacyPolyfills: [ "regenerator-runtime/runtime" ]
})
],
css: {
postcss: {
"parser": postCssScss,
"map": false,
"plugins": [postcssRTLCSS]
"plugins": [ postcssRTLCSS ]
}
},
});
10 changes: 5 additions & 5 deletions extra/beta/update-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ if (! exists) {
function commit(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();
console.log(stdout);

if (stdout.includes("no changes added to commit")) {
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());
}

function tag(version) {
let res = childProcess.spawnSync("git", ["tag", version]);
let res = childProcess.spawnSync("git", [ "tag", version ]);
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());
}

Expand All @@ -56,7 +56,7 @@ function tagExists(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;
}
2 changes: 1 addition & 1 deletion extra/close-incorrect-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const github = require("@actions/github");
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
labels: ["invalid-format"]
labels: [ "invalid-format" ]
});

// Add the issue closing comment
Expand Down
6 changes: 3 additions & 3 deletions extra/update-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (! exists) {
function commit(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();
console.log(stdout);

Expand All @@ -51,7 +51,7 @@ function commit(version) {
}

function tag(version) {
let res = childProcess.spawnSync("git", ["tag", version]);
let res = childProcess.spawnSync("git", [ "tag", version ]);
console.log(res.stdout.toString().trim());
}

Expand All @@ -66,7 +66,7 @@ function tagExists(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;
}
8 changes: 4 additions & 4 deletions extra/update-wiki-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ function updateWiki(newVersion) {

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();

// Replace the version: https://regex101.com/r/hmj2Bc/1
content = content.replace(/(git checkout )([^\s]+)/, `$1${newVersion}`);
fs.writeFileSync(howToUpdateFilename, content);

childProcess.spawnSync("git", ["add", "-A"], {
childProcess.spawnSync("git", [ "add", "-A" ], {
cwd: wikiDir,
});

childProcess.spawnSync("git", ["commit", "-m", `Update to ${newVersion}`], {
childProcess.spawnSync("git", [ "commit", "-m", `Update to ${newVersion}` ], {
cwd: wikiDir,
});

console.log("Pushing to Github");
childProcess.spawnSync("git", ["push"], {
childProcess.spawnSync("git", [ "push" ], {
cwd: wikiDir,
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"install-legacy": "npm install --legacy-peer-deps",
"update-legacy": "npm update --legacy-peer-deps",
"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": "npm run lint:js && npm run lint:style",
"dev": "vite --host --config ./config/vite.config.js",
Expand Down
2 changes: 1 addition & 1 deletion server/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove
async function sendProxyList(socket) {
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()));

timeLogger.print("Send Proxy List");
Expand Down
2 changes: 1 addition & 1 deletion server/jobs/clear-old-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DEFAULT_KEEP_PERIOD = 180;
try {
await R.exec(
"DELETE FROM heartbeat WHERE time < DATETIME('now', '-' || ? || ' days') ",
[parsedPeriod]
[ parsedPeriod ]
);
} catch (e) {
log(`Failed to clear old data: ${e.message}`);
Expand Down
2 changes: 1 addition & 1 deletion server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Monitor extends BeanModel {
}

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 ]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/alerta.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Alerta extends NotificationProvider {
await axios.post(alertaUrl, postData, config);
} else {
let datadup = Object.assign( {
correlate: ["service_up", "service_down"],
correlate: [ "service_up", "service_down" ],
event: monitorJSON["type"],
group: "uptimekuma-" + monitorJSON["type"],
resource: monitorJSON["name"],
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/apprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Apprise extends NotificationProvider {
name = "apprise";

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";

Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/gorush.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Gorush extends NotificationProvider {
let data = {
"notifications": [
{
"tokens": [notification.gorushDeviceToken],
"tokens": [ notification.gorushDeviceToken ],
"platform": platformMapping[notification.gorushPlatform],
"message": msg,
// Optional
Expand Down
12 changes: 6 additions & 6 deletions server/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const server = require("./server");

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
Expand All @@ -21,7 +21,7 @@ class Proxy {
let bean;

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) {
throw new Error("proxy not found");
Expand Down Expand Up @@ -71,14 +71,14 @@ class Proxy {
* @return {Promise<void>}
*/
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) {
throw new Error("proxy not found");
}

// 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
await R.trash(bean);
Expand Down Expand Up @@ -172,12 +172,12 @@ class Proxy {
*/
async function applyProxyEveryMonitor(proxyID, userID) {
// 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
for (const monitor of monitors) {
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 ]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ if (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))
.find(portValue => !isNaN(portValue));

Expand Down Expand Up @@ -1237,7 +1237,7 @@ try {
const exists = proxies.find(item => item.id === proxy.id);

// 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;
}

Expand Down
4 changes: 2 additions & 2 deletions server/util-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ exports.pingAsync = function (hostname, ipv6 = false) {

exports.dnsResolve = function (hostname, resolverServer, rrtype) {
const resolver = new Resolver();
resolver.setServers([resolverServer]);
resolver.setServers([ resolverServer ]);
return new Promise((resolve, reject) => {
if (rrtype == "PTR") {
resolver.reverse(hostname, (err, records) => {
Expand Down Expand Up @@ -345,7 +345,7 @@ exports.doubleCheckPassword = async (socket, currentPassword) => {
exports.startUnitTest = async () => {
console.log("Starting unit test...");
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) => {
console.log(data.toString());
Expand Down
2 changes: 1 addition & 1 deletion src/components/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
default: "No",
},
},
emits: ["yes"],
emits: [ "yes" ],
data: () => ({
modal: null,
}),
Expand Down
Loading

0 comments on commit d71c086

Please sign in to comment.