From 8a0643805e3d064d4b4fea5dc312648ffb14681d Mon Sep 17 00:00:00 2001 From: Canop Date: Wed, 1 Jan 2025 11:17:31 +0100 Subject: [PATCH 1/3] lint rules, part of the code "fixed", no test --- bacon.toml | 43 +++++++++++- biome.json | 5 ++ graphics/M-14.svg | 103 +++++++++++++++++++++++++++++ graphics/M-simple.svg | 97 +++++++++++++++++++++++++++ graphics/Miaou-white.svg | 139 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/main-js/wzin.js | 6 +- src/page-js/auths.js | 13 ++-- src/page-js/chat.js | 6 +- src/page-js/chat.mob.js | 10 +-- src/page-js/help.js | 10 +-- src/page-js/login.js | 18 ++--- src/page-js/pad.js | 17 ++--- src/page-js/pad.mob.js | 23 +++---- src/page-js/prefs.js | 46 ++++++------- src/page-js/request.js | 8 +-- src/page-js/room.js | 12 ++-- src/page-js/rooms.js | 22 +++---- src/page-js/user.js | 4 +- src/page-js/username.js | 8 +-- src/sw-js/sw-notifs.js | 12 ++-- yarn.lock | 19 ++++++ 22 files changed, 515 insertions(+), 107 deletions(-) create mode 100644 biome.json create mode 100644 graphics/M-14.svg create mode 100644 graphics/M-simple.svg create mode 100644 graphics/Miaou-white.svg diff --git a/bacon.toml b/bacon.toml index 58c08ada..4714b40c 100644 --- a/bacon.toml +++ b/bacon.toml @@ -2,12 +2,51 @@ # # Complete help on configuration: https://dystroy.org/bacon/config/ -default_job = "eslint-server" +default_job = "biome-libs" -[jobs.eslint-server] +[jobs.biome-libs] +env.RAYON_NUM_THREADS = "1" # for reproducible order +command = [ + "npx", "@biomejs/biome", "lint", + "--colors", "force", + "./libs", + "--skip", "complexity/useArrowFunction", + "--skip", "style/useTemplate", +] +need_stdout = true +analyzer = "biome" +watch = ["libs"] + +[jobs.biome-client] +env.RAYON_NUM_THREADS = "1" # for reproducible order +command = [ + "npx", "@biomejs/biome", "lint", + "--colors", "force", + "./src", + "--skip", "complexity/useArrowFunction", + "--skip", "style/useTemplate", + "--skip", "style/noArguments", + "--skip", "style/useConst", + "--skip", "suspicious/noRedundantUseStrict", + "--skip", "style/useSingleVarDeclarator", + "--skip", "complexity/noForEach", + "--skip", "style/noParameterAssign", + "--skip", "complexity/useLiteralKeys", + "--skip", "suspicious/noAssignInExpressions", # TODO clean +] +need_stdout = true +analyzer = "biome" +watch = [ + "libs", + "biome.json", +] + + +[jobs.eslint-libs] command = ["npx", "eslint", "--color", "libs/*"] need_stdout = true analyzer = "eslint" watch = ["libs"] [keybindings] +c = "job:biome-client" diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..e47eee8f --- /dev/null +++ b/biome.json @@ -0,0 +1,5 @@ +{ + "files": { + "ignore": ["jquery-*.js"] + } +} diff --git a/graphics/M-14.svg b/graphics/M-14.svg new file mode 100644 index 00000000..5d1fccb1 --- /dev/null +++ b/graphics/M-14.svg @@ -0,0 +1,103 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/graphics/M-simple.svg b/graphics/M-simple.svg new file mode 100644 index 00000000..d1ae1402 --- /dev/null +++ b/graphics/M-simple.svg @@ -0,0 +1,97 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/graphics/Miaou-white.svg b/graphics/Miaou-white.svg new file mode 100644 index 00000000..c4ee358d --- /dev/null +++ b/graphics/Miaou-white.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index dfb0deb4..824e5d3b 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "start": "sh start.sh" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@eslint/js": "^9.14.0", "eslint": "^9.14.0", "globals": "^15.12.0" diff --git a/src/main-js/wzin.js b/src/main-js/wzin.js index 62c36a56..ec0b16ee 100644 --- a/src/main-js/wzin.js +++ b/src/main-js/wzin.js @@ -36,7 +36,7 @@ window.wzin = (function(){ this.svg.remove(); if (this.observer) this.observer.disconnect(); while (this.bindings.length) { - var args = this.bindings.shift(); + let args = this.bindings.shift(); args[0].off(args[1], args[2]); } if (this.savedBg) { @@ -92,7 +92,7 @@ window.wzin = (function(){ path += " H "+l2; path += " V "+p2.top; path += " H "+pl; - var dx = Math.min(s, p2.top-p1.top-h1+10); + let dx = Math.min(s, p2.top-p1.top-h1+10); path += " C "+(pl-dx)+' '+(p2.top)+ ', '+(pl-dx)+' '+B1+ ', '+l1+' '+B1; } else { path += " C "+(pl-S)+' '+p1.top+ ', '+(pl-S)+' '+B2+ ', '+l2+' '+B; @@ -105,7 +105,7 @@ window.wzin = (function(){ } } } else { - var r1 = l1+w1, + let r1 = l1+w1, r2 = l2+w2, r = Math.max(r1, r2); path = "M "+r1+' '+p1.top; diff --git a/src/page-js/auths.js b/src/page-js/auths.js index 765c9189..13531817 100644 --- a/src/page-js/auths.js +++ b/src/page-js/auths.js @@ -5,7 +5,7 @@ $(function(){ }); miaou(function(gui, locals, prof, time){ - var room = locals.room; + let room = locals.room; $('.date').text(function(_, t){ return Date.now()/1000-t<15*60 ? "just now" : time.formatRelativeTime(t); }); @@ -18,14 +18,17 @@ miaou(function(gui, locals, prof, time){ } $('#auths-page') .on('mouseenter', '.user', prof.show).on('mouseleave', '.profile', prof.hide); - $('#backToRoom').click(function(){ location = room.path; return false }); + $('#backToRoom').click(function(){ + document.location = room.path; + return false; + }); $('input[type=radio]').click(function(){ - var $row = $(this).closest('tr').nextAll('.denyMessageTr').first(); - if (this.value=='deny') $row.show().find('input').focus(); + let $row = $(this).closest('tr').nextAll('.denyMessageTr').first(); + if (this.value==='deny') $row.show().find('input').focus(); else $row.hide(); }) $('td.rendered').each(function(){ - var h = this.innerHTML; + let h = this.innerHTML; if (h) this.innerHTML = miaou.fmt.mdTextToHtml(h); else $(this).closest('tr').hide() }) diff --git a/src/page-js/chat.js b/src/page-js/chat.js index 004b009d..0b617068 100644 --- a/src/page-js/chat.js +++ b/src/page-js/chat.js @@ -1,9 +1,9 @@ miaou(function(chat, locals){ - var me = locals.me, - room = locals.room; + let me = locals.me; + let room = locals.room; if (room) window.name = 'room_'+room.id; - else location = 'rooms'; + else document.location = 'rooms'; if (room.private) { $('#roomname').addClass('private').attr('title', 'This room is private'); } diff --git a/src/page-js/chat.mob.js b/src/page-js/chat.mob.js index 2f748699..ad5c3d8b 100644 --- a/src/page-js/chat.mob.js +++ b/src/page-js/chat.mob.js @@ -1,16 +1,16 @@ miaou(function(chat, locals, prof){ - var me = locals.me, - room = locals.room; + let me = locals.me; + let room = locals.room; if (!room) { - location = 'rooms'; + document.location = 'rooms'; } if (room.private) { $('#roomname').addClass('private').attr('title', 'This room is private'); } $('#help').click(function(){ window.open('help#Writing_Messages') }); - $('#changeroom').click(function(){ location = 'rooms' }); + $('#changeroom').click(function(){ document.location = 'rooms' }); $('#shortcuts').click(function(){ window.open('help#All_Shortcuts') }); $('#me').text(me.name); $('.tab').click(function(){ @@ -24,7 +24,7 @@ miaou(function(chat, locals, prof){ $('.mpage').eq($(this).index()).toggle(); }); $('#editProfile').click(function(){ - location = 'prefs'; + document.location = 'prefs'; }); // profile opening diff --git a/src/page-js/help.js b/src/page-js/help.js index 99a76945..214eae9b 100644 --- a/src/page-js/help.js +++ b/src/page-js/help.js @@ -1,8 +1,8 @@ $(function(){ - var h2hash; + let h2hash; $('h2, h3').each(function(){ - var hash = $(this).text().replace(/\W+/g, '_'); - if ('#' + hash==location.hash) { + let hash = $(this).text().replace(/\W+/g, '_'); + if ('#' + hash === location.hash) { $('html,body').scrollTop($(this).offset().top); } if (this.tagName==='H2') h2hash = hash; @@ -15,12 +15,12 @@ $(function(){ }); $('#help-summary h3').hide(); $('h2, h3').click(function(){ - var hash = $(this).attr('hash'); + let hash = $(this).attr('hash'); location.hash = '#' + hash; $('html,body').animate({ scrollTop: $('#help-content [hash='+hash+']').offset().top }, 500); - var h2hash = $(this).attr('h2hash'); + let h2hash = $(this).attr('h2hash'); $('#help-summary h3').each(function(){ if ((h2hash===hash && $(this).is(':visible')) || $(this).attr('h2hash')!==h2hash) { $(this).slideUp(); diff --git a/src/page-js/login.js b/src/page-js/login.js index d8401ba6..3666efb7 100644 --- a/src/page-js/login.js +++ b/src/page-js/login.js @@ -1,37 +1,37 @@ miaou(function(locals){ - var m = location.toString().match(/room=(\d+)/), + let m = location.toString().match(/room=(\d+)/), strategies = locals.oauth2Strategies; if (m) { localStorage['login.room'] = m[1]; } else { - delete localStorage['login.room']; + localStorage.removeItem('login.room'); } if ( localStorage['successfulLoginLastTime'] && localStorage['lastUsedStrategy'] && strategies[localStorage['lastUsedStrategy']] ) { - delete localStorage['successfulLoginLastTime']; + localStorage.removeItem('successfulLoginLastTime'); $('#buttons').html('Authentication in progress...'); $('.toRemoveWhenLogin').remove(); - setTimeout(function(){ location = strategies[localStorage['lastUsedStrategy']].url }, 100); + setTimeout(function(){ document.location = strategies[localStorage['lastUsedStrategy']].url }, 100); } else { - var names = { + let names = { google: " Google", stackexchange: " StackOverflow", github: " GitHub", reddit: " reddit" }; - var bubbles = { + let bubbles = { stackexchange: "Warning: only use this if you have an existing StackOverflow account "+ "(not just StackExchange)" }; - for (var key in strategies) { + for (let key in strategies) { (function(key, strategy){ - var $button = $('