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) {
this._on_output(message);
}
}
};
/**
* TODOC

View File

@ -54,30 +54,8 @@ function makeJwt(payload) {
id = ssb.createIdentity(':auth');
}
const final_payload = b64url(
base64Encode(
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('.');
const final_payload = b64url(base64Encode(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;
}
@ -141,11 +119,15 @@ function hashPassword(password) {
* @returns TODOC
*/
function noAdministrator() {
return !core.globalSettings ||
return (
!core.globalSettings ||
!core.globalSettings.permissions ||
!Object.keys(core.globalSettings.permissions).some(function(name) {
return core.globalSettings.permissions[name].indexOf("administration") != -1;
});
!Object.keys(core.globalSettings.permissions).some(function (name) {
return (
core.globalSettings.permissions[name].indexOf('administration') != -1
);
})
);
}
/**
@ -207,7 +189,6 @@ function isNameValid(name) {
function handler(request, response) {
// TODO(tasiaiso): split this function
let session = getCookies(request.headers).session;
if (request.uri == "/login") {
let formData = form.decodeForm(request.query);
if (query(request.headers)?.permissions?.authenticated) {
@ -377,4 +358,4 @@ function makeRefresh(credentials) {
}
}
export { handler, query, makeRefresh };
export {handler, query, makeRefresh};

View File

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