Skip to content

Commit

Permalink
npm run format (after useTabs: false in .prettierrc)
Browse files Browse the repository at this point in the history
  • Loading branch information
jifalops committed Nov 24, 2024
1 parent 246f897 commit ba51ea9
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 144 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"commands": [
"npx local-cors-proxy --proxyUrl https://dummyjson.com --port 3099"
]
},
}
]
},
{
Expand All @@ -40,15 +40,15 @@
"commands": [
"npm install && npm run test:e2e && npm run preview -- --host"
]
},
}
]
},
{
"splitTerminals": [
{
"name": "bash",
"commands": []
},
}
]
}
],
Expand Down
2 changes: 2 additions & 0 deletions e2e/demo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ import {
test('home page has expected <main>', async ({ page }) => {
await page.goto('/');
await expect(page.locator('main')).toBeVisible();
await page.goto('/');
await expect(page.locator('main')).toBeVisible();
});
102 changes: 51 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
{
"name": "svelte-static",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"obfuscate": "javascript-obfuscator ./build --output ./build",
"test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test"
},
"devDependencies": {
"@iconify/json": "^2.2.273",
"@playwright/test": "^1.45.3",
"@sentry/browser": "^8.40.0",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/eslint": "^9.6.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"javascript-obfuscator": "^4.1.1",
"luxon": "^3.5.0",
"postcss": "^8.4.49",
"postcss-import": "^16.1.0",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.6",
"prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tailwindcss": "^3.4.9",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"unplugin-icons": "^0.20.1",
"vite": "^5.0.3",
"vitest": "^2.0.4"
},
"dependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15"
}
"name": "svelte-static",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"obfuscate": "javascript-obfuscator ./build --output ./build",
"test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test"
},
"devDependencies": {
"@iconify/json": "^2.2.273",
"@playwright/test": "^1.45.3",
"@sentry/browser": "^8.40.0",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/eslint": "^9.6.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"javascript-obfuscator": "^4.1.1",
"luxon": "^3.5.0",
"postcss": "^8.4.49",
"postcss-import": "^16.1.0",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.6",
"prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tailwindcss": "^3.4.9",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"unplugin-icons": "^0.20.1",
"vite": "^5.0.3",
"vitest": "^2.0.4"
},
"dependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15"
}
}
12 changes: 6 additions & 6 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
}

@layer components {
button,
.btn {
@apply inline-block rounded-md px-4 py-2 hover:ring-1 focus:ring-2;
@apply bg-blue-600 text-white;
@apply dark:bg-blue-500;
}
button,
.btn {
@apply inline-block rounded-md px-4 py-2 hover:ring-1 focus:ring-2;
@apply bg-blue-600 text-white;
@apply dark:bg-blue-500;
}
}
4 changes: 2 additions & 2 deletions src/lib/ad_campaign/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** The driven port of the application for reporting events related to ad campaigns. */
export abstract class AdCampaignService {
abstract trackClick(targetId: string): void;
abstract trackConversion(label: string, value?: number): void;
abstract trackClick(targetId: string): void;
abstract trackConversion(label: string, value?: number): void;
}
44 changes: 22 additions & 22 deletions src/lib/ad_campaign/service_google_ads.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { AdCampaignService } from './service';

declare global {
interface Window {
dataLayer: any[];
}
interface Window {
dataLayer: any[];
}
}

/**
* Google Ads (AdWords) adapter for the ad campaign service.
*/
export class AdCampaignServiceGoogleAds extends AdCampaignService {
constructor(gtagId: string) {
super();
const script = document.createElement('script');
script.async = true;
script.src = `https://www.googletagmanager.com/gtag/js?id=${gtagId}`;
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
this.gtag('js', new Date());
this.gtag('config', gtagId);
}
constructor(gtagId: string) {
super();
const script = document.createElement('script');
script.async = true;
script.src = `https://www.googletagmanager.com/gtag/js?id=${gtagId}`;
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
this.gtag('js', new Date());
this.gtag('config', gtagId);
}

private gtag(..._: any[]): void {
window.dataLayer.push(arguments);
}
private gtag(..._: any[]): void {
window.dataLayer.push(arguments);
}

trackClick(targetId: string): void {
this.gtag('event', 'click', { targetId });
}
trackConversion(label: string, value?: number): void {
this.gtag('event', 'conversion', { label, value });
}
trackClick(targetId: string): void {
this.gtag('event', 'click', { targetId });
}
trackConversion(label: string, value?: number): void {
this.gtag('event', 'conversion', { label, value });
}
}
12 changes: 6 additions & 6 deletions src/lib/ad_campaign/service_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { AdCampaignService } from './service';
* Mock adapter for the ad campaign service that logs to the console.
*/
export class AdCampaignServiceMock extends AdCampaignService {
trackClick(targetId: string): void {
log.debug('AdCampaign:', 'click', targetId);
}
trackConversion(label: string, value?: number): void {
log.debug('AdCampaign:', 'conversion', label, value);
}
trackClick(targetId: string): void {
log.debug('AdCampaign:', 'click', targetId);
}
trackConversion(label: string, value?: number): void {
log.debug('AdCampaign:', 'conversion', label, value);
}
}
2 changes: 1 addition & 1 deletion src/lib/ad_display/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** The driven port of the application for loading and showing ads. */
export abstract class AdDisplayService {
abstract loadAd(element: HTMLElement, adSlot: string, format: string): Promise<void>;
abstract loadAd(element: HTMLElement, adSlot: string, format: string): Promise<void>;
}
48 changes: 24 additions & 24 deletions src/lib/ad_display/service_google_adsense.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { AdDisplayService } from './service';

declare global {
interface Window {
adsbygoogle: any[];
}
interface Window {
adsbygoogle: any[];
}
}

/**
* Google AdSense adapter for the ad display service.
*/
export class AdDisplayServiceGoogleAdsense extends AdDisplayService {
private clientId: string;
private clientId: string;

constructor(clientId: string) {
super();
this.clientId = clientId;
window.adsbygoogle = window.adsbygoogle || [];
const script = document.createElement('script');
script.async = true;
script.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`;
script.crossOrigin = 'anonymous';
document.head.appendChild(script);
}
constructor(clientId: string) {
super();
this.clientId = clientId;
window.adsbygoogle = window.adsbygoogle || [];
const script = document.createElement('script');
script.async = true;
script.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${this.clientId}`;
script.crossOrigin = 'anonymous';
document.head.appendChild(script);
}

async loadAd(element: HTMLElement, adSlot: string, format: string = 'auto'): Promise<void> {
window.adsbygoogle.push({
element,
adUnitPath: adSlot,
format: format
});
return new Promise((resolve) => {
element.addEventListener('load', () => resolve());
});
}
async loadAd(element: HTMLElement, adSlot: string, format: string = 'auto'): Promise<void> {
window.adsbygoogle.push({
element,
adUnitPath: adSlot,
format: format
});
return new Promise((resolve) => {
element.addEventListener('load', () => resolve());
});
}
}
10 changes: 5 additions & 5 deletions src/lib/ad_display/service_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { AdDisplayService } from './service';

/** The mock adapter for the ad display service that shows a rectangular placeholder. */
export class AdDisplayServiceMock extends AdDisplayService {
override async loadAd(element: HTMLElement, adSlot: string, format: string): Promise<void> {
element.classList.add('block', 'bg-neutral-500', 'rounded-lg', 'overflow-hidden');
element.innerHTML = `
override async loadAd(element: HTMLElement, adSlot: string, format: string): Promise<void> {
element.classList.add('block', 'bg-neutral-500', 'rounded-lg', 'overflow-hidden');
element.innerHTML = `
<div class="flex items-center justify-center h-full">
<span>Ad Placeholder ${element.offsetWidth}x${element.offsetHeight}</span>
</div>
`;
return Promise.resolve();
}
return Promise.resolve();
}
}
2 changes: 1 addition & 1 deletion src/lib/reporting/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** The driven port of the application for reporting errors to an external service. */
export abstract class ReportingService {
abstract reportError(error: any, message?: string): Promise<void>;
abstract reportError(error: any, message?: string): Promise<void>;
}
6 changes: 3 additions & 3 deletions src/lib/reporting/service_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ReportingService } from './service';
* Mock adapter for the reporting service that logs to the console.
*/
export class ReportingServiceMock extends ReportingService {
override async reportError(error: any, message?: string): Promise<void> {
log.error('Reporting:', message, error);
}
override async reportError(error: any, message?: string): Promise<void> {
log.error('Reporting:', message, error);
}
}
22 changes: 11 additions & 11 deletions src/lib/reporting/service_sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { ReportingService } from './service';
* Sentry adapter for the reporting service.
*/
export class ReportingServiceSentry extends ReportingService {
constructor(dsn: string) {
super();
Sentry.init({ dsn });
}
constructor(dsn: string) {
super();
Sentry.init({ dsn });
}

override async reportError(error: any, message?: string): Promise<void> {
if (message) {
Sentry.captureException(error, { extra: { message: message } });
} else {
Sentry.captureException(error);
}
}
override async reportError(error: any, message?: string): Promise<void> {
if (message) {
Sentry.captureException(error, { extra: { message: message } });
} else {
Sentry.captureException(error);
}
}
}
18 changes: 9 additions & 9 deletions src/lib/telemetry/service_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { TelemetryService } from './service';
* Mock adapter for the telemetry service that logs to the console.
*/
export class TelemetryServiceMock extends TelemetryService {
pageView(path: string): void {
log.debug('Telemetry:', 'page_view', path);
}
pageView(path: string): void {
log.debug('Telemetry:', 'page_view', path);
}

event(name: string, params?: Record<string, any>): void {
log.debug('Telemetry:', 'event', name, params);
}
event(name: string, params?: Record<string, any>): void {
log.debug('Telemetry:', 'event', name, params);
}

timing(name: string, value: number): void {
log.debug('Telemetry:', 'timing_complete', name, value);
}
timing(name: string, value: number): void {
log.debug('Telemetry:', 'timing_complete', name, value);
}
}

0 comments on commit ba51ea9

Please sign in to comment.