Skip to content

Commit 7e10278

Browse files
authored
chore(format): cover all supported source files (#248)
1 parent 4529199 commit 7e10278

132 files changed

Lines changed: 1972 additions & 2930 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# top-most EditorConfig file
2-
root = true
3-
4-
[*]
5-
charset = utf-8
6-
end_of_line = lf
7-
insert_final_newline = true
8-
indent_style = tab
9-
indent_size = 4
10-
tab_width = 4
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = tab
9+
indent_size = 4
10+
tab_width = 4
11+
12+
[*.{yaml,yml}]
13+
indent_style = space
14+
indent_size = 2

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
github: chhoumann
2-
custom: https://www.buymeacoffee.com/chhoumann
2+
custom: https://www.buymeacoffee.com/chhoumann

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
dryRun:
7-
description: 'Dry run (no actual release)'
7+
description: "Dry run (no actual release)"
88
required: false
99
default: false
1010
type: boolean

.oxfmtrc.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"$schema": "./node_modules/oxfmt/configuration_schema.json",
33
"useTabs": true,
4-
"ignorePatterns": []
4+
"ignorePatterns": [],
5+
"overrides": [
6+
{
7+
"files": ["**/*.yaml", "**/*.yml"],
8+
"options": {
9+
"tabWidth": 2,
10+
"useTabs": false
11+
}
12+
}
13+
]
514
}

docs/mkdocs.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ site_name: PodNotes
22
repo_url: https://github.com/chhoumann/podnotes
33
edit_uri: edit/master/docs/docs
44
nav:
5-
- Home: index.md
6-
- Commands: commands.md
7-
- Podcasts: podcasts.md
8-
- 'Local files': local_files.md
9-
- "Import & Export": import_export.md
10-
- Transcripts: transcripts.md
11-
- 'Notes':
12-
- Timestamps: timestamps.md
13-
- Templates: templates.md
14-
- Advanced:
15-
- API: api.md
16-
- Usage with QuickAdd: QuickAdd.md
5+
- Home: index.md
6+
- Commands: commands.md
7+
- Podcasts: podcasts.md
8+
- "Local files": local_files.md
9+
- "Import & Export": import_export.md
10+
- Transcripts: transcripts.md
11+
- "Notes":
12+
- Timestamps: timestamps.md
13+
- Templates: templates.md
14+
- Advanced:
15+
- API: api.md
16+
- Usage with QuickAdd: QuickAdd.md
1717
theme:
18-
name: material
19-
palette:
20-
primary: blue
18+
name: material
19+
palette:
20+
primary: blue

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build": "npm run typecheck && vite build",
1616
"typecheck": "tsc --noEmit",
1717
"lint": "oxlint --deny-warnings src tests/e2e scripts",
18-
"format:check": "oxfmt --check package.json manifest.json tsconfig.json .oxlintrc.json .oxfmtrc.json vite.config.ts vitest.config.ts vitest.e2e.config.ts tests/e2e scripts",
18+
"format:check": "npm run format -- --check",
1919
"version": "node version-bump.mjs && git add manifest.json versions.json",
2020
"semantic-release": "semantic-release",
2121
"test": "npm run check:a11y && vitest",
@@ -27,7 +27,7 @@
2727
"check:a11y": "svelte-check --fail-on-warnings",
2828
"docs:build": "mkdocs build -f docs/mkdocs.yml -d site",
2929
"docs:deploy": "npm run docs:build && wrangler pages deploy docs/site --project-name podnotes --branch master",
30-
"format": "oxfmt package.json manifest.json tsconfig.json .oxlintrc.json .oxfmtrc.json vite.config.ts vitest.config.ts vitest.e2e.config.ts tests/e2e scripts"
30+
"format": "oxfmt src tests scripts .github package.json manifest.json versions.json tsconfig.json .oxlintrc.json .oxfmtrc.json vite.config.ts vitest.config.ts vitest.e2e.config.ts vitest.setup.ts version-bump.mjs wrangler.jsonc orca.yaml docs/mkdocs.yml"
3131
},
3232
"dependencies": {
3333
"fuse.js": "^7.4.2",

src/API/API.test.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,14 @@ describe("API.getPodcastSegmentFormatted", () => {
5454
currentEpisode.set(feedEpisode);
5555
const api = new API();
5656

57-
expect(api.getPodcastSegmentFormatted("HH:mm:ss", 115, 125)).toBe(
58-
"00:01:55-00:02:05",
59-
);
57+
expect(api.getPodcastSegmentFormatted("HH:mm:ss", 115, 125)).toBe("00:01:55-00:02:05");
6058
});
6159

6260
test("links feed episodes with start and end times", () => {
6361
currentEpisode.set(feedEpisode);
6462
const api = new API();
6563

66-
const rendered = api.getPodcastSegmentFormatted(
67-
"HH:mm:ss",
68-
115,
69-
125,
70-
true,
71-
);
64+
const rendered = api.getPodcastSegmentFormatted("HH:mm:ss", 115, 125, true);
7265

7366
expect(rendered).toContain("[00:01:55-00:02:05]");
7467
expect(rendered).toContain("time=115");
@@ -106,9 +99,9 @@ describe("API.getPodcastSegmentFormatted", () => {
10699
expect(api.getPodcastSegmentFormatted("HH:mm:ss", 126, 125, true)).toBe(
107100
"00:02:06-00:02:05",
108101
);
109-
expect(
110-
api.getPodcastSegmentFormatted("HH:mm:ss", 125, Number.NaN, true),
111-
).toBe("00:02:05-00:00:00");
102+
expect(api.getPodcastSegmentFormatted("HH:mm:ss", 125, Number.NaN, true)).toBe(
103+
"00:02:05-00:00:00",
104+
);
112105
});
113106

114107
test("seeking through the public API clears an active playback segment", () => {
@@ -263,12 +256,9 @@ describe("API volume (AP-07)", () => {
263256

264257
describe("API transcript access", () => {
265258
function setTranscriptVault(files: Record<string, string>) {
266-
const createTFile = (path: string): TFile =>
267-
Object.assign(new TFile(), { path });
259+
const createTFile = (path: string): TFile => Object.assign(new TFile(), { path });
268260
const getAbstractFileByPath = vi.fn((path: string) =>
269-
Object.prototype.hasOwnProperty.call(files, path)
270-
? createTFile(path)
271-
: null,
261+
Object.prototype.hasOwnProperty.call(files, path) ? createTFile(path) : null,
272262
);
273263
const read = vi.fn(async (file: TFile) => files[file.path] ?? "");
274264

src/API/API.ts

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
import { get } from "svelte/store";
1717
import encodePodnotesURI from "src/utility/encodePodnotesURI";
1818
import { isLocalFile } from "src/utility/isLocalFile";
19-
import {
20-
formatPodcastSegment,
21-
normalizePodcastSegmentTimes,
22-
} from "src/utility/podcastSegment";
19+
import { formatPodcastSegment, normalizePodcastSegmentTimes } from "src/utility/podcastSegment";
2320
import {
2421
adjustPlaybackRate,
2522
normalizePlaybackRate,
@@ -39,12 +36,8 @@ const normalizeSkipLength = (length: number): number =>
3936
// two-way binds the store onto the media element. Fall back to the current value
4037
// (itself clamped) so a bad write is a no-op rather than corrupting playback.
4138
const clampVolume = (value: number, fallback = 1): number => {
42-
const safeFallback = Number.isFinite(fallback)
43-
? Math.min(1, Math.max(0, fallback))
44-
: 1;
45-
return Number.isFinite(value)
46-
? Math.min(1, Math.max(0, value))
47-
: safeFallback;
39+
const safeFallback = Number.isFinite(fallback) ? Math.min(1, Math.max(0, fallback)) : 1;
40+
return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : safeFallback;
4841
};
4942

5043
export class API implements IAPI {
@@ -96,11 +89,7 @@ export class API implements IAPI {
9689
* @param offsetSeconds Optional offset to subtract from the current playback time.
9790
* @returns
9891
*/
99-
getPodcastTimeFormatted(
100-
format: string,
101-
linkify = false,
102-
offsetSeconds = 0,
103-
): string {
92+
getPodcastTimeFormatted(format: string, linkify = false, offsetSeconds = 0): string {
10493
if (!this.podcast) {
10594
throw new Error("No podcast loaded");
10695
}
@@ -118,11 +107,7 @@ export class API implements IAPI {
118107
return time;
119108
}
120109

121-
const url = encodePodnotesURI(
122-
this.podcast.title,
123-
feedUrl,
124-
adjustedTime,
125-
);
110+
const url = encodePodnotesURI(this.podcast.title, feedUrl, adjustedTime);
126111

127112
return `[${time}](${url.href})`;
128113
}
@@ -139,11 +124,7 @@ export class API implements IAPI {
139124

140125
const segmentTimes = normalizePodcastSegmentTimes(startTime, endTime);
141126
const segment = segmentTimes
142-
? formatPodcastSegment(
143-
segmentTimes.startTime,
144-
segmentTimes.endTime,
145-
format,
146-
)
127+
? formatPodcastSegment(segmentTimes.startTime, segmentTimes.endTime, format)
147128
: formatPodcastSegment(startTime, endTime, format);
148129

149130
if (!linkify || !segmentTimes) return segment;
@@ -174,8 +155,7 @@ export class API implements IAPI {
174155
episode,
175156
pluginInstance.settings.transcript.path,
176157
);
177-
const transcriptFile =
178-
pluginInstance.app.vault.getAbstractFileByPath(transcriptPath);
158+
const transcriptFile = pluginInstance.app.vault.getAbstractFileByPath(transcriptPath);
179159

180160
if (!(transcriptFile instanceof TFile)) {
181161
return null;
@@ -204,18 +184,14 @@ export class API implements IAPI {
204184
}
205185

206186
skipBackward(): void {
207-
const skipBackLen = normalizeSkipLength(
208-
get(plugin).settings.skipBackwardLength,
209-
);
187+
const skipBackLen = normalizeSkipLength(get(plugin).settings.skipBackwardLength);
210188
// Never seek before the start. A cleared settings field (NaN/null) falls
211189
// back to the default rather than corrupting currentTime (PB-02).
212190
this.currentTime = Math.max(0, this.currentTime - skipBackLen);
213191
}
214192

215193
skipForward(): void {
216-
const skipForwardLen = normalizeSkipLength(
217-
get(plugin).settings.skipForwardLength,
218-
);
194+
const skipForwardLen = normalizeSkipLength(get(plugin).settings.skipForwardLength);
219195
const target = this.currentTime + skipForwardLen;
220196
const dur = this.length;
221197
// Clamp just short of the end so an over-skip lands at the end instead of
@@ -224,21 +200,15 @@ export class API implements IAPI {
224200
// not rewind, so keep at least the current time (PB-02 / Codex review #213).
225201
// With an unknown/zero duration (metadata not loaded) leave it unclamped.
226202
this.currentTime =
227-
dur > 0
228-
? Math.max(this.currentTime, Math.min(target, dur - 0.25))
229-
: target;
203+
dur > 0 ? Math.max(this.currentTime, Math.min(target, dur - 0.25)) : target;
230204
}
231205

232206
increasePlaybackRate(): void {
233-
playbackRateStore.update((rate) =>
234-
adjustPlaybackRate(rate, PLAYBACK_RATE_STEP),
235-
);
207+
playbackRateStore.update((rate) => adjustPlaybackRate(rate, PLAYBACK_RATE_STEP));
236208
}
237209

238210
decreasePlaybackRate(): void {
239-
playbackRateStore.update((rate) =>
240-
adjustPlaybackRate(rate, -PLAYBACK_RATE_STEP),
241-
);
211+
playbackRateStore.update((rate) => adjustPlaybackRate(rate, -PLAYBACK_RATE_STEP));
242212
}
243213

244214
resetPlaybackRate(): void {

src/API/IAPI.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Episode } from 'src/types/Episode';
1+
import type { Episode } from "src/types/Episode";
22

33
export interface IAPI {
44
readonly podcast: Episode;
@@ -9,11 +9,7 @@ export interface IAPI {
99
playbackRate: number;
1010
volume: number;
1111

12-
getPodcastTimeFormatted(
13-
format: string,
14-
linkify?: boolean,
15-
offsetSeconds?: number,
16-
): string;
12+
getPodcastTimeFormatted(format: string, linkify?: boolean, offsetSeconds?: number): string;
1713

1814
getPodcastSegmentFormatted(
1915
format: string,
@@ -23,7 +19,7 @@ export interface IAPI {
2319
): string;
2420

2521
getTranscript(episode?: Episode): Promise<string | null>;
26-
22+
2723
start(): void;
2824
stop(): void;
2925
togglePlayback(): void;

0 commit comments

Comments
 (0)