Skip to content

Commit 06a9316

Browse files
authored
chore: add linting for camelcase variables (#1098)
1 parent a4b88dc commit 06a9316

Some content is hidden

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

68 files changed

+539
-577
lines changed

docs/docs/en/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
SHOW_ANSWER: "Show Answer",
4949
DAYS_STR_IVL: "${interval} days",
5050
CHECK_ALGORITHM_WIKI:
51-
'For more information, check the <a href="${algo_url}">algorithm implementation</a>.',
51+
'For more information, check the <a href="${algoUrl}">algorithm implementation</a>.',
5252
};
5353
```
5454

@@ -62,7 +62,7 @@ export default {
6262
SHOW_ANSWER: "Onyesha Jibu",
6363
DAYS_STR_IVL: "Siku ${interval}",
6464
CHECK_ALGORITHM_WIKI:
65-
'Kwa habari zaidi, angalia <a href="${algo_url}">utekelezaji wa algorithm</a>.',
65+
'Kwa habari zaidi, angalia <a href="${algoUrl}">utekelezaji wa algorithm</a>.',
6666
};
6767
```
6868

docs/docs/zh/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
SHOW_ANSWER: "Show Answer",
4949
DAYS_STR_IVL: "${interval} days",
5050
CHECK_ALGORITHM_WIKI:
51-
'For more information, check the <a href="${algo_url}">algorithm implementation</a>.',
51+
'For more information, check the <a href="${algoUrl}">algorithm implementation</a>.',
5252
};
5353
```
5454

@@ -62,7 +62,7 @@ export default {
6262
SHOW_ANSWER: "Onyesha Jibu",
6363
DAYS_STR_IVL: "Siku ${interval}",
6464
CHECK_ALGORITHM_WIKI:
65-
'Kwa habari zaidi, angalia <a href="${algo_url}">utekelezaji wa algorithm</a>.',
65+
'Kwa habari zaidi, angalia <a href="${algoUrl}">utekelezaji wa algorithm</a>.',
6666
};
6767
```
6868

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default tseslint.config(
1515
"linebreak-style": 0,
1616
quotes: ["warn", "double", "avoid-escape"],
1717
semi: ["error", "always"],
18+
camelcase: ["error"],
1819
"@typescript-eslint/no-unused-vars": [
1920
"error",
2021
{

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717

1818
// GUI & Obsidian coupled code
1919
"src/core.ts",
20-
"src/sr-file.ts",
20+
"src/file.ts",
2121
"src/gui/",
2222
"src/icons/",
2323
"src/main.ts",
@@ -39,7 +39,7 @@ module.exports = {
3939
global: {
4040
// TODO: Bring coverage back up to 98%+
4141
statements: 93,
42-
branches: 89,
42+
branches: 88,
4343
},
4444
},
4545
};

src/algorithms/base/rep-item-schedule-info.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Moment } from "moment";
22

33
import { TICKS_PER_DAY } from "src/constants";
4-
import { formatDate_YYYY_MM_DD, globalDateProvider } from "src/utils/dates";
4+
import { formatDateYYYYMMDD, globalDateProvider } from "src/utils/dates";
55

66
export abstract class RepItemScheduleInfo {
77
dueDate: Moment;
@@ -18,7 +18,7 @@ export abstract class RepItemScheduleInfo {
1818
}
1919

2020
formatDueDate(): string {
21-
return formatDate_YYYY_MM_DD(this.dueDate);
21+
return formatDateYYYYMMDD(this.dueDate);
2222
}
2323

2424
delayedBeforeReviewDaysInt(): number {

src/algorithms/osr/osr-note-graph.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export class OsrNoteGraph {
4141
}
4242

4343
const targetLinks =
44-
this.vaultNoteLinkInfoFinder.getResolvedTargetLinksForNotePath(path) ||
45-
/* c8 ignore next */ {};
44+
this.vaultNoteLinkInfoFinder.getResolvedTargetLinksForNotePath(path) || {};
4645
for (const targetPath in targetLinks) {
4746
if (this.incomingLinks[targetPath] === undefined) this.incomingLinks[targetPath] = [];
4847

@@ -64,7 +63,7 @@ export class OsrNoteGraph {
6463
linkPGTotal = 0,
6564
totalLinkCount = 0;
6665

67-
for (const statObj of this.incomingLinks[notePath] || /* c8 ignore next */ []) {
66+
for (const statObj of this.incomingLinks[notePath] || []) {
6867
const ease: number = noteEaseList.getEaseByPath(statObj.sourcePath);
6968
if (ease) {
7069
linkTotal += statObj.linkCount * this.pageranks[statObj.sourcePath] * ease;
@@ -74,8 +73,7 @@ export class OsrNoteGraph {
7473
}
7574

7675
const outgoingLinks =
77-
this.vaultNoteLinkInfoFinder.getResolvedTargetLinksForNotePath(notePath) ||
78-
/* c8 ignore next */ {};
76+
this.vaultNoteLinkInfoFinder.getResolvedTargetLinksForNotePath(notePath) || {};
7977
for (const outgoingLink in outgoingLinks) {
8078
const ease: number = noteEaseList.getEaseByPath(outgoingLink);
8179
const linkCount: number = outgoingLinks[outgoingLink];

src/algorithms/osr/rep-item-schedule-info-osr.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info"
44
import { SRSettings } from "src/settings";
55
import { DateUtil, globalDateProvider } from "src/utils/dates";
66

7-
export class RepItemScheduleInfo_Osr extends RepItemScheduleInfo {
7+
export class RepItemScheduleInfoOsr extends RepItemScheduleInfo {
88
// A question can have multiple cards. The schedule info for all sibling cards are formatted together
99
// in a single <!--SR: --> comment, such as:
1010
// <!--SR:!2023-09-02,4,270!2023-09-02,5,270!2023-09-02,6,270!2023-09-02,7,270-->
@@ -34,18 +34,18 @@ export class RepItemScheduleInfo_Osr extends RepItemScheduleInfo {
3434
// We always want the correct schedule format, so we use the dummy due date if there is no schedule for a card
3535
const dateStr: string = this.dueDate
3636
? this.formatDueDate()
37-
: RepItemScheduleInfo_Osr.dummyDueDateForNewCard;
37+
: RepItemScheduleInfoOsr.dummyDueDateForNewCard;
3838
return `!${dateStr},${this.interval},${this.latestEase}`;
3939
}
4040

4141
static get initialInterval(): number {
4242
return 1.0;
4343
}
4444

45-
static getDummyScheduleForNewCard(settings: SRSettings): RepItemScheduleInfo_Osr {
46-
return RepItemScheduleInfo_Osr.fromDueDateStr(
47-
RepItemScheduleInfo_Osr.dummyDueDateForNewCard,
48-
RepItemScheduleInfo_Osr.initialInterval,
45+
static getDummyScheduleForNewCard(settings: SRSettings): RepItemScheduleInfoOsr {
46+
return RepItemScheduleInfoOsr.fromDueDateStr(
47+
RepItemScheduleInfoOsr.dummyDueDateForNewCard,
48+
RepItemScheduleInfoOsr.initialInterval,
4949
settings.baseEase,
5050
);
5151
}
@@ -57,6 +57,6 @@ export class RepItemScheduleInfo_Osr extends RepItemScheduleInfo {
5757
delayedBeforeReviewTicks: number | null = null,
5858
) {
5959
const dueDate: Moment = DateUtil.dateStrToMoment(dueDateStr);
60-
return new RepItemScheduleInfo_Osr(dueDate, interval, ease, delayedBeforeReviewTicks);
60+
return new RepItemScheduleInfoOsr(dueDate, interval, ease, delayedBeforeReviewTicks);
6161
}
6262
}

src/algorithms/osr/srs-algorithm-osr.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info"
55
import { ReviewResponse } from "src/algorithms/base/repetition-item";
66
import { osrSchedule } from "src/algorithms/osr/note-scheduling";
77
import { NoteLinkStat, OsrNoteGraph } from "src/algorithms/osr/osr-note-graph";
8-
import { RepItemScheduleInfo_Osr } from "src/algorithms/osr/rep-item-schedule-info-osr";
8+
import { RepItemScheduleInfoOsr } from "src/algorithms/osr/rep-item-schedule-info-osr";
99
import { DueDateHistogram } from "src/due-date-histogram";
1010
import { Note } from "src/note";
1111
import { INoteEaseList, NoteEaseList } from "src/note-ease-list";
1212
import { Question } from "src/question";
1313
import { SRSettings } from "src/settings";
1414
import { globalDateProvider } from "src/utils/dates";
1515

16-
export class SrsAlgorithm_Osr implements ISrsAlgorithm {
16+
export class SrsAlgorithmOsr implements ISrsAlgorithm {
1717
private settings: SRSettings;
1818
private noteEaseList: INoteEaseList;
1919

@@ -47,18 +47,17 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
4747
: linkContribution * this.settings.baseEase);
4848

4949
// add note's average flashcard ease if available
50-
/* c8 ignore next 3 */
5150
if (this.noteEaseList.hasEaseForPath(notePath)) {
5251
ease = (ease + this.noteEaseList.getEaseByPath(notePath)) / 2;
5352
}
5453

5554
// Don't know the due date until we know the calculated interval
5655
const dueDate: Moment = null;
57-
const interval: number = SrsAlgorithm_Osr.initialInterval;
56+
const interval: number = SrsAlgorithmOsr.initialInterval;
5857
ease = Math.round(ease);
59-
const temp: RepItemScheduleInfo_Osr = new RepItemScheduleInfo_Osr(dueDate, interval, ease);
58+
const temp: RepItemScheduleInfoOsr = new RepItemScheduleInfoOsr(dueDate, interval, ease);
6059

61-
const result: RepItemScheduleInfo_Osr = this.calcSchedule(
60+
const result: RepItemScheduleInfoOsr = this.calcSchedule(
6261
temp,
6362
response,
6463
dueDateNoteHistogram,
@@ -72,7 +71,7 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
7271
noteOnLoadedNote(path: string, note: Note, noteEase: number): void {
7372
let flashcardsInNoteAvgEase: number = null;
7473
if (note) {
75-
flashcardsInNoteAvgEase = SrsAlgorithm_Osr.calculateFlashcardAvgEase(
74+
flashcardsInNoteAvgEase = SrsAlgorithmOsr.calculateFlashcardAvgEase(
7675
note.questionList,
7776
this.settings,
7877
);
@@ -122,8 +121,8 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
122121
response: ReviewResponse,
123122
dueDateNoteHistogram: DueDateHistogram,
124123
): RepItemScheduleInfo {
125-
const noteScheduleOsr: RepItemScheduleInfo_Osr = noteSchedule as RepItemScheduleInfo_Osr;
126-
const temp: RepItemScheduleInfo_Osr = this.calcSchedule(
124+
const noteScheduleOsr: RepItemScheduleInfoOsr = noteSchedule as RepItemScheduleInfoOsr;
125+
const temp: RepItemScheduleInfoOsr = this.calcSchedule(
127126
noteScheduleOsr,
128127
response,
129128
dueDateNoteHistogram,
@@ -133,14 +132,14 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
133132

134133
const dueDate: Moment = moment(globalDateProvider.today.add(interval, "d"));
135134
this.noteEaseList.setEaseForPath(notePath, ease);
136-
return new RepItemScheduleInfo_Osr(dueDate, interval, ease);
135+
return new RepItemScheduleInfoOsr(dueDate, interval, ease);
137136
}
138137

139138
private calcSchedule(
140-
schedule: RepItemScheduleInfo_Osr,
139+
schedule: RepItemScheduleInfoOsr,
141140
response: ReviewResponse,
142141
dueDateHistogram: DueDateHistogram,
143-
): RepItemScheduleInfo_Osr {
142+
): RepItemScheduleInfoOsr {
144143
const temp: Record<string, number> = osrSchedule(
145144
response,
146145
schedule.interval,
@@ -150,32 +149,31 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
150149
dueDateHistogram,
151150
);
152151

153-
return new RepItemScheduleInfo_Osr(globalDateProvider.today, temp.interval, temp.ease);
152+
return new RepItemScheduleInfoOsr(globalDateProvider.today, temp.interval, temp.ease);
154153
}
155154

156155
cardGetResetSchedule(): RepItemScheduleInfo {
157-
const interval = SrsAlgorithm_Osr.initialInterval;
156+
const interval = SrsAlgorithmOsr.initialInterval;
158157
const ease = this.settings.baseEase;
159158
const dueDate = globalDateProvider.today.add(interval, "d");
160-
return new RepItemScheduleInfo_Osr(dueDate, interval, ease);
159+
return new RepItemScheduleInfoOsr(dueDate, interval, ease);
161160
}
162161

163162
cardGetNewSchedule(
164163
response: ReviewResponse,
165164
notePath: string,
166165
dueDateFlashcardHistogram: DueDateHistogram,
167166
): RepItemScheduleInfo {
168-
let initial_ease: number = this.settings.baseEase;
169-
/* c8 ignore next 3 */
167+
let initialEase: number = this.settings.baseEase;
170168
if (this.noteEaseList.hasEaseForPath(notePath)) {
171-
initial_ease = Math.round(this.noteEaseList.getEaseByPath(notePath));
169+
initialEase = Math.round(this.noteEaseList.getEaseByPath(notePath));
172170
}
173171
const delayBeforeReview = 0;
174172

175173
const schedObj: Record<string, number> = osrSchedule(
176174
response,
177-
SrsAlgorithm_Osr.initialInterval,
178-
initial_ease,
175+
SrsAlgorithmOsr.initialInterval,
176+
initialEase,
179177
delayBeforeReview,
180178
this.settings,
181179
dueDateFlashcardHistogram,
@@ -184,15 +182,15 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
184182
const interval = schedObj.interval;
185183
const ease = schedObj.ease;
186184
const dueDate = globalDateProvider.today.add(interval, "d");
187-
return new RepItemScheduleInfo_Osr(dueDate, interval, ease, delayBeforeReview);
185+
return new RepItemScheduleInfoOsr(dueDate, interval, ease, delayBeforeReview);
188186
}
189187

190188
cardCalcUpdatedSchedule(
191189
response: ReviewResponse,
192190
cardSchedule: RepItemScheduleInfo,
193191
dueDateFlashcardHistogram: DueDateHistogram,
194192
): RepItemScheduleInfo {
195-
const cardScheduleOsr: RepItemScheduleInfo_Osr = cardSchedule as RepItemScheduleInfo_Osr;
193+
const cardScheduleOsr: RepItemScheduleInfoOsr = cardSchedule as RepItemScheduleInfoOsr;
196194
const schedObj: Record<string, number> = osrSchedule(
197195
response,
198196
cardScheduleOsr.interval,
@@ -205,6 +203,6 @@ export class SrsAlgorithm_Osr implements ISrsAlgorithm {
205203
const ease = schedObj.ease;
206204
const dueDate = globalDateProvider.today.add(interval, "d");
207205
const delayBeforeReview = 0;
208-
return new RepItemScheduleInfo_Osr(dueDate, interval, ease, delayBeforeReview);
206+
return new RepItemScheduleInfoOsr(dueDate, interval, ease, delayBeforeReview);
209207
}
210208
}

src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { DataStoreAlgorithm } from "src/data-store-algorithm/data-store-algorith
99
import { Deck, DeckTreeFilter } from "src/deck";
1010
import { DeckTreeStatsCalculator } from "src/deck-tree-stats-calculator";
1111
import { CardDueDateHistogram, NoteDueDateHistogram } from "src/due-date-histogram";
12+
import { ISRFile, SrTFile } from "src/file";
1213
import { FlashcardReviewMode } from "src/flashcard-review-sequencer";
1314
import { Note } from "src/note";
1415
import { NoteEaseList } from "src/note-ease-list";
1516
import { NoteFileLoader } from "src/note-file-loader";
1617
import { NoteReviewQueue } from "src/note-review-queue";
1718
import { QuestionPostponementList } from "src/question-postponement-list";
1819
import { SettingsUtil, SRSettings } from "src/settings";
19-
import { ISRFile, SrTFile } from "src/sr-file";
2020
import { Stats } from "src/stats";
2121
import { TopicPath } from "src/topic-path";
2222
import { globalDateProvider } from "src/utils/dates";

src/data-store-algorithm/data-store-in-note-algorithm-osr.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Moment } from "moment";
22
import moment from "moment";
33

44
import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info";
5-
import { RepItemScheduleInfo_Osr } from "src/algorithms/osr/rep-item-schedule-info-osr";
5+
import { RepItemScheduleInfoOsr } from "src/algorithms/osr/rep-item-schedule-info-osr";
66
import { Card } from "src/card";
77
import {
88
ALLOWED_DATE_FORMATS,
@@ -12,18 +12,16 @@ import {
1212
YAML_FRONT_MATTER_REGEX,
1313
} from "src/constants";
1414
import { IDataStoreAlgorithm } from "src/data-store-algorithm/idata-store-algorithm";
15+
import { ISRFile } from "src/file";
1516
import { Question } from "src/question";
1617
import { SRSettings } from "src/settings";
17-
import { ISRFile } from "src/sr-file";
18-
import { formatDate_YYYY_MM_DD } from "src/utils/dates";
18+
import { formatDateYYYYMMDD } from "src/utils/dates";
1919

20-
//
2120
// Algorithm: The original OSR algorithm
2221
// (RZ: Perhaps not the original algorithm, but the only one available in 2023/early 2024)
2322
//
2423
// Data Store: With data stored in the note's markdown file
25-
//
26-
export class DataStoreInNote_AlgorithmOsr implements IDataStoreAlgorithm {
24+
export class DataStoreInNoteAlgorithmOsr implements IDataStoreAlgorithm {
2725
private settings: SRSettings;
2826

2927
constructor(settings: SRSettings) {
@@ -43,16 +41,16 @@ export class DataStoreInNote_AlgorithmOsr implements IDataStoreAlgorithm {
4341
const dueDate: Moment = moment(frontmatter.get("sr-due"), ALLOWED_DATE_FORMATS);
4442
const interval: number = parseFloat(frontmatter.get("sr-interval"));
4543
const ease: number = parseFloat(frontmatter.get("sr-ease"));
46-
result = new RepItemScheduleInfo_Osr(dueDate, interval, ease);
44+
result = new RepItemScheduleInfoOsr(dueDate, interval, ease);
4745
}
4846
return result;
4947
}
5048

5149
async noteSetSchedule(note: ISRFile, repItemScheduleInfo: RepItemScheduleInfo): Promise<void> {
5250
let fileText: string = await note.read();
5351

54-
const schedInfo: RepItemScheduleInfo_Osr = repItemScheduleInfo as RepItemScheduleInfo_Osr;
55-
const dueString: string = formatDate_YYYY_MM_DD(schedInfo.dueDate);
52+
const schedInfo: RepItemScheduleInfoOsr = repItemScheduleInfo as RepItemScheduleInfoOsr;
53+
const dueString: string = formatDateYYYYMMDD(schedInfo.dueDate);
5654
const interval: number = schedInfo.interval;
5755
const ease: number = schedInfo.latestEase;
5856

@@ -96,13 +94,13 @@ export class DataStoreInNote_AlgorithmOsr implements IDataStoreAlgorithm {
9694
formatCardSchedule(card: Card) {
9795
let result: string;
9896
if (card.hasSchedule) {
99-
const schedule = card.scheduleInfo as RepItemScheduleInfo_Osr;
97+
const schedule = card.scheduleInfo as RepItemScheduleInfoOsr;
10098
const dateStr = schedule.dueDate
101-
? formatDate_YYYY_MM_DD(schedule.dueDate)
102-
: RepItemScheduleInfo_Osr.dummyDueDateForNewCard;
99+
? formatDateYYYYMMDD(schedule.dueDate)
100+
: RepItemScheduleInfoOsr.dummyDueDateForNewCard;
103101
result = `!${dateStr},${schedule.interval},${schedule.latestEase}`;
104102
} else {
105-
result = `!${RepItemScheduleInfo_Osr.dummyDueDateForNewCard},${RepItemScheduleInfo_Osr.initialInterval},${this.settings.baseEase}`;
103+
result = `!${RepItemScheduleInfoOsr.dummyDueDateForNewCard},${RepItemScheduleInfoOsr.initialInterval},${this.settings.baseEase}`;
106104
}
107105
return result;
108106
}

0 commit comments

Comments
 (0)