From ed674f2dac37524c5b0a6e17c37246ce457c6bd1 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 5 Jun 2023 17:27:40 -0700 Subject: [PATCH] chore: format --- gulpfile.js | 112 +++++++++++------- package.json | 2 +- packages/backend/package.json | 2 +- packages/backend/src/boot/master.ts | 2 +- .../src/remote/activitypub/db-resolver.ts | 2 - .../remote/activitypub/misc/ld-signature.ts | 2 - .../backend/src/server/api/stream/index.ts | 2 +- .../src/services/drive/image-processor.ts | 4 +- packages/client/src/scripts/katex-macro.ts | 6 +- packages/client/src/scripts/sticky-sidebar.ts | 2 +- packages/sw/package.json | 2 +- pnpm-lock.yaml | 44 +++---- rome.json | 1 + 13 files changed, 106 insertions(+), 77 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f994f0029a..7220d8421a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,66 +2,98 @@ * Gulp tasks */ -const fs = require('fs'); -const gulp = require('gulp'); -const replace = require('gulp-replace'); -const terser = require('gulp-terser'); -const cssnano = require('gulp-cssnano'); +const fs = require("fs"); +const gulp = require("gulp"); +const replace = require("gulp-replace"); +const terser = require("gulp-terser"); +const cssnano = require("gulp-cssnano"); -const locales = require('./locales'); -const meta = require('./package.json'); +const locales = require("./locales"); +const meta = require("./package.json"); -gulp.task('copy:backend:views', () => - gulp.src('./packages/backend/src/server/web/views/**/*').pipe(gulp.dest('./packages/backend/built/server/web/views')) +gulp.task("copy:backend:views", () => + gulp + .src("./packages/backend/src/server/web/views/**/*") + .pipe(gulp.dest("./packages/backend/built/server/web/views")), ); - -gulp.task('copy:backend:custom', () => - gulp.src('./custom/assets/**/*').pipe(gulp.dest('./packages/backend/assets/')) +gulp.task("copy:backend:custom", () => + gulp + .src("./custom/assets/**/*") + .pipe(gulp.dest("./packages/backend/assets/")), ); -gulp.task('copy:client:fonts', () => - gulp.src('./packages/client/node_modules/three/examples/fonts/**/*').pipe(gulp.dest('./built/_client_dist_/fonts/')) +gulp.task("copy:client:fonts", () => + gulp + .src("./packages/client/node_modules/three/examples/fonts/**/*") + .pipe(gulp.dest("./built/_client_dist_/fonts/")), ); -gulp.task('copy:client:locales', cb => { - fs.mkdirSync('./built/_client_dist_/locales', { recursive: true }); +gulp.task("copy:client:locales", (cb) => { + fs.mkdirSync("./built/_client_dist_/locales", { recursive: true }); - const v = { '_version_': meta.version }; + const v = { _version_: meta.version }; for (const [lang, locale] of Object.entries(locales)) { - fs.writeFileSync(`./built/_client_dist_/locales/${lang}.${meta.version}.json`, JSON.stringify({ ...locale, ...v }), 'utf-8'); + fs.writeFileSync( + `./built/_client_dist_/locales/${lang}.${meta.version}.json`, + JSON.stringify({ ...locale, ...v }), + "utf-8", + ); } cb(); }); - -gulp.task('build:backend:script', () => { - return gulp.src(['./packages/backend/src/server/web/boot.js', './packages/backend/src/server/web/bios.js', './packages/backend/src/server/web/cli.js']) - .pipe(replace('LANGS', JSON.stringify(Object.keys(locales)))) - .pipe(terser({ - toplevel: true - })) - .pipe(gulp.dest('./packages/backend/built/server/web/')); +gulp.task("build:backend:script", () => { + return gulp + .src([ + "./packages/backend/src/server/web/boot.js", + "./packages/backend/src/server/web/bios.js", + "./packages/backend/src/server/web/cli.js", + ]) + .pipe(replace("LANGS", JSON.stringify(Object.keys(locales)))) + .pipe( + terser({ + toplevel: true, + }), + ) + .pipe(gulp.dest("./packages/backend/built/server/web/")); }); -gulp.task('build:backend:style', () => { - return gulp.src(['./packages/backend/src/server/web/style.css', './packages/backend/src/server/web/bios.css', './packages/backend/src/server/web/cli.css']) - .pipe(cssnano({ - zindex: false - })) - .pipe(gulp.dest('./packages/backend/built/server/web/')); +gulp.task("build:backend:style", () => { + return gulp + .src([ + "./packages/backend/src/server/web/style.css", + "./packages/backend/src/server/web/bios.css", + "./packages/backend/src/server/web/cli.css", + ]) + .pipe( + cssnano({ + zindex: false, + }), + ) + .pipe(gulp.dest("./packages/backend/built/server/web/")); }); -gulp.task('build', gulp.parallel( - 'copy:client:locales', 'copy:backend:views', 'copy:backend:custom', 'build:backend:script', 'build:backend:style', 'copy:client:fonts' -)); +gulp.task( + "build", + gulp.parallel( + "copy:client:locales", + "copy:backend:views", + "copy:backend:custom", + "build:backend:script", + "build:backend:style", + "copy:client:fonts", + ), +); -gulp.task('default', gulp.task('build')); +gulp.task("default", gulp.task("build")); -gulp.task('watch', () => { - gulp.watch([ - './packages/*/src/**/*', - ], { ignoreInitial: false }, gulp.task('build')); +gulp.task("watch", () => { + gulp.watch( + ["./packages/*/src/**/*"], + { ignoreInitial: false }, + gulp.task("build"), + ); }); diff --git a/package.json b/package.json index 1118cc39d2..a03c5dff1b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "gulp-replace": "1.1.4", "gulp-terser": "2.1.0", "install-peers": "^1.0.4", - "rome": "^11.0.0", + "rome": "^12.1.3", "start-server-and-test": "1.15.2", "typescript": "4.9.4" } diff --git a/packages/backend/package.json b/packages/backend/package.json index 8ad4a46e75..0d7ea1f925 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -18,7 +18,7 @@ "lint": "pnpm rome check \"src/**/*.ts\"", "mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha", "test": "pnpm run mocha", - "format": "pnpm rome format * --write && pnpm rome check --apply-suggested *" + "format": "pnpm rome format * --write && pnpm rome check --apply *" }, "resolutions": { "chokidar": "^3.3.1" diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index df5ad1d67a..17b84c74a5 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -167,7 +167,7 @@ async function connectDb(): Promise { } } -async function spawnWorkers(limit: number = 1) { +async function spawnWorkers(limit = 1) { const workers = Math.min(limit, os.cpus().length); bootLogger.info(`Starting ${workers} worker${workers === 1 ? "" : "s"}...`); await Promise.all([...Array(workers)].map(spawnWorker)); diff --git a/packages/backend/src/remote/activitypub/db-resolver.ts b/packages/backend/src/remote/activitypub/db-resolver.ts index 0a2aec9e85..44ff70c56c 100644 --- a/packages/backend/src/remote/activitypub/db-resolver.ts +++ b/packages/backend/src/remote/activitypub/db-resolver.ts @@ -67,8 +67,6 @@ export function parseUri(value: string | IObject): UriParseResult { } export default class DbResolver { - constructor() {} - /** * AP Note => Misskey Note in DB */ diff --git a/packages/backend/src/remote/activitypub/misc/ld-signature.ts b/packages/backend/src/remote/activitypub/misc/ld-signature.ts index 0a4ec3a539..1fb452c079 100644 --- a/packages/backend/src/remote/activitypub/misc/ld-signature.ts +++ b/packages/backend/src/remote/activitypub/misc/ld-signature.ts @@ -11,8 +11,6 @@ export class LdSignature { public preLoad = true; public loderTimeout = 10 * 1000; - constructor() {} - public async signRsaSignature2017( data: any, privateKey: string, diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index b8482c5686..e268b580f5 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -46,7 +46,7 @@ export default class Connection { private channels: Channel[] = []; private subscribingNotes: Map = new Map(); private cachedNotes: Packed<"Note">[] = []; - private isMastodonCompatible: boolean = false; + private isMastodonCompatible = false; private host: string; private accessToken: string; private currentSubscribe: string[][] = []; diff --git a/packages/backend/src/services/drive/image-processor.ts b/packages/backend/src/services/drive/image-processor.ts index 55869f478f..da5bfee188 100644 --- a/packages/backend/src/services/drive/image-processor.ts +++ b/packages/backend/src/services/drive/image-processor.ts @@ -14,7 +14,7 @@ export async function convertToWebp( path: string, width: number, height: number, - quality: number = 85, + quality = 85, ): Promise { return convertSharpToWebp(await sharp(path), width, height, quality); } @@ -23,7 +23,7 @@ export async function convertSharpToWebp( sharp: sharp.Sharp, width: number, height: number, - quality: number = 85, + quality = 85, ): Promise { const data = await sharp .resize(width, height, { diff --git a/packages/client/src/scripts/katex-macro.ts b/packages/client/src/scripts/katex-macro.ts index 4c176b2962..f91e657da9 100644 --- a/packages/client/src/scripts/katex-macro.ts +++ b/packages/client/src/scripts/katex-macro.ts @@ -14,7 +14,7 @@ function parseSingleKaTeXMacro(src: string): [string, KaTeXMacro] { if (!src.startsWith("\\newcommand") || src.slice(-1) !== "}") return invalid; // current index we are checking (= "\\newcommand".length) - let currentPos: number = 11; + let currentPos = 11; currentPos = skipSpaces(currentPos); // parse {\name}, (\name), or [\name] @@ -61,8 +61,8 @@ function parseSingleKaTeXMacro(src: string): [string, KaTeXMacro] { currentPos = skipSpaces(currentPos); while (currentPos < src.length - 1) { - let numbersignPos: number = -1; - let isEscaped: boolean = false; + let numbersignPos = -1; + let isEscaped = false; for (let i = currentPos; i < src.length - 1; ++i) { if (src[i] !== "\\" && src[i] !== "#") { diff --git a/packages/client/src/scripts/sticky-sidebar.ts b/packages/client/src/scripts/sticky-sidebar.ts index 6602d4a3d5..3c42ecb3b4 100644 --- a/packages/client/src/scripts/sticky-sidebar.ts +++ b/packages/client/src/scripts/sticky-sidebar.ts @@ -7,7 +7,7 @@ export class StickySidebar { private isTop = false; private isBottom = false; private offsetTop: number; - private globalHeaderHeight: number = 59; + private globalHeaderHeight = 59; constructor( container: StickySidebar["container"], diff --git a/packages/sw/package.json b/packages/sw/package.json index 6c052b5cca..f64bbfd0a4 100644 --- a/packages/sw/package.json +++ b/packages/sw/package.json @@ -5,7 +5,7 @@ "build": "webpack", "watch": "pnpm swc src -d built -D -w", "lint": "pnpm rome check \"src/**/*.ts\"", - "format": "pnpm rome format * --write && pnpm rome check --apply-suggested *" + "format": "pnpm rome format * --write && pnpm rome check --apply *" }, "devDependencies": { "@swc/cli": "^0.1.62", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 205059075c..463f4247a6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: specifier: ^1.0.4 version: 1.0.4 rome: - specifier: ^11.0.0 - version: 11.0.0 + specifier: ^12.1.3 + version: 12.1.3 start-server-and-test: specifier: 1.15.2 version: 1.15.2 @@ -2666,48 +2666,48 @@ packages: picomatch: 2.3.1 dev: true - /@rometools/cli-darwin-arm64@11.0.0: - resolution: {integrity: sha512-F3vkdY+s3FLIEnAjSbyHTuIPB88cLpccimW4ecid5I7S6GzGG3iUJI4xT00JhH73K4P/qW20/9r+kH1T9Du8Xg==} + /@rometools/cli-darwin-arm64@12.1.3: + resolution: {integrity: sha512-AmFTUDYjBuEGQp/Wwps+2cqUr+qhR7gyXAUnkL5psCuNCz3807TrUq/ecOoct5MIavGJTH6R4aaSL6+f+VlBEg==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@rometools/cli-darwin-x64@11.0.0: - resolution: {integrity: sha512-X6jhtS6Iml4GOzgNtnLwIp/KXXhSdqeVyfv69m/AHnIzx3gQAjPZ7BPnJLvTCbhe4SKHL+uTZYFSCJpkUUKE6w==} + /@rometools/cli-darwin-x64@12.1.3: + resolution: {integrity: sha512-k8MbWna8q4LRlb005N2X+JS1UQ+s3ZLBBvwk4fP8TBxlAJXUz17jLLu/Fi+7DTTEmMhM84TWj4FDKW+rNar28g==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@rometools/cli-linux-arm64@11.0.0: - resolution: {integrity: sha512-dktTJJlTpmycBZ2TwhJBcAO8ztK8DdevdyZnFFxdYRvtmJgTjIsC2UFayf/SbKew8B8q1IhI0it+D6ihAeIpeg==} + /@rometools/cli-linux-arm64@12.1.3: + resolution: {integrity: sha512-X/uLhJ2/FNA3nu5TiyeNPqiD3OZoFfNfRvw6a3ut0jEREPvEn72NI7WPijH/gxSz55znfQ7UQ6iM4DZumUknJg==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@rometools/cli-linux-x64@11.0.0: - resolution: {integrity: sha512-WVcnXPNdWGUWo0p4NU8YzuthjYR7q+b4vRcjdxtP1DlpphZmSsoC/RSE85nEqRAz8hChcKUansVzOPM8BSsuGA==} + /@rometools/cli-linux-x64@12.1.3: + resolution: {integrity: sha512-csP17q1eWiUXx9z6Jr/JJPibkplyKIwiWPYNzvPCGE8pHlKhwZj3YHRuu7Dm/4EOqx0XFIuqqWZUYm9bkIC8xg==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rometools/cli-win32-arm64@11.0.0: - resolution: {integrity: sha512-tPj6RThQzS7Q45jqQll7NlTYvNcsg/BEP3LYiiazqSh9FAFnMkrV6ewUcMPKWyAfiyLs7jlz4rRvdNRUSygzfQ==} + /@rometools/cli-win32-arm64@12.1.3: + resolution: {integrity: sha512-RymHWeod57EBOJY4P636CgUwYA6BQdkQjh56XKk4pLEHO6X1bFyMet2XL7KlHw5qOTalzuzf5jJqUs+vf3jdXQ==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /@rometools/cli-win32-x64@11.0.0: - resolution: {integrity: sha512-bmBai8WHxYjsGk1+je7ZTfCUCWq30WJI3pQM8pzTA674lfGTZ9ymJoZwTaIMSO4rL5V9mlO6uLunsBKso9VqOg==} + /@rometools/cli-win32-x64@12.1.3: + resolution: {integrity: sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ==} cpu: [x64] os: [win32] requiresBuild: true @@ -13531,18 +13531,18 @@ packages: fsevents: 2.3.2 dev: true - /rome@11.0.0: - resolution: {integrity: sha512-rRo6JOwpMLc3OkeTDRXkrmrDqnxDvZ75GS4f0jLDBNmRgDXWbu0F8eVnJoRn+VbK2AE7vWvhVOMBjnWowcopkQ==} + /rome@12.1.3: + resolution: {integrity: sha512-e+ff72hxDpe/t5/Us7YRBVw3PBET7SeczTQNn6tvrWdrCaAw3qOukQQ+tDCkyFtS4yGsnhjrJbm43ctNbz27Yg==} engines: {node: '>=14.*'} hasBin: true requiresBuild: true optionalDependencies: - '@rometools/cli-darwin-arm64': 11.0.0 - '@rometools/cli-darwin-x64': 11.0.0 - '@rometools/cli-linux-arm64': 11.0.0 - '@rometools/cli-linux-x64': 11.0.0 - '@rometools/cli-win32-arm64': 11.0.0 - '@rometools/cli-win32-x64': 11.0.0 + '@rometools/cli-darwin-arm64': 12.1.3 + '@rometools/cli-darwin-x64': 12.1.3 + '@rometools/cli-linux-arm64': 12.1.3 + '@rometools/cli-linux-x64': 12.1.3 + '@rometools/cli-win32-arm64': 12.1.3 + '@rometools/cli-win32-x64': 12.1.3 dev: true /rss-parser@3.13.0: diff --git a/rome.json b/rome.json index 7a51b60e68..09db5f75e2 100644 --- a/rome.json +++ b/rome.json @@ -16,6 +16,7 @@ "packages/backend/nsfw-model/", "packages/client/src/emojilist.json", "*.md", + "**/tsconfig.json", "*/.yml" ] }