Skip to content

Commit

Permalink
refactor: add new eslint rules and apply changes (PreMiD#4946)
Browse files Browse the repository at this point in the history
eslint rules

D

ya yeeet

fix: add setTrayTitle back

ok

refactor: more shit

yeppers

yeppers

trayTitle

yoppers

yeeters

yeet

boop

beep

wtf man

Revert "wtf man"

This reverts commit f2cae0c.

Revert "Revert "wtf man""

This reverts commit 0e31803.

yoinkers

fix: presenceData and other

style: add two prettier rules

refactor: no more !== null

booooop

textContent => value (input elements)

more yeeters

style: prettier fixes

bump no-one-time-vars

fix: a, b, c, d, e, f websites

Update presence.ts

yeetus

feat: add metadata sorting script

refactor: sort metadatas

we made some script which we think works hopefully so!!!!!

apparently we fixed some stuff according to one smart little sexy beast

f

bumpy bumpy boopy i did an oopsie

eslint rules

D

ya yeeet

fix: add setTrayTitle back

ok

refactor: more shit

yeppers

yeppers

trayTitle

yoppers

yeeters

yeet

boop

beep

wtf man

Revert "wtf man"

This reverts commit f2cae0c.

Revert "Revert "wtf man""

This reverts commit 0e31803.

yoinkers

fix: presenceData and other

style: add two prettier rules

refactor: no more !== null

booooop

textContent => value (input elements)

more yeeters

style: prettier fixes

bump no-one-time-vars

fix: a, b, c, d, e, f websites

Update presence.ts

yeetus

feat: add metadata sorting script

refactor: sort metadatas

we made some script which we think works hopefully so!!!!!

apparently we fixed some stuff according to one smart little sexy beast

Update metadata.json

fix more shiz

Update metadata.json

rename

rename

Small fixes for massCompile

Bump linting dependencies

Fix remaining errors

chore: bump the buggiest plugin ever

chore: fixed errors caused by the buggiest package

the buggiest package apparently now has less bugs raisedeyebrow

bumpy bumpy boopy i did an oopsie

Update websites/0-9/4chan/iframe.ts

fix: a buncha shit

refactor: yay

fix: bump more versions

chore: update schemas to 1.6

chore: rename xero

chore: rename xero

chore: bumped schema (PreMiD#5093)

chore: add pr template (PreMiD#5088)

feat(Prydwen Institute): Cover as largeImageKey (PreMiD#5091)

* Update Prydwen Institude presence

* Small fix

* Fix typo

* Small fix

* Small fix

* Change metadata

* Update schema

Co-authored-by: Rhys <64903135+EncryptedDev@users.noreply.github.com>

feat(CSGO Stash): Cover as largeImagekey (PreMiD#5095)

* feat(CSGO Stash): update presence

* Bump version

* Update schema

fix(Udemy): update title selector (PreMiD#5096)

* updated course title selector

* restored missing anchor from udemy title selector

* Version bump Udemy presence

feat(Animu): Artwork as largeImageKey (PreMiD#5092)

* Added simple artwork update

* Update metadata.json

* Revert "Update metadata.json"

This reverts commit 15021e7.

* Update metadata.json

* Update websites/R/Rádio Animu/dist/metadata.json

feat(YouTube): Add thumbnails as image keys (PreMiD#5099)

* feat(YouTube): Add thumbnails as image keys

* feat(YouTube): add thumbnail as a default off option

chore: bumped schema (PreMiD#5093)

chore: add pr template (PreMiD#5088)

feat(Prydwen Institute): Cover as largeImageKey (PreMiD#5091)

* Update Prydwen Institude presence

* Small fix

* Fix typo

* Small fix

* Small fix

* Change metadata

* Update schema

Co-authored-by: Rhys <64903135+EncryptedDev@users.noreply.github.com>

feat(CSGO Stash): Cover as largeImagekey (PreMiD#5095)

* feat(CSGO Stash): update presence

* Bump version

* Update schema

fix(Udemy): update title selector (PreMiD#5096)

* updated course title selector

* restored missing anchor from udemy title selector

* Version bump Udemy presence

feat(Animu): Artwork as largeImageKey (PreMiD#5092)

* Added simple artwork update

* Update metadata.json

* Revert "Update metadata.json"

This reverts commit 15021e7.

* Update metadata.json

* Update websites/R/Rádio Animu/dist/metadata.json

feat(YouTube): Add thumbnails as image keys (PreMiD#5099)

* feat(YouTube): Add thumbnails as image keys

* feat(YouTube): add thumbnail as a default off option

te

Update metadata.json

test

k

Update metadata.json

Co-Authored-By: Rhys <64903135+EncryptedDev@users.noreply.github.com>
Co-Authored-By: Bas950 <bas.van.zanten007@gmail.com>
Co-Authored-By: Slowlife <slowlife1165@gmail.com>
Co-Authored-By: Rodry <38259440+ImRodry@users.noreply.github.com>

Co-authored-by: Bas950 <bas.van.zanten007@gmail.com>
Co-authored-by: Slowlife <slowlife1165@gmail.com>
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 23, 2021
1 parent 252a15d commit e486925
Show file tree
Hide file tree
Showing 1,827 changed files with 26,115 additions and 30,715 deletions.
13 changes: 10 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:eqeqeq-fix/recommended"
"plugin:eqeqeq-fix/recommended",
"plugin:prettier/recommended"
],
"globals": {
"Atomics": "readonly",
Expand Down Expand Up @@ -53,7 +54,13 @@
"@typescript-eslint/no-explicit-any": "error",
"no-eval": "warn",
"no-undefined": "error",
"no-eq-null": "error"
"no-eq-null": "error",
"@typescript-eslint/array-type": ["error", { "default": "array" }],
"no-lonely-if": "error",
"prettier/prettier": "error",
"arrow-body-style": "off",
"prefer-arrow-callback": "off",
"no-one-time-vars/no-one-time-vars": [2, {"ignoredVariables":["browsingTimestamp"]}]
},
"overrides": [
{
Expand All @@ -70,5 +77,5 @@
],
"reportUnusedDisableDirectives": true,
"noInlineConfig": false,
"plugins": ["@typescript-eslint"]
"plugins": ["@typescript-eslint", "prettier", "no-one-time-vars"]
}
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"useTabs": false,
"endOfLine": "lf",
"proseWrap": "always",
"semi": true
"semi": true,
"quoteProps": "as-needed",
"arrowParens": "avoid"
}
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@
"@types/glob": "^7.1.4",
"@types/mongodb": "4.0.7",
"@types/node": "^16.10.2",
"@types/prettier": "^2.4.1",
"@types/prettier": "^2.4.2",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"axios": "^0.24.0",
"chalk": "^4.1.2",
"debug": "^4.3.2",
"enquirer": "^2.3.6",
"eslint": "^7.32.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eqeqeq-fix": "^1.0.3",
"eslint-plugin-no-one-time-vars": "^2.1.1",
"eslint-plugin-prettier": "^4.0.0",
"glob": "^7.2.0",
"jsonschema": "^1.4.0",
"json-to-ast": "^2.1.0",
"jsonschema": "^1.4.0",
"mongodb": "^3.6.9",
"ora": "^6.0.1",
"prettier": "^2.4.1",
"prettier": "^2.5.1",
"semver": "^7.3.5",
"source-map-support": "^0.5.19",
"terser": "^5.9.0",
"typescript": "^4.4.3"
"typescript": "^4.5.3"
}
}
36 changes: 17 additions & 19 deletions util/tools/auto/presenceUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const readFile = (path: string): string =>
emitResult.diagnostics
);

allDiagnostics.forEach((diagnostic) => {
allDiagnostics.forEach(diagnostic => {
if (diagnostic.file) {
const { line, character } =
diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!),
Expand Down Expand Up @@ -145,8 +145,8 @@ const readFile = (path: string): string =>
.find({}, { projection: { _id: 0, name: 1, "metadata.version": 1 } })
.toArray(),
presences: Array<[Metadata, string]> = glob("./{websites,programs}/*/*/")
.filter((pF) => existsSync(`${pF}/dist/metadata.json`))
.map((pF) => {
.filter(pF => existsSync(`${pF}/dist/metadata.json`))
.map(pF => {
const file = readFile(`${pF}/dist/metadata.json`);
if (isValidJSON(file)) {
const data = JSON.parse(file);
Expand All @@ -161,19 +161,19 @@ const readFile = (path: string): string =>
}
}),
newPresences = presences.filter(
(p) => !dbPresences.some((dP) => dP.name === p[0].service)
p => !dbPresences.some(dP => dP.name === p[0].service)
),
deletedPresences = dbPresences.filter(
(dP) => !presences.some((p) => p[0].service === dP.name)
dP => !presences.some(p => p[0].service === dP.name)
),
outdatedPresences = dbPresences
.filter((dP) =>
.filter(dP =>
presences.some(
(p) =>
p =>
dP.name === p[0].service && p[0].version !== dP.metadata.version
)
)
.map((dP) => presences.find((p) => p[0].service === dP.name)),
.map(dP => presences.find(p => p[0].service === dP.name)),
dbDiff = outdatedPresences.concat(newPresences);

if (dbDiff.length > 5) {
Expand All @@ -193,7 +193,7 @@ const readFile = (path: string): string =>
oP: Promise<UpdateWriteOpResult>[] = [];

const compiledPresences = await Promise.all(
dbDiff.map(async (file) => {
dbDiff.map(async file => {
let metadata: customMetadata = file[0];
const path = file[1],
sources = glob(`${path}*.ts`),
Expand Down Expand Up @@ -288,11 +288,11 @@ const readFile = (path: string): string =>
database = client.db(dbname).collection("presences");
}

const bulkNp = compiledPresences.filter((e) =>
newPresences.some((p) => e && e.name === p[0].service)
const bulkNp = compiledPresences.filter(e =>
newPresences.some(p => e && e.name === p[0].service)
),
bulkOp = compiledPresences.filter((e) =>
outdatedPresences.some((p) => e && e.name === p[0].service)
bulkOp = compiledPresences.filter(e =>
outdatedPresences.some(p => e && e.name === p[0].service)
);

if (bulkNp.length > 0) {
Expand All @@ -305,7 +305,7 @@ const readFile = (path: string): string =>
}

if (deletedPresences.length > 0) {
dP = deletedPresences.map((p) => database.deleteOne({ name: p.name }));
dP = deletedPresences.map(p => database.deleteOne({ name: p.name }));
for (const presence of deletedPresences) {
if (!presence || !presence.name) continue;
console.log(
Expand All @@ -315,9 +315,7 @@ const readFile = (path: string): string =>
}

if (bulkOp.length > 0) {
oP = bulkOp.map((p) =>
database.updateOne({ name: p.name }, { $set: p })
);
oP = bulkOp.map(p => database.updateOne({ name: p.name }, { $set: p }));
for (const presence of bulkOp) {
console.log(
`UPD - "${presence.name}" => ${presence.metadata.version}`
Expand All @@ -337,12 +335,12 @@ const readFile = (path: string): string =>

main();

process.on("unhandledRejection", (rejection) => {
process.on("unhandledRejection", rejection => {
console.error(rejection);
process.exit(1);
});

process.on("uncaughtException", (err) => {
process.on("uncaughtException", err => {
console.error(err.stack || err);
process.exit(1);
});
Expand Down
25 changes: 15 additions & 10 deletions util/tools/auto/schemaValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const latestMetadataSchema = async (): Promise<string[]> => {
)
).data as { name: string }[]
)
.filter((c) => c.name.endsWith(".json"))
.map((c) => c.name.match(/\d.\d/g)[0]);
.filter(c => c.name.endsWith(".json"))
.map(c => c.name.match(/\d.\d/g)[0]);
return [
`https://schemas.premid.app/metadata/${versions.at(-1)}`,
versions.at(-1)
Expand Down Expand Up @@ -101,12 +101,17 @@ const latestMetadataSchema = async (): Promise<string[]> => {
oldVersion = presences[0].metadata.version,
invalidLangs: string[] = [];

Object.keys(meta.description).forEach((lang) => {
Object.keys(meta.description).forEach(lang => {
const index = validLangs.findIndex((l: string) => l === lang);
if (index === -1) invalidLangs.push(lang);
});

if (result.valid && !invalidLangs.length && folder === service && isVersionBumped(oldVersion, newVersion)) {
if (
result.valid &&
!invalidLangs.length &&
folder === service &&
isVersionBumped(oldVersion, newVersion)
) {
if (meta.$schema && meta.$schema !== latestSchema)
validatedWithWarnings(
service,
Expand All @@ -122,7 +127,7 @@ const latestMetadataSchema = async (): Promise<string[]> => {
errors.push(
`::error file=${metaFile},line=${getLine(
"version"
)},title=instance.version::The current version (${newVersion}) of the presence has not been bumped. The latest published version is ${oldVersion}`
)},title=instance.version::The current version (${newVersion}) of the presence has not been bumped. The latest published version is ${oldVersion}`
);
}

Expand Down Expand Up @@ -182,32 +187,32 @@ const latestMetadataSchema = async (): Promise<string[]> => {
}) as ObjectNode;

if (value) {
const node = AST.children.find((c) => c.key.value === line).value;
const node = AST.children.find(c => c.key.value === line).value;

switch (node.type) {
case "Literal":
return node.loc.start.line;
case "Object":
return node.children.find((c) => c.key.value === value).loc.start
return node.children.find(c => c.key.value === value).loc.start
.line;
case "Array": {
if (typeof value === "number")
return node.children[value].loc.start.line;
else {
return node.children.find((c) => {
return node.children.find(c => {
switch (c.type) {
case "Literal":
return c.value === value;
case "Object":
return c.children.find((c) => c.key.value === value);
return c.children.find(c => c.key.value === value);
}
}).loc.start.line;
}
}
}
} else
return (
AST.children.find((c) => c.key.value === line)?.loc?.start?.line ?? 0
AST.children.find(c => c.key.value === line)?.loc?.start?.line ?? 0
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions util/tools/auto/syntaxEnforcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { exec } from "child_process";
* @return Promise<string>
*/
function execShellCommand(cmd: string[]) {
return new Promise<string>((resolve) => {
return new Promise<string>(resolve => {
exec(cmd.join(" "), (error, stdout, stderr) => {
if (error) console.warn(error);

Expand Down Expand Up @@ -105,7 +105,7 @@ const readFile = (path: string): string =>
"|-----------------------------------|"
].join("\n")
)
)
);

await execShellCommand(["yarn", "ms"]);

Expand All @@ -130,7 +130,7 @@ const readFile = (path: string): string =>
changedPresenceFiles = listOfChangedFiles
.split("\n")
.filter(
(file) => file.includes("presence.ts") || file.includes("iframe.ts")
file => file.includes("presence.ts") || file.includes("iframe.ts")
);

await increaseSemver(changedPresenceFiles);
Expand Down
4 changes: 2 additions & 2 deletions util/tools/massVer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const read = (path: string): string => readFile(path, { encoding: "utf8" }),
flag: "w"
}),
missingMetadata: string[] = glob("./{websites,programs}/*/*/").filter(
(pF) => !exists(`${pF}/dist/metadata.json`)
pF => !exists(`${pF}/dist/metadata.json`)
),
allmeta: Array<[Metadata, string]> = glob(
"./{websites,programs}/*/*/*/metadata.json"
).map((pF) => {
).map(pF => {
const file = read(pF);
if (isValidJSON(file)) return [JSON.parse(file), pF];
else {
Expand Down
8 changes: 4 additions & 4 deletions util/tools/schemaUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const read = (path: string): string => readFile(path, { encoding: "utf8" }),
)
).data as { name: string }[]
)
.filter((c) => c.name.endsWith(".json"))
.map((c) => c.name.match(/\d.\d/g)[0]);
.filter(c => c.name.endsWith(".json"))
.map(c => c.name.match(/\d.\d/g)[0]);
return `https://schemas.premid.app/metadata/${versions.pop()}`;
},
write = (path: string, code: Metadata): void =>
Expand All @@ -43,11 +43,11 @@ const read = (path: string): string => readFile(path, { encoding: "utf8" }),
}),
main = async () => {
const missingMetadata: string[] = glob("./{websites,programs}/*/*/").filter(
(pF) => !exists(`${pF}/dist/metadata.json`)
pF => !exists(`${pF}/dist/metadata.json`)
),
allmeta: Array<[Metadata, string]> = glob(
"./{websites,programs}/*/*/*/metadata.json"
).map((pF) => {
).map(pF => {
const file = read(pF);
if (isValidJSON(file)) return [JSON.parse(file), pF];
else {
Expand Down
10 changes: 5 additions & 5 deletions util/tools/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const spinnerSettings = {
);
}

readdirSync(src).forEach((letter) => {
readdirSync(`${src}/${letter}/`).forEach(async (presence) => {
readdirSync(src).forEach(letter => {
readdirSync(`${src}/${letter}/`).forEach(async presence => {
const data = JSON.parse(
readFileSync(
`${src}/${letter}/${presence}/dist/metadata.json`,
Expand Down Expand Up @@ -197,7 +197,7 @@ const spinnerSettings = {
)
.catch(() => process.exit());
files = (Array.from(filesMap) as Files).filter(
(f) => f[1].category === category
f => f[1].category === category
);
}
break;
Expand All @@ -211,7 +211,7 @@ const spinnerSettings = {
// @ts-expect-error Limit doesn't exist in Options.
limit: 7,
multiple: true,
choices: (Array.from(filesMap) as Files).map((f) => f[0]),
choices: (Array.from(filesMap) as Files).map(f => f[0]),
footer() {
const selectedPresences = this.selected.length;
return gray(
Expand All @@ -222,7 +222,7 @@ const spinnerSettings = {
])
.then((answer: { selected: string }) => answer.selected)
.catch(() => process.exit());
files = (Array.from(filesMap) as Files).filter((f) =>
files = (Array.from(filesMap) as Files).filter(f =>
selected.includes(f[0])
);
}
Expand Down
Loading

0 comments on commit e486925

Please sign in to comment.