Skip to content

Commit 10ec39c

Browse files
Fix lint warnings (#1890)
* Refactor variable names and improve type safety in customizer and build scripts Co-authored-by: randerson <[email protected]> * Don't typecast to any --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent 30ac27a commit 10ec39c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

special-pages/index.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ for (const [pageName, injectNames] of Object.entries(support)) {
8181
errors.push(`${publicDir} does not exist. Each page must have a 'src' directory`);
8282
continue;
8383
}
84-
for (const [injectName, jobs] of Object.entries(injectNames)) {
84+
for (const [injectNameKey, jobs] of Object.entries(injectNames)) {
8585
// output main dir
86-
const buildDir = join(BUILD, injectName);
86+
const buildDir = join(BUILD, injectNameKey);
8787

8888
const pageOutputDirectory = join(buildDir, 'pages', pageName);
8989

@@ -93,14 +93,14 @@ for (const [pageName, injectNames] of Object.entries(support)) {
9393
src: publicDir,
9494
dist: join(publicDir, 'dist'),
9595
dest: pageOutputDirectory,
96-
injectName,
96+
injectName: injectNameKey,
9797
});
9898
}
9999
if (job === 'build-js') {
100100
const outputDir = join(pageOutputDirectory, 'dist');
101101
buildJobs.push({
102102
outputDir,
103-
injectName: /** @type {ImportMeta['injectName']} */ (injectName),
103+
injectName: /** @type {ImportMeta['injectName']} */ (injectNameKey),
104104
pageName,
105105
});
106106
}

special-pages/pages/new-tab/app/customizer/mocks.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,40 @@ export function customizerData() {
119119
};
120120

121121
if (url.searchParams.has('background')) {
122-
const value = url.searchParams.get('background');
123-
if (value && value in values.colors) {
122+
const backgroundParam = url.searchParams.get('background');
123+
if (backgroundParam && backgroundParam in values.colors) {
124124
customizer.background = {
125125
kind: 'color',
126-
value: /** @type {import('../../types/new-tab').PredefinedColor} */ (value),
126+
value: /** @type {import('../../types/new-tab').PredefinedColor} */ (backgroundParam),
127127
};
128-
} else if (value && value in values.gradients) {
128+
} else if (backgroundParam && backgroundParam in values.gradients) {
129129
customizer.background = {
130130
kind: 'gradient',
131-
value: /** @type {import('../../types/new-tab').PredefinedGradient} */ (value),
131+
value: /** @type {import('../../types/new-tab').PredefinedGradient} */ (backgroundParam),
132132
};
133-
} else if (value && value.startsWith('hex:')) {
134-
const hex = value.slice(4);
133+
} else if (backgroundParam && backgroundParam.startsWith('hex:')) {
134+
const hex = backgroundParam.slice(4);
135135
if (hex.length === 6 || hex.length === 8) {
136+
const value = `#${hex.slice(0, 6)}`;
136137
customizer.background = {
137138
kind: 'hex',
138-
value: `#${hex.slice(0, 6)}`,
139+
value,
139140
};
140141
} else {
141142
console.warn('invalid hex values');
142143
}
143-
} else if (value && value.startsWith('userImage:')) {
144-
const image = value.slice(10);
144+
} else if (backgroundParam && backgroundParam.startsWith('userImage:')) {
145+
const image = backgroundParam.slice(10);
145146
if (image in values.userImages) {
147+
const value = values.userImages[image];
146148
customizer.background = {
147149
kind: 'userImage',
148-
value: values.userImages[image],
150+
value,
149151
};
150152
} else {
151153
console.warn('unknown user image');
152154
}
153-
} else if (value && value === 'default') {
155+
} else if (backgroundParam && backgroundParam === 'default') {
154156
customizer.background = { kind: 'default' };
155157
}
156158
}

0 commit comments

Comments
 (0)