From eaa72aa1c39b91ba34654ba4a32eb2cb51d1738c Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Wed, 8 Oct 2025 11:23:52 +0000 Subject: [PATCH] fix: resolve all linting errors and dependency conflicts - Update @types/node from ^18.15.0 to ^20.19.0 to resolve Vite 7.1.9 compatibility - Remove unused imports in capacitor-platform-service-clean-integration.ts - Replace non-null assertions with optional chaining for safer code - Add explicit return types to all async functions and Vue component methods - Replace console.log statements with comments for better code quality - Fix unused parameters by prefixing with underscore - Change Promise to Promise for better type safety - All 31 linting errors resolved, build now passes cleanly The plugin is now ready for integration with crowd-funder-for-time-pwa project with clean TypeScript compilation and zero linting warnings. --- ...itor-platform-service-clean-integration.ts | 24 ++- .../daily-notification-timesafari-setup.ts | 63 ++++---- package-lock.json | 146 +++++++++--------- package.json | 2 +- 4 files changed, 114 insertions(+), 121 deletions(-) diff --git a/examples/capacitor-platform-service-clean-integration.ts b/examples/capacitor-platform-service-clean-integration.ts index f698d5e..1d5ad02 100644 --- a/examples/capacitor-platform-service-clean-integration.ts +++ b/examples/capacitor-platform-service-clean-integration.ts @@ -14,26 +14,16 @@ // EXISTING TIMESAFARI PWA CODE (unchanged) // ================================================= -import { Filesystem, Directory, Encoding } from "@capacitor/filesystem"; -import { - Camera, - CameraResultType, - CameraSource, - CameraDirection, -} from "@capacitor/camera"; +import { CameraDirection } from "@capacitor/camera"; import { Capacitor } from "@capacitor/core"; -import { Share } from "@capacitor/share"; import { SQLiteConnection, SQLiteDBConnection, CapacitorSQLite, - DBSQLiteValues, } from "@capacitor-community/sqlite"; -import { runMigrations } from "@/db-sql/migration"; import { QueryExecResult } from "@/interfaces/database"; import { - ImageResult, PlatformService, PlatformCapabilities, } from "../PlatformService"; @@ -104,7 +94,7 @@ export class CapacitorPlatformService implements PlatformService { private initialized = false; private initializationPromise: Promise | null = null; private operationQueue: Array = []; - private isProcessingQueue: boolean = false; + private isProcessingQueue = false; // ================================================= // NEW PROPERTIES FOR DAILYNOTIFICATION PLUGIN @@ -413,12 +403,16 @@ export class CapacitorPlatformService implements PlatformService { try { // Use plugin's enhanced fetching with same interface as existing TimeSafari code - const starredProjectChanges = await this.integrationService!.getStarredProjectsWithChanges( + const starredProjectChanges = await this.integrationService?.getStarredProjectsWithChanges( currentActiveDid, settings.starredPlanHandleIds, settings.lastAckedStarredPlanChangesJwtId ); + if (!starredProjectChanges) { + return { data: [], hitLimit: false }; + } + // Enhanced logging (optional) logger.log("[CapacitorPlatformService] Starred projects loaded successfully:", { count: starredProjectChanges.data.length, @@ -500,14 +494,14 @@ export class CapacitorPlatformService implements PlatformService { // Return existing TimeSafari storage adapter return { // Use existing TimeSafari storage patterns - store: async (key: string, value: unknown) => { + store: async (key: string, value: unknown): Promise => { await this.dbExec( "INSERT OR REPLACE INTO temp (id, data) VALUES (?, ?)", [key, JSON.stringify(value)] ); }, - retrieve: async (key: string) => { + retrieve: async (key: string): Promise => { const result = await this.dbQuery( "SELECT data FROM temp WHERE id = ?", [key] diff --git a/examples/daily-notification-timesafari-setup.ts b/examples/daily-notification-timesafari-setup.ts index 5858046..38db69b 100644 --- a/examples/daily-notification-timesafari-setup.ts +++ b/examples/daily-notification-timesafari-setup.ts @@ -30,12 +30,12 @@ interface StarredProjectsResponse { // Your existing TimeSafari PWA class structure class TimeSafariHomeView { // Your existing properties - activeDid: string = ''; + activeDid = ''; starredPlanHandleIds: string[] = []; - lastAckedStarredPlanChangesJwtId: string = ''; - numNewStarredProjectChanges: number = 0; - newStarredProjectChangesHitLimit: boolean = false; - apiServer: string = 'https://endorser.ch'; + lastAckedStarredPlanChangesJwtId = ''; + numNewStarredProjectChanges = 0; + newStarredProjectChangesHitLimit = false; + apiServer = 'https://endorser.ch'; axios: AxiosInstance; // Plugin integration @@ -51,7 +51,7 @@ class TimeSafariHomeView { */ async setupDailyNotification(): Promise { try { - console.log('Setting up DailyNotification for TimeSafari PWA...'); + // Setup DailyNotification for TimeSafari PWA // Step 1: Configure the DailyNotification plugin await DailyNotification.configure({ @@ -214,7 +214,7 @@ class TimeSafariHomeView { channel: 'timesafari_community_updates' }); - console.log('DailyNotification setup completed successfully!'); + // DailyNotification setup completed successfully } catch (error) { console.error('Failed to setup DailyNotification:', error); @@ -232,22 +232,24 @@ class TimeSafariHomeView { if (this.activeDid && this.starredPlanHandleIds.length > 0) { try { // Use plugin's enhanced fetching with same interface as your existing code - const starredProjectChanges = await this.integrationService!.getStarredProjectsWithChanges( + const starredProjectChanges = await this.integrationService?.getStarredProjectsWithChanges( this.activeDid, this.starredPlanHandleIds, this.lastAckedStarredPlanChangesJwtId ); + if (!starredProjectChanges) { + this.numNewStarredProjectChanges = 0; + this.newStarredProjectChangesHitLimit = false; + return; + } + // Same handling as your existing code this.numNewStarredProjectChanges = starredProjectChanges.data.length; this.newStarredProjectChangesHitLimit = starredProjectChanges.hitLimit; // Enhanced logging (optional) - console.log('Starred projects loaded successfully:', { - count: this.numNewStarredProjectChanges, - hitLimit: this.newStarredProjectChangesHitLimit, - planIds: this.starredPlanHandleIds.length - }); + // Starred projects loaded successfully } catch (error) { // Same error handling as your existing code @@ -273,10 +275,7 @@ class TimeSafariHomeView { this.updateStarredProjectsUI(data); // Enhanced logging (optional) - console.log('Starred projects success callback:', { - count: data.data.length, - hitLimit: data.hitLimit - }); + // Starred projects success callback } async handleStarredProjectsError(error: Error): Promise { @@ -293,17 +292,17 @@ class TimeSafariHomeView { }); } - async handleStarredProjectsComplete(result: unknown): Promise { + async handleStarredProjectsComplete(_result: unknown): Promise { // Handle completion - console.log('Starred projects fetch completed:', result); + // Starred projects fetch completed } /** * Your existing methods (unchanged) */ - private updateStarredProjectsUI(data: StarredProjectsResponse): void { + private updateStarredProjectsUI(_data: StarredProjectsResponse): void { // Your existing UI update logic - console.log('Updating UI with starred projects data:', data); + // Updating UI with starred projects data } private getTimeSafariStorageAdapter(): unknown { @@ -320,10 +319,10 @@ export async function setupDailyNotificationForTimeSafari( activeDid: string, starredPlanHandleIds: string[], lastAckedJwtId: string, - apiServer: string = 'https://endorser.ch' + apiServer = 'https://endorser.ch' ): Promise { - console.log('Setting up DailyNotification for TimeSafari PWA...'); + // Setting up DailyNotification for TimeSafari PWA // Create your existing HomeView instance const homeView = new TimeSafariHomeView(axiosInstance); @@ -340,14 +339,14 @@ export async function setupDailyNotificationForTimeSafari( // Test the enhanced method await homeView.loadNewStarredProjectChanges(); - console.log('DailyNotification setup completed successfully!'); + // DailyNotification setup completed successfully return homeView; } // Vue.js component integration example export const TimeSafariDailyNotificationMixin = { - data() { + data(): Record { return { // Your existing data activeDid: '', @@ -362,13 +361,13 @@ export const TimeSafariDailyNotificationMixin = { }; }, - async mounted() { + async mounted(): Promise { // Setup DailyNotification when component mounts await this.setupDailyNotification(); }, methods: { - async setupDailyNotification() { + async setupDailyNotification(): Promise { try { // Configure DailyNotification plugin await DailyNotification.configure({ @@ -415,7 +414,7 @@ export const TimeSafariDailyNotificationMixin = { }, // Your existing methods (enhanced) - async loadNewStarredProjectChanges() { + async loadNewStarredProjectChanges(): Promise { if (this.activeDid && this.starredPlanHandleIds.length > 0) { try { const starredProjectChanges = await this.integrationService.getStarredProjectsWithChanges( @@ -438,24 +437,24 @@ export const TimeSafariDailyNotificationMixin = { } }, - handleStarredProjectsSuccess(data: StarredProjectsResponse) { + handleStarredProjectsSuccess(data: StarredProjectsResponse): void { this.numNewStarredProjectChanges = data.data.length; this.newStarredProjectChangesHitLimit = data.hitLimit; this.updateStarredProjectsUI(data); }, - handleStarredProjectsError(error: Error) { + handleStarredProjectsError(error: Error): void { console.warn('[HomeView] Failed to load starred project changes:', error); this.numNewStarredProjectChanges = 0; this.newStarredProjectChangesHitLimit = false; }, // Your existing methods - updateStarredProjectsUI(data: StarredProjectsResponse) { + updateStarredProjectsUI(_data: StarredProjectsResponse): void { // Your existing UI update logic }, - getTimeSafariStorageAdapter() { + getTimeSafariStorageAdapter(): unknown { // Your existing storage adapter return {}; } diff --git a/package-lock.json b/package-lock.json index 6bf602c..e970a1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@capacitor/ios": "^6.2.1", "@types/jest": "^29.5.0", "@types/jsdom": "^21.1.7", - "@types/node": "^18.15.0", + "@types/node": "^20.19.0", "@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/parser": "^5.57.0", "eslint": "^8.37.0", @@ -1915,19 +1915,6 @@ "node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0" } }, - "node_modules/@jest/environment-jsdom-abstract/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/@jest/environment-jsdom-abstract/node_modules/pretty-format": { "version": "30.0.5", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.5.tgz", @@ -2304,6 +2291,19 @@ "node": ">= 8.0.0" } }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.52.4", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.4.tgz", @@ -2817,13 +2817,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "18.19.84", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.84.tgz", - "integrity": "sha512-ACYy2HGcZPHxEeWTqowTF7dhXN+JU1o7Gr4b41klnn6pj2LD6rsiGqSZojMdk1Jh2ys3m76ap+ae1vvE4+5+vg==", + "version": "20.19.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.19.tgz", + "integrity": "sha512-pb1Uqj5WJP7wrcbLU7Ru4QtA0+3kAXrkutGiD26wUKzSMgNNaPARTUDQmElUXp64kh3cWdou3Q0C7qwwxqSFmg==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.21.0" } }, "node_modules/@types/normalize-package-data": { @@ -3249,6 +3249,19 @@ "node": ">= 8" } }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -3488,9 +3501,9 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { @@ -5088,9 +5101,9 @@ } }, "node_modules/filelist/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -5587,9 +5600,9 @@ } }, "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -6644,19 +6657,6 @@ "node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0" } }, - "node_modules/jest-environment-jsdom/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/jest-environment-jsdom/node_modules/pretty-format": { "version": "30.0.5", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.0.5.tgz", @@ -6994,6 +6994,19 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-util/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-validate": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", @@ -8409,6 +8422,19 @@ "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -8938,13 +8964,13 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", "engines": { - "node": ">=8.6" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" @@ -10274,19 +10300,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/tldts": { "version": "6.1.86", "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", @@ -10544,9 +10557,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" }, @@ -10745,19 +10758,6 @@ } } }, - "node_modules/vite/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/vite/node_modules/rollup": { "version": "4.52.4", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.4.tgz", diff --git a/package.json b/package.json index c6f3b66..8920935 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@capacitor/ios": "^6.2.1", "@types/jest": "^29.5.0", "@types/jsdom": "^21.1.7", - "@types/node": "^18.15.0", + "@types/node": "^20.19.0", "@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/parser": "^5.57.0", "eslint": "^8.37.0",