Auto-format code (#277)
This commit is contained in:
25
.github/config/dprint.json
vendored
Normal file
25
.github/config/dprint.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://dprint.dev/schemas/v0.json",
|
||||||
|
"projectType": "openSource",
|
||||||
|
"incremental": true,
|
||||||
|
"indentWidth": 2,
|
||||||
|
"typescript": {
|
||||||
|
"lineWidth": 280,
|
||||||
|
"semiColons": "asi",
|
||||||
|
"quoteStyle": "preferDouble",
|
||||||
|
"useBraces": "preferNone",
|
||||||
|
"singleBodyPosition": "nextLine",
|
||||||
|
"arrowFunction.useParentheses": "preferNone",
|
||||||
|
"commentLine.forceSpaceAfterSlashes": false,
|
||||||
|
"taggedTemplate.spaceBeforeLiteral": false,
|
||||||
|
"nextControlFlowPosition": "nextLine"
|
||||||
|
},
|
||||||
|
"includes": ["**/*.{js,mjs}"],
|
||||||
|
"excludes": [
|
||||||
|
"**/node_modules",
|
||||||
|
"**/.github"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"https://plugins.dprint.dev/typescript-0.42.0.wasm"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
"preview": "node .github/preview.mjs",
|
"preview": "node .github/preview.mjs",
|
||||||
"linter": "eslint source/**/*.mjs",
|
"linter": "eslint source/**/*.mjs",
|
||||||
"dev": "nodemon source/app/web/index.mjs -e mjs,css,ejs,json",
|
"dev": "nodemon source/app/web/index.mjs -e mjs,css,ejs,json",
|
||||||
"postinstall": "node node_modules/puppeteer/install.js"
|
"postinstall": "node node_modules/puppeteer/install.js",
|
||||||
|
"fmt": "dprint fmt --config .github/config/dprint.json && eslint source/**/*.mjs --fix"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ rules:
|
|||||||
|
|
||||||
# Prefer using new syntax and features
|
# Prefer using new syntax and features
|
||||||
prefer-regex-literals: error
|
prefer-regex-literals: error
|
||||||
prefer-named-capture-group: error
|
|
||||||
prefer-arrow-callback: error
|
prefer-arrow-callback: error
|
||||||
prefer-destructuring: error
|
prefer-destructuring: error
|
||||||
prefer-numeric-literals: error
|
prefer-numeric-literals: error
|
||||||
@@ -103,15 +102,15 @@ rules:
|
|||||||
no-unsafe-finally: off
|
no-unsafe-finally: off
|
||||||
|
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
# Rules below are really motivated by
|
|
||||||
|
|
||||||
# Code style (general rules)
|
# Code style (general rules)
|
||||||
no-tabs: error
|
no-tabs: error
|
||||||
no-trailing-spaces: error
|
no-trailing-spaces: error
|
||||||
brace-style: [error, stroustrup]
|
brace-style: [error, stroustrup]
|
||||||
comma-dangle: [error, always-multiline]
|
|
||||||
comma-style: error
|
comma-style: error
|
||||||
sort-vars: error
|
sort-vars: error
|
||||||
|
no-async-promise-executor: off
|
||||||
|
no-misleading-character-class: off
|
||||||
|
|
||||||
# Coding style (quoting rules)
|
# Coding style (quoting rules)
|
||||||
quote-props: [error, as-needed, {numbers: true}]
|
quote-props: [error, as-needed, {numbers: true}]
|
||||||
@@ -120,7 +119,6 @@ rules:
|
|||||||
|
|
||||||
# Coding style (comments rules)
|
# Coding style (comments rules)
|
||||||
line-comment-position: error
|
line-comment-position: error
|
||||||
capitalized-comments: error
|
|
||||||
|
|
||||||
# Coding style (spacing rules)
|
# Coding style (spacing rules)
|
||||||
block-spacing: [error, always]
|
block-spacing: [error, always]
|
||||||
@@ -128,14 +126,10 @@ rules:
|
|||||||
func-call-spacing: error
|
func-call-spacing: error
|
||||||
arrow-spacing: error
|
arrow-spacing: error
|
||||||
generator-star-spacing: error
|
generator-star-spacing: error
|
||||||
object-curly-spacing: [error, never]
|
|
||||||
rest-spread-spacing: error
|
rest-spread-spacing: error
|
||||||
key-spacing: [error, {afterColon: false}]
|
|
||||||
computed-property-spacing: error
|
computed-property-spacing: error
|
||||||
switch-colon-spacing: [error, {after: false}]
|
|
||||||
array-bracket-spacing: [error, never]
|
array-bracket-spacing: [error, never]
|
||||||
no-whitespace-before-property: error
|
no-whitespace-before-property: error
|
||||||
space-before-function-paren: [error, never]
|
|
||||||
space-in-parens: error
|
space-in-parens: error
|
||||||
spaced-comment: [error, never]
|
spaced-comment: [error, never]
|
||||||
lines-between-class-members: error
|
lines-between-class-members: error
|
||||||
@@ -148,8 +142,6 @@ rules:
|
|||||||
no-new-func: error
|
no-new-func: error
|
||||||
no-new-wrappers: error
|
no-new-wrappers: error
|
||||||
func-names: [error, never]
|
func-names: [error, never]
|
||||||
function-call-argument-newline: [error, never]
|
|
||||||
function-paren-newline: [error, never]
|
|
||||||
no-extra-parens: [error, functions]
|
no-extra-parens: [error, functions]
|
||||||
arrow-body-style: [error, as-needed]
|
arrow-body-style: [error, as-needed]
|
||||||
arrow-parens: [error, as-needed]
|
arrow-parens: [error, as-needed]
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
import fs from "fs/promises"
|
import fs from "fs/promises"
|
||||||
import paths from "path"
|
import paths from "path"
|
||||||
import sgit from "simple-git"
|
import sgit from "simple-git"
|
||||||
process.on("unhandledRejection", error => { throw error }) //eslint-disable-line max-statements-per-line, brace-style
|
process.on("unhandledRejection", error => {
|
||||||
|
throw error
|
||||||
|
})
|
||||||
|
|
||||||
//Debug message buffer
|
//Debug message buffer
|
||||||
let DEBUG = true
|
let DEBUG = true
|
||||||
|
|||||||
@@ -344,7 +344,7 @@
|
|||||||
//Apply replacements
|
//Apply replacements
|
||||||
for (const [emoji, twemoji] of emojis) {
|
for (const [emoji, twemoji] of emojis) {
|
||||||
if (custom)
|
if (custom)
|
||||||
rendered = rendered.replace(new RegExp(`<metrics[ ]*(?<attributes>[^>]*)>${emoji}</metrics>`, "g"), twemoji.replace(/(<svg class="twemoji" [\s\S]+?)(>)/, "$1 $<attributes> $2")) //eslint-disable-line prefer-named-capture-group
|
rendered = rendered.replace(new RegExp(`<metrics[ ]*(?<attributes>[^>]*)>${emoji}</metrics>`, "g"), twemoji.replace(/(<svg class="twemoji" [\s\S]+?)(>)/, "$1 $<attributes> $2"))
|
||||||
rendered = rendered.replace(new RegExp(emoji, "g"), twemoji)
|
rendered = rendered.replace(new RegExp(emoji, "g"), twemoji)
|
||||||
}
|
}
|
||||||
return rendered
|
return rendered
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# Overrides enforced rules for mocks
|
# Overrides enforced rules for mocks
|
||||||
rules:
|
rules:
|
||||||
max-params: off
|
max-params: off
|
||||||
no-unused-vars: off
|
no-unused-vars: off
|
||||||
prefer-named-capture-group: off
|
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
/**Total extracter */
|
/**Total extracter */
|
||||||
async function total({imports}) {
|
async function total({imports}) {
|
||||||
if (!total.promise) {
|
if (!total.promise) {
|
||||||
total.promise = new Promise(async(solve, reject) => { //eslint-disable-line no-async-promise-executor
|
total.promise = new Promise(async(solve, reject) => {
|
||||||
//Setup browser
|
//Setup browser
|
||||||
console.debug("metrics/compute/plugins > achievements > filling total from github.com/search")
|
console.debug("metrics/compute/plugins > achievements > filling total from github.com/search")
|
||||||
const browser = await imports.puppeteer.launch()
|
const browser = await imports.puppeteer.launch()
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
//Attempt to guess whether tabs or spaces are used in patches
|
//Attempt to guess whether tabs or spaces are used in patches
|
||||||
console.debug(`metrics/compute/${login}/plugins > habits > searching indent style`)
|
console.debug(`metrics/compute/${login}/plugins > habits > searching indent style`)
|
||||||
patches
|
patches
|
||||||
.map(({patch}) => patch.match(/((?:\t)|(?:[ ]{2})) /gm) ?? []) //eslint-disable-line prefer-named-capture-group
|
.map(({patch}) => patch.match(/((?:\t)|(?:[ ]{2})) /gm) ?? [])
|
||||||
.forEach(indent => habits.indents[/^\t/.test(indent) ? "tabs" : "spaces"]++)
|
.forEach(indent => habits.indents[/^\t/.test(indent) ? "tabs" : "spaces"]++)
|
||||||
habits.indents.style = habits.indents.spaces > habits.indents.tabs ? "spaces" : habits.indents.tabs > habits.indents.spaces ? "tabs" : ""
|
habits.indents.style = habits.indents.spaces > habits.indents.tabs ? "spaces" : habits.indents.tabs > habits.indents.spaces ? "tabs" : ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
//Register existing licenses properties
|
//Register existing licenses properties
|
||||||
const licenses = Object.fromEntries((await graphql(queries.licenses())).licenses.map(license => [license.key, license]))
|
const licenses = Object.fromEntries((await graphql(queries.licenses())).licenses.map(license => [license.key, license]))
|
||||||
for (const license of Object.values(licenses))
|
for (const license of Object.values(licenses)) {
|
||||||
|
//dprint-ignore
|
||||||
[...license.limitations, ...license.conditions, ...license.permissions].flat().map(({key, label}) => text[key] = label)
|
[...license.limitations, ...license.conditions, ...license.permissions].flat().map(({key, label}) => text[key] = label)
|
||||||
|
}
|
||||||
colors(licenses)
|
colors(licenses)
|
||||||
|
|
||||||
//Check if licensed exists
|
//Check if licensed exists
|
||||||
|
|||||||
@@ -64,13 +64,13 @@
|
|||||||
//Format text
|
//Format text
|
||||||
console.debug(`metrics/compute/${login}/plugins > tweets > formatting tweet ${tweet.id}`)
|
console.debug(`metrics/compute/${login}/plugins > tweets > formatting tweet ${tweet.id}`)
|
||||||
tweet.createdAt = `${imports.date(tweet.created_at, {timeStyle:"short", timeZone:data.config.timezone?.name})} on ${imports.date(tweet.created_at, {dateStyle:"short", timeZone:data.config.timezone?.name})}`
|
tweet.createdAt = `${imports.date(tweet.created_at, {timeStyle:"short", timeZone:data.config.timezone?.name})} on ${imports.date(tweet.created_at, {dateStyle:"short", timeZone:data.config.timezone?.name})}`
|
||||||
tweet.text = imports.htmlescape( //eslint-disable-line function-paren-newline
|
tweet.text = imports.htmlescape(
|
||||||
//Escape tags
|
//Escape tags
|
||||||
imports.htmlescape(tweet.text, {"<":true, ">":true})
|
imports.htmlescape(tweet.text, {"<":true, ">":true})
|
||||||
//Mentions
|
//Mentions
|
||||||
.replace(new RegExp(`@(${tweet.mentions.join("|")})`, "gi"), '<span class="mention">@$1</span>')
|
.replace(new RegExp(`@(${tweet.mentions.join("|")})`, "gi"), '<span class="mention">@$1</span>')
|
||||||
//Hashtags (this regex comes from the twitter source code)
|
//Hashtags (this regex comes from the twitter source code)
|
||||||
.replace(/(?<!&)[#|#]([a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f]*[a-z_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f][a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f]*)/gi, ' <span class="hashtag">#$1</span> ') //eslint-disable-line no-misleading-character-class, prefer-named-capture-group
|
.replace(/(?<!&)[#|#]([a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f]*[a-z_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f][a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u0750-\u077f\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff\u20000-\u2a6df\u2a700-\u2b73f\u2b740-\u2b81f\u2f800-\u2fa1f]*)/gi, ' <span class="hashtag">#$1</span> ')
|
||||||
//Line breaks
|
//Line breaks
|
||||||
.replace(/\n/g, "<br/>")
|
.replace(/\n/g, "<br/>")
|
||||||
//Links
|
//Links
|
||||||
|
|||||||
Reference in New Issue
Block a user