Skip to content

Commit 5f0ad7d

Browse files
committed
style(ui): replace let/var with const for never-reassigned variables
1 parent d19a25a commit 5f0ad7d

9 files changed

Lines changed: 39 additions & 39 deletions

File tree

ui/src/components/domain/activity/Activity.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ export default function Activity({ log }: ActivityProps) {
148148
const formatDiff = (diffTxt: string) => {
149149
if (!diffTxt) return '';
150150

151-
let dmp = new diff_match_patch();
152-
let patch = dmp.patch_fromText(diffTxt);
151+
const dmp = new diff_match_patch();
152+
const patch = dmp.patch_fromText(diffTxt);
153153
if (!patch || patch.length === 0) {
154154
return '<span class="text-muted-foreground">No changes</span>';
155155
}
156156
// Type assertion needed because diff-match-patch types are incomplete
157-
let html = diff_prettyDiffLines((patch[0] as any).diffs);
157+
const html = diff_prettyDiffLines((patch[0] as any).diffs);
158158
return html;
159159
};
160160

ui/src/components/domain/enrichment/EnrichmentRequestsList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ function EnrichmentRequestsList({
208208
);
209209

210210
const errorMsg = (request: EnrichmentRequest) => {
211-
let msgs: string[] = [];
211+
const msgs: string[] = [];
212212
if (request.ignoredCount && request.ignoredCount > 0) {
213213
msgs.push(
214214
`Ignored ${request.ignoredCount} artifact${request.ignoredCount > 1 ? 's' : ''}`,
215215
);
216216
}
217-
let warn_count =
217+
const warn_count =
218218
request.enrichers?.filter((enricher) => enricher.status === 'warning')
219219
.length || 0;
220220
if (warn_count > 0) {
221221
msgs.push(`Warnings in ${warn_count} enricher${warn_count > 1 ? 's' : ''}`);
222222
}
223-
let error_count =
223+
const error_count =
224224
request.enrichers?.filter((enricher) => enricher.status === 'error')
225225
.length || 0;
226226
if (error_count > 0) {

ui/src/components/domain/enrichment/EnrichmentResults.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,20 @@ export default function EnrichmentResults() {
544544
};
545545

546546
const errorMsg = () => {
547-
let msgs: string[] = [];
547+
const msgs: string[] = [];
548548
if (enrichmentDetails?.ignored && enrichmentDetails.ignored.length > 0) {
549549
msgs.push(
550550
`Ignored ${enrichmentDetails.ignored.length} artifact${enrichmentDetails.ignored.length > 1 ? 's' : ''}`,
551551
);
552552
}
553-
let warn_count =
553+
const warn_count =
554554
enrichmentDetails?.enrichers?.filter(
555555
(enricher) => enricher.status === 'warning',
556556
).length || 0;
557557
if (warn_count > 0) {
558558
msgs.push(`Warnings in ${warn_count} enricher${warn_count > 1 ? 's' : ''}`);
559559
}
560-
let error_count =
560+
const error_count =
561561
enrichmentDetails?.enrichers?.filter(
562562
(enricher) => enricher.status === 'error',
563563
).length || 0;

ui/src/components/domain/enrichment/dialogs/EnrichmentRequestDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default function EnrichmentRequestDialog({
171171
};
172172

173173
useEffect(() => {
174-
let entities: { [key: number]: OptimizedEntryResponse } = {};
174+
const entities: { [key: number]: OptimizedEntryResponse } = {};
175175
for (const note of notesList || []) {
176176
for (const entity of note.entities) {
177177
if (selectedNoteIds.has(note.id)) {
@@ -214,7 +214,7 @@ export default function EnrichmentRequestDialog({
214214
// Resolve entities list if provided
215215
let resolvedEntities: number[] | undefined;
216216
if (entitiesList && allEntitiesData) {
217-
let entities = await Promise.resolve(entitiesList);
217+
const entities = await Promise.resolve(entitiesList);
218218
resolvedEntities = entities.map(
219219
(entity) =>
220220
allEntitiesData.find(

ui/src/components/domain/notes/NoteViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export default function NoteViewer() {
281281
const doc = view.state;
282282
let to = doc.selection.main.to;
283283
let from = doc.selection.main.from;
284-
let content = doc.doc.toString();
284+
const content = doc.doc.toString();
285285

286286
if (to === from) {
287287
from = 0;
@@ -321,7 +321,7 @@ export default function NoteViewer() {
321321

322322
let to = view.state.selection.main.to;
323323
let from = view.state.selection.main.from;
324-
let content = view.state.doc.toString();
324+
const content = view.state.doc.toString();
325325

326326
if (to === from) {
327327
from = 0;

ui/src/components/domain/notes/NotesListPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export default function NotesListPage() {
143143
column: string,
144144
value: string | DateRangeFilter,
145145
) => {
146-
let updatedFilters = { ...searchFilters };
146+
const updatedFilters = { ...searchFilters };
147147

148148
if (column === 'createdAt' && typeof value === 'object') {
149149
updatedFilters.created_date_from = value.from || '';

ui/src/utils/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class SubtypeHierarchy {
3232
this.tree = {};
3333
this.pathsMap = {};
3434

35-
for (let path of paths) {
35+
for (const path of paths) {
3636
// Store the original full path
3737
this.pathsMap[path] = true;
3838

ui/src/utils/editor/enhancements.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class CradleEditor {
210210
tries[entryClass.subtype] = new DynamicTrie(
211211
async (x) => {
212212
try {
213-
let result =
213+
const result =
214214
await this._lspApi.lspTrieRetrieve({
215215
type: entryClass.subtype,
216216
prefix: x,
@@ -564,21 +564,21 @@ export class CradleEditor {
564564

565565
const pos = context.pos;
566566
const tree = syntaxTree(context.state);
567-
let node = tree.resolve(pos, -1);
567+
const node = tree.resolve(pos, -1);
568568

569569
let options: Array<{ label: string; type: string; info?: string }> = [];
570-
let from = node.from;
571-
let to = node.to;
570+
const from = node.from;
571+
const to = node.to;
572572

573-
let path = this.getParent(node, 'BlockMapping');
573+
const path = this.getParent(node, 'BlockMapping');
574574
if (path && path.length >= 2 && path.length <= 7) {
575-
let section = path[1];
575+
const section = path[1];
576576
if (section && section.firstChild) {
577-
let sectxt = context.state.doc.sliceString(
577+
const sectxt = context.state.doc.sliceString(
578578
section.firstChild.from,
579579
section.firstChild.to,
580580
);
581-
let parent = node.parent;
581+
const parent = node.parent;
582582
if (sectxt == 'entries' && parent != null) {
583583
if (
584584
parent.name == 'Key' ||
@@ -657,7 +657,7 @@ export class CradleEditor {
657657

658658
const pos = context.pos;
659659
const tree = syntaxTree(context.state);
660-
let node = tree.resolve(pos, -1);
660+
const node = tree.resolve(pos, -1);
661661

662662
let options: Array<{ label: string; type: string }> = [];
663663
let from = node.from;
@@ -935,12 +935,12 @@ export class CradleEditor {
935935
enter: (syntaxNode) => {
936936
const node = syntaxNode.node;
937937
if (node.name === 'CradleLink') {
938-
let typeNode = node.getChildren('CradleLinkType');
939-
let valueNode = node.getChildren('CradleLinkValue');
938+
const typeNode = node.getChildren('CradleLinkType');
939+
const valueNode = node.getChildren('CradleLinkValue');
940940
if (!typeNode || !valueNode) return true;
941941

942-
let type = text.slice(typeNode[0].from, typeNode[0].to);
943-
let value = text.slice(valueNode[0].from, valueNode[0].to);
942+
const type = text.slice(typeNode[0].from, typeNode[0].to);
943+
const value = text.slice(valueNode[0].from, valueNode[0].to);
944944

945945
entries.push({
946946
type,
@@ -953,8 +953,8 @@ export class CradleEditor {
953953
},
954954
});
955955

956-
let artifacts: Array<{ type: string; value: string }> = [];
957-
let entities: Array<{ type: string; value: string }> = [];
956+
const artifacts: Array<{ type: string; value: string }> = [];
957+
const entities: Array<{ type: string; value: string }> = [];
958958
for (const entry of entries) {
959959
if (this.entryClasses?.[entry.type].type === 'entity') {
960960
entities.push(entry);
@@ -994,8 +994,8 @@ export class CradleEditor {
994994
node.name == 'Frontmatter' ||
995995
node.name == 'FrontMatterContent'
996996
) {
997-
let frontmatter = text.slice(node.from, node.to);
998-
let yml = frontmatter
997+
const frontmatter = text.slice(node.from, node.to);
998+
const yml = frontmatter
999999
.substring(3, frontmatter.length - 4)
10001000
.trim();
10011001
try {
@@ -1063,9 +1063,9 @@ export class CradleEditor {
10631063
}
10641064
}
10651065
} catch (e: any) {
1066-
var loc = e.mark;
1067-
var from = loc ? loc.position : 0;
1068-
var to = from;
1066+
const loc = e.mark;
1067+
const from = loc ? loc.position : 0;
1068+
const to = from;
10691069
diagnostics.push({
10701070
from: from,
10711071
to: to,

ui/src/utils/parser/extensions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const LINK_REGEX =
6565
/^(?:~)?\[\[([^:|]+?):((?:\\[[\]|]|[^[\]|])+?)(?:\|((?:\\[[\]|]|[^[\]|])+?))?\]\](?:\((?:(\d{2}:\d{2}\s+)?(\d{2}-\d{2}-\d{4}))\))?/;
6666

6767
export function cradleLinkRule(state: any, silent: boolean): boolean {
68-
let str = state.src.slice(state.pos);
68+
const str = state.src.slice(state.pos);
6969
const match = LINK_REGEX.exec(str);
7070
if (!match) return false;
7171
if (silent) return false;
@@ -131,7 +131,7 @@ export function renderFootnoteRef(token: Token): string {
131131
}
132132

133133
let DownloadLinkPromiseCache: Record<string, Promise<FileDownload>> = {};
134-
let MinioCache: Record<string, FileDownload> = {};
134+
const MinioCache: Record<string, FileDownload> = {};
135135

136136
export function fetchMinioDownloadLink(
137137
fileTransferApi: FileTransferApi,
@@ -173,7 +173,7 @@ export async function resolveMinioLinks(
173173
const fileId = params.get('fileId');
174174
if (!fileId) return;
175175

176-
let cached = MinioCache[fileId];
176+
const cached = MinioCache[fileId];
177177
let presigned: string | undefined = cached?.presignedUrl;
178178
let expiry: number | undefined = cached?.expiresIn;
179179
if (!presigned || Date.now() > (expiry || 0)) {
@@ -312,7 +312,7 @@ export async function parseWithExtensions(
312312

313313
let metadata = {};
314314
try {
315-
let note = matter(mdContent, {
315+
const note = matter(mdContent, {
316316
engines: {
317317
yaml: (data) => {
318318
try {

0 commit comments

Comments
 (0)