From bdc35a343efce619b8e57a6457d654b6aeef8a5f Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 16 Jul 2023 15:32:32 -0700 Subject: [PATCH] refactor: :rotating_light: linting fix --- package.json | 2 +- .../1678426061773-tweak-varchar-length.js | 18 +- packages/backend/native-utils/package.json | 1 + .../src/model/repository/antenna.rs | 2 +- .../native-utils/src/model/schema/antenna.rs | 2 +- .../native-utils/src/model/schema/app.rs | 2 +- packages/backend/native-utils/tests/common.rs | 4 +- .../tests/model/repository/antenna.rs | 10 +- packages/backend/src/const.ts | 5 +- packages/backend/src/misc/download-url.ts | 4 +- packages/client/.eslintrc.json | 7 + packages/client/package.json | 10 +- .../client/src/components/MkAbuseReport.vue | 4 +- .../src/components/MkAbuseReportWindow.vue | 2 +- .../client/src/components/MkAnalogClock.vue | 40 +- .../client/src/components/MkAutocomplete.vue | 18 +- packages/client/src/components/MkButton.vue | 4 +- packages/client/src/components/MkCaptcha.vue | 8 +- .../client/src/components/MkChannelList.vue | 3 +- packages/client/src/components/MkChart.vue | 59 +- .../client/src/components/MkChatPreview.vue | 2 +- .../client/src/components/MkContextMenu.vue | 12 +- .../client/src/components/MkCropperDialog.vue | 10 +- packages/client/src/components/MkCwButton.vue | 2 +- .../src/components/MkDateSeparatedList.vue | 5 +- packages/client/src/components/MkDialog.vue | 16 +- packages/client/src/components/MkDonation.vue | 6 +- .../src/components/MkEmojiPickerDialog.vue | 1 - packages/client/src/components/MkMedia.vue | 4 +- .../client/src/components/MkNoteDetailed.vue | 6 +- packages/client/src/components/MkTab.vue | 2 +- packages/client/src/components/form/input.vue | 6 +- packages/client/src/components/form/radio.vue | 4 +- packages/client/src/components/form/range.vue | 6 +- .../client/src/components/form/select.vue | 12 +- .../client/src/components/form/suspense.vue | 3 +- .../client/src/components/form/switch.vue | 4 +- .../client/src/components/form/textarea.vue | 6 +- .../client/src/components/global/MkAcct.vue | 2 +- .../client/src/components/global/MkAd.vue | 2 +- .../client/src/components/global/MkAvatar.vue | 2 +- .../client/src/components/global/MkEmoji.vue | 2 +- .../global/MkMisskeyFlavoredMarkdown.vue | 4 +- .../src/components/global/MkPageHeader.vue | 20 +- .../client/src/components/global/MkSpacer.vue | 8 +- .../components/global/MkStickyContainer.vue | 9 +- .../client/src/components/global/MkTime.vue | 6 +- .../src/components/global/MkUserName.vue | 2 +- .../src/components/global/RouterView.vue | 14 +- packages/client/src/ui/deck.vue | 10 +- .../client/src/ui/deck/antenna-column.vue | 5 +- .../client/src/ui/deck/channel-column.vue | 5 +- packages/client/src/ui/deck/column-core.vue | 2 +- packages/client/src/ui/deck/column.vue | 26 +- packages/client/src/ui/deck/deck-store.ts | 4 +- packages/client/src/ui/deck/direct-column.vue | 2 +- packages/client/src/ui/deck/list-column.vue | 5 +- packages/client/src/ui/deck/main-column.vue | 10 +- .../client/src/ui/deck/mentions-column.vue | 2 +- .../src/ui/deck/notifications-column.vue | 2 +- packages/client/src/ui/deck/tl-column.vue | 9 +- .../client/src/ui/deck/widgets-column.vue | 2 +- packages/client/src/ui/universal.vue | 9 +- packages/client/src/ui/universal.widgets.vue | 4 +- packages/client/src/ui/visitor.vue | 2 +- packages/client/src/ui/visitor/a.vue | 2 +- packages/client/src/ui/visitor/b.vue | 13 +- packages/client/src/ui/visitor/kanban.vue | 2 +- packages/client/src/ui/zen.vue | 5 +- .../client/src/widgets/activity.chart.vue | 20 +- packages/client/src/widgets/activity.vue | 11 +- packages/client/src/widgets/aiscript.vue | 11 +- packages/client/src/widgets/button.vue | 11 +- packages/client/src/widgets/calendar.vue | 13 +- packages/client/src/widgets/clock.vue | 11 +- packages/client/src/widgets/digital-clock.vue | 11 +- packages/client/src/widgets/federation.vue | 11 +- .../client/src/widgets/instance-cloud.vue | 8 +- packages/client/src/widgets/job-queue.vue | 11 +- packages/client/src/widgets/memo.vue | 11 +- packages/client/src/widgets/notifications.vue | 11 +- packages/client/src/widgets/online-users.vue | 11 +- packages/client/src/widgets/photos.vue | 11 +- packages/client/src/widgets/post-form.vue | 11 +- packages/client/src/widgets/rss-ticker.vue | 11 +- packages/client/src/widgets/rss.vue | 11 +- packages/client/src/widgets/server-info.vue | 7 +- .../src/widgets/server-metric/cpu-mem.vue | 32 +- .../client/src/widgets/server-metric/cpu.vue | 2 +- .../src/widgets/server-metric/index.vue | 11 +- .../src/widgets/server-metric/meilisearch.vue | 12 +- .../client/src/widgets/server-metric/mem.vue | 10 +- .../client/src/widgets/server-metric/net.vue | 32 +- packages/client/src/widgets/slideshow.vue | 11 +- packages/client/src/widgets/timeline.vue | 11 +- packages/client/src/widgets/trends.vue | 11 +- packages/client/src/widgets/unix-clock.vue | 11 +- packages/client/src/widgets/user-list.vue | 15 +- packages/megalodon/package.json | 2 +- packages/megalodon/src/axios.d.ts | 2 +- packages/megalodon/src/cancel.ts | 16 +- packages/megalodon/src/converter.ts | 2 +- packages/megalodon/src/default.ts | 6 +- packages/megalodon/src/entity.ts | 2 +- packages/megalodon/src/filter_context.ts | 14 +- packages/megalodon/src/index.ts | 54 +- packages/megalodon/src/megalodon.ts | 2753 ++++---- packages/megalodon/src/misskey.ts | 5701 +++++++++-------- packages/megalodon/src/notification.ts | 20 +- packages/megalodon/src/oauth.ts | 204 +- packages/megalodon/src/parser.ts | 142 +- packages/megalodon/src/proxy_config.ts | 165 +- packages/megalodon/src/response.ts | 12 +- packages/sw/package.json | 2 +- pnpm-lock.yaml | 1269 +++- rome.json | 4 + 116 files changed, 6537 insertions(+), 4697 deletions(-) create mode 100644 packages/client/.eslintrc.json diff --git a/package.json b/package.json index 818b50ab32..d4460c8788 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "gulp-replace": "1.1.4", "gulp-terser": "2.1.0", "install-peers": "^1.0.4", - "rome": "^12.1.3", + "rome": "^v12.1.3-nightly.f65b0d9", "start-server-and-test": "1.15.2", "typescript": "5.1.6" } diff --git a/packages/backend/migration/1678426061773-tweak-varchar-length.js b/packages/backend/migration/1678426061773-tweak-varchar-length.js index 8833745991..00ddcaebea 100644 --- a/packages/backend/migration/1678426061773-tweak-varchar-length.js +++ b/packages/backend/migration/1678426061773-tweak-varchar-length.js @@ -1,10 +1,16 @@ export class tweakVarcharLength1678426061773 { - name = 'tweakVarcharLength1678426061773' + name = "tweakVarcharLength1678426061773"; - async up(queryRunner) { - await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "smtpUser" TYPE character varying(1024)`, undefined); - await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "smtpPass" TYPE character varying(1024)`, undefined); - } + async up(queryRunner) { + await queryRunner.query( + `ALTER TABLE "meta" ALTER COLUMN "smtpUser" TYPE character varying(1024)`, + undefined, + ); + await queryRunner.query( + `ALTER TABLE "meta" ALTER COLUMN "smtpPass" TYPE character varying(1024)`, + undefined, + ); + } - async down(queryRunner) {} + async down(queryRunner) {} } diff --git a/packages/backend/native-utils/package.json b/packages/backend/native-utils/package.json index 385330d776..962b4bc4c4 100644 --- a/packages/backend/native-utils/package.json +++ b/packages/backend/native-utils/package.json @@ -43,6 +43,7 @@ "universal": "napi universal", "version": "napi version", "format": "cargo fmt --all", + "lint": "cargo clippy --fix", "cargo:test": "pnpm run cargo:unit && pnpm run cargo:integration", "cargo:unit": "cargo test unit_test && cargo test -F napi unit_test", "cargo:integration": "cargo test -F noarray int_test -- --test-threads=1" diff --git a/packages/backend/native-utils/src/model/repository/antenna.rs b/packages/backend/native-utils/src/model/repository/antenna.rs index 7c614b954b..2b761173ea 100644 --- a/packages/backend/native-utils/src/model/repository/antenna.rs +++ b/packages/backend/native-utils/src/model/repository/antenna.rs @@ -46,7 +46,7 @@ impl Repository for antenna::Model { src: self.src.try_into()?, user_list_id: self.user_list_id, user_group_id, - users: self.users.into(), + users: self.users, instances: self.instances.into(), case_sensitive: self.case_sensitive, notify: self.notify, diff --git a/packages/backend/native-utils/src/model/schema/antenna.rs b/packages/backend/native-utils/src/model/schema/antenna.rs index 4ec1e07946..da2c3061b4 100644 --- a/packages/backend/native-utils/src/model/schema/antenna.rs +++ b/packages/backend/native-utils/src/model/schema/antenna.rs @@ -58,7 +58,7 @@ impl TryFrom for super::AntennaSrc { // ---- TODO: could be macro impl Schema for super::Antenna {} -pub static VALIDATOR: Lazy = Lazy::new(|| super::Antenna::validator()); +pub static VALIDATOR: Lazy = Lazy::new(super::Antenna::validator); // ---- cfg_if! { diff --git a/packages/backend/native-utils/src/model/schema/app.rs b/packages/backend/native-utils/src/model/schema/app.rs index 682b82ec07..9b5691154d 100644 --- a/packages/backend/native-utils/src/model/schema/app.rs +++ b/packages/backend/native-utils/src/model/schema/app.rs @@ -91,7 +91,7 @@ pub enum AppPermission { impl Schema for App {} -pub static VALIDATOR: Lazy = Lazy::new(|| App::validator()); +pub static VALIDATOR: Lazy = Lazy::new(App::validator); #[cfg(test)] mod unit_test { diff --git a/packages/backend/native-utils/tests/common.rs b/packages/backend/native-utils/tests/common.rs index 186e862bd5..b134319ca0 100644 --- a/packages/backend/native-utils/tests/common.rs +++ b/packages/backend/native-utils/tests/common.rs @@ -148,8 +148,8 @@ async fn setup_model(db: &DbConn) { let user_model = entity::user::Model { id: user_id.to_owned(), created_at: Utc::now().into(), - username: name.to_lowercase().to_string(), - username_lower: name.to_lowercase().to_string(), + username: name.to_lowercase(), + username_lower: name.to_lowercase(), name: Some(name.to_string()), token: Some(gen_string(16)), is_admin: true, diff --git a/packages/backend/native-utils/tests/model/repository/antenna.rs b/packages/backend/native-utils/tests/model/repository/antenna.rs index 3bda2ca183..80eea67718 100644 --- a/packages/backend/native-utils/tests/model/repository/antenna.rs +++ b/packages/backend/native-utils/tests/model/repository/antenna.rs @@ -43,18 +43,16 @@ mod int_test { keywords: vec![ vec!["foo".to_string(), "bar".to_string()], vec!["foobar".to_string()], - ] - .into(), + ], exclude_keywords: vec![ vec!["abc".to_string()], vec!["def".to_string(), "ghi".to_string()], - ] - .into(), + ], src: schema::AntennaSrc::All, user_list_id: None, user_group_id: None, - users: vec![].into(), - instances: vec![].into(), + users: vec![], + instances: vec![], case_sensitive: true, notify: true, with_replies: false, diff --git a/packages/backend/src/const.ts b/packages/backend/src/const.ts index 49f012c5ea..2a955ee521 100644 --- a/packages/backend/src/const.ts +++ b/packages/backend/src/const.ts @@ -1,5 +1,8 @@ import config from "@/config/index.js"; -import { DB_MAX_NOTE_TEXT_LENGTH, DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { + DB_MAX_NOTE_TEXT_LENGTH, + DB_MAX_IMAGE_COMMENT_LENGTH, +} from "@/misc/hard-limits.js"; export const MAX_NOTE_TEXT_LENGTH = Math.min( config.maxNoteLength ?? 3000, diff --git a/packages/backend/src/misc/download-url.ts b/packages/backend/src/misc/download-url.ts index b96871e72e..e9975f3486 100644 --- a/packages/backend/src/misc/download-url.ts +++ b/packages/backend/src/misc/download-url.ts @@ -21,10 +21,10 @@ export async function downloadUrl(url: string, path: string): Promise { const maxSize = config.maxFileSize || 262144000; const req = got - .stream(url, { + .stream(url, { headers: { "User-Agent": config.userAgent, - "Host": new URL(url).hostname, + Host: new URL(url).hostname, }, timeout: { lookup: timeout, diff --git a/packages/client/.eslintrc.json b/packages/client/.eslintrc.json new file mode 100644 index 0000000000..fd4718003d --- /dev/null +++ b/packages/client/.eslintrc.json @@ -0,0 +1,7 @@ +{ + "extends": ["@eslint-sets/vue3", "@eslint-sets/vue3-ts"], + "plugins": ["file-progress", "prettier"], + "rules": { + "file-progress/activate": 1 + } +} diff --git a/packages/client/package.json b/packages/client/package.json index 95fb9f9b2a..3fe101b811 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -4,11 +4,14 @@ "scripts": { "watch": "pnpm vite build --watch --mode development", "build": "pnpm vite build", - "lint": "pnpm rome check \"src/**/*.{ts,vue}\"", - "format": "pnpm rome format * --write && pnpm prettier --write '**/*.{scss,vue}'" + "lint": "pnpm rome check **/*.ts --apply && pnpm run lint:vue", + "lint:vue": "pnpm paralint --ext .vue --fix '**/*.vue' --cache", + "format": "pnpm rome format * --write && pnpm prettier --write '**/*.{scss,vue}' --cache --cache-strategy metadata" }, "devDependencies": { "@discordapp/twemoji": "14.1.2", + "@eslint-sets/eslint-config-vue3": "^5.6.1", + "@eslint-sets/eslint-config-vue3-ts": "^3.3.0", "@phosphor-icons/web": "^2.0.3", "@rollup/plugin-alias": "3.1.9", "@rollup/plugin-json": "4.1.0", @@ -46,6 +49,8 @@ "date-fns": "2.30.0", "emojilib": "github:thatonecalculator/emojilib", "escape-regexp": "0.0.1", + "eslint-config-prettier": "^8.6.0", + "eslint-plugin-file-progress": "^1.3.0", "eventemitter3": "5.0.1", "fast-blurhash": "^1.1.2", "focus-trap": "^7.5.2", @@ -57,6 +62,7 @@ "katex": "0.16.8", "matter-js": "0.18.0", "mfm-js": "0.23.3", + "paralint": "^1.2.1", "photoswipe": "5.3.8", "prettier": "3.0.0", "prettier-plugin-vue": "1.1.6", diff --git a/packages/client/src/components/MkAbuseReport.vue b/packages/client/src/components/MkAbuseReport.vue index ccb85d7222..f92d10ba77 100644 --- a/packages/client/src/components/MkAbuseReport.vue +++ b/packages/client/src/components/MkAbuseReport.vue @@ -80,11 +80,11 @@ const emit = defineEmits<{ (ev: "resolved", reportId: string): void; }>(); -let forward = $ref(props.report.forwarded); +const forward = $ref(props.report.forwarded); function resolve() { os.apiWithDialog("admin/resolve-abuse-user-report", { - forward: forward, + forward, reportId: props.report.id, }).then(() => { emit("resolved", props.report.id); diff --git a/packages/client/src/components/MkAbuseReportWindow.vue b/packages/client/src/components/MkAbuseReportWindow.vue index 6fdf3b9e0b..fc80cd66f5 100644 --- a/packages/client/src/components/MkAbuseReportWindow.vue +++ b/packages/client/src/components/MkAbuseReportWindow.vue @@ -41,7 +41,7 @@