Merge branch 'tasiaiso-prettier'

This commit is contained in:
Cory McWilliams 2024-02-24 11:03:36 -05:00
commit 8e7e0ed490
12 changed files with 272 additions and 221 deletions

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# Add prettier to the project
41024ddb7961b04a5688bbc997cb74de6fab4763

14
.prettierignore Normal file
View File

@ -0,0 +1,14 @@
node_modules
src
deps
.clang-format
# Minified files
**/*.min.css
**/*.min.js
**/leaflet.*
**/commonmark*
**/w3.css
apps/ssb/tribute.esm.js
apps/api/app.js
**/emojis.json

10
.prettierrc.yaml Normal file
View File

@ -0,0 +1,10 @@
trailingComma: 'es5'
useTabs: true
semi: true
singleQuote: true
bracketSpacing: false
# overrides:
# - files: '**/*.json'
# options:
# useTabs: false
# tabWidth: 2

View File

@ -76,7 +76,7 @@ App.prototype.send = function(message) {
if (message && this._on_output) { if (message && this._on_output) {
this._on_output(message); this._on_output(message);
} }
} };
/** /**
* TODOC * TODOC

View File

@ -54,30 +54,8 @@ function makeJwt(payload) {
id = ssb.createIdentity(':auth'); id = ssb.createIdentity(':auth');
} }
const final_payload = b64url( const final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}))));
base64Encode( const jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.');
JSON.stringify(
Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}
)
)
)
);
const jwt = [
b64url(
base64Encode(
JSON.stringify({
alg: 'HS256',
typ: 'JWT'
})
)
),
final_payload,
b64url(
ssb.hmacsha256sign(final_payload, ':auth', id)
)
].join('.');
return jwt; return jwt;
} }
@ -141,11 +119,15 @@ function hashPassword(password) {
* @returns TODOC * @returns TODOC
*/ */
function noAdministrator() { function noAdministrator() {
return !core.globalSettings || return (
!core.globalSettings ||
!core.globalSettings.permissions || !core.globalSettings.permissions ||
!Object.keys(core.globalSettings.permissions).some(function (name) { !Object.keys(core.globalSettings.permissions).some(function (name) {
return core.globalSettings.permissions[name].indexOf("administration") != -1; return (
}); core.globalSettings.permissions[name].indexOf('administration') != -1
);
})
);
} }
/** /**
@ -207,7 +189,6 @@ function isNameValid(name) {
function handler(request, response) { function handler(request, response) {
// TODO(tasiaiso): split this function // TODO(tasiaiso): split this function
let session = getCookies(request.headers).session; let session = getCookies(request.headers).session;
if (request.uri == "/login") { if (request.uri == "/login") {
let formData = form.decodeForm(request.query); let formData = form.decodeForm(request.query);
if (query(request.headers)?.permissions?.authenticated) { if (query(request.headers)?.permissions?.authenticated) {

View File

@ -456,7 +456,7 @@ class TfSparkLineElement extends LitElement {
customElements.define('tf-sparkline', TfSparkLineElement); customElements.define('tf-sparkline', TfSparkLineElement);
// TODOC // TODOC
window.addEventListener("keydown", function(event) { window.addEventListener('keydown', function (event) {
if (event.keyCode == 83 && (event.altKey || event.ctrlKey)) { if (event.keyCode == 83 && (event.altKey || event.ctrlKey)) {
if (editing()) { if (editing()) {
save(); save();
@ -1393,7 +1393,11 @@ async function sourcePretty() {
let formatted = await prettier.format(source, { let formatted = await prettier.format(source, {
parser: 'babel', parser: 'babel',
plugins: [babel, estree], plugins: [babel, estree],
trailingComma: 'es5',
useTabs: true, useTabs: true,
semi: true,
singleQuote: true,
bracketSpacing: false,
}); });
if (source !== formatted) { if (source !== formatted) {
gEditor.dispatch({ gEditor.dispatch({
@ -1407,14 +1411,16 @@ async function sourcePretty() {
} }
// TODOC // TODOC
window.addEventListener("load", function() { window.addEventListener('load', function () {
window.addEventListener("hashchange", hashChange); window.addEventListener('hashchange', hashChange);
window.addEventListener("focus", focus); window.addEventListener('focus', focus);
window.addEventListener("blur", blur); window.addEventListener('blur', blur);
window.addEventListener("message", message, false); window.addEventListener('message', message, false);
window.addEventListener("online", connectSocket); window.addEventListener('online', connectSocket);
document.getElementById("name").value = window.location.pathname; document.getElementById('name').value = window.location.pathname;
document.getElementById('closeEditor').addEventListener('click', () => closeEditor()); document
.getElementById('closeEditor')
.addEventListener('click', () => closeEditor());
document.getElementById('save').addEventListener('click', () => save()); document.getElementById('save').addEventListener('click', () => save());
document.getElementById('icon').addEventListener('click', () => changeIcon()); document.getElementById('icon').addEventListener('click', () => changeIcon());
document.getElementById('delete').addEventListener('click', () => deleteApp()); document.getElementById('delete').addEventListener('click', () => deleteApp());

27
package-lock.json generated Normal file
View File

@ -0,0 +1,27 @@
{
"name": "tildefriends",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tildefriends",
"license": "MIT",
"dependencies": {
"prettier": "^3.2.5"
}
},
"node_modules/prettier": {
"version": "3.2.5",
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
}
}
}

11
package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "tildefriends",
"scripts": {
"prettier": "prettier . --check --cache --write"
},
"author": "Cory McWilliams",
"license": "MIT",
"dependencies": {
"prettier": "^3.2.5"
}
}