Skip to content

Commit 7600846

Browse files
authored
chore: fix more lint errors. (#580)
Somehow #579 was merged by Graphite without passing CI. The fixes are in this PR.
1 parent e37a723 commit 7600846

17 files changed

Lines changed: 50 additions & 38 deletions

File tree

packages/cli/build.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async function buildNapiBinding() {
111111
}
112112

113113
async function buildCli() {
114-
const tsconfig = readJsonConfigFile(join(projectDir, 'tsconfig.json'), sys.readFile);
114+
const tsconfig = readJsonConfigFile(join(projectDir, 'tsconfig.json'), sys.readFile.bind(sys));
115115

116116
const { options: initialOptions } = parseJsonSourceFileConfigFileContent(
117117
tsconfig,
@@ -544,7 +544,7 @@ async function createConditionalShim(
544544
importResult.default = `./dist/test/${shimBaseName}.js`;
545545
}
546546

547-
(result as Record<string, unknown>).import = importResult;
547+
result.import = importResult;
548548
}
549549
}
550550

@@ -555,7 +555,7 @@ async function createConditionalShim(
555555
if (typeof requireValue === 'string') {
556556
const cjsPath = join(shimDir, `${baseFileName}.cjs`);
557557
await writeFile(cjsPath, `module.exports = require('${testImportSpecifier}');\n`);
558-
(result as Record<string, unknown>).require = `./dist/test/${shimBaseName}.cjs`;
558+
result.require = `./dist/test/${shimBaseName}.cjs`;
559559
} else if (typeof requireValue === 'object' && requireValue !== null) {
560560
const requireResult: Record<string, string> = {};
561561

@@ -575,7 +575,7 @@ async function createConditionalShim(
575575
requireResult.default = `./dist/test/${shimBaseName}.cjs`;
576576
}
577577

578-
(result as Record<string, unknown>).require = requireResult;
578+
result.require = requireResult;
579579
}
580580
}
581581

packages/cli/src/pack-bin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@ export async function runCLI(): Promise<void> {
121121
if (module.enableCompileCache) {
122122
module.enableCompileCache();
123123
}
124-
runCLI();
124+
125+
await runCLI();

packages/core/build-support/find-create-require.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function findCreateRequireInStaticImports(
164164
if (!node.init || node.init.type !== 'CallExpression') {
165165
return;
166166
}
167-
const call = node.init as CallExpression;
167+
const call = node.init;
168168
if (call.callee.type === 'Identifier' && call.callee.name === createRequireLocalName) {
169169
if (node.id.type === 'Identifier') {
170170
requireVarName = node.id.name;
@@ -207,7 +207,7 @@ function isGetBuiltinModuleCall(expr: Expression): boolean {
207207
if (expr.type !== 'CallExpression') {
208208
return false;
209209
}
210-
const call = expr as CallExpression;
210+
const call = expr;
211211

212212
// Check callee is a member expression with property `getBuiltinModule`
213213
if (call.callee.type !== 'MemberExpression' || call.callee.computed) {
@@ -251,7 +251,7 @@ function findCreateRequireInGlobalModule(
251251
return;
252252
}
253253

254-
const call = node.init as CallExpression;
254+
const call = node.init;
255255

256256
// Check if callee is a MemberExpression with property `createRequire`
257257
if (call.callee.type !== 'MemberExpression' || call.callee.computed) {

packages/global/src/create/bin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
438438
rewriteMonorepo(workspaceInfo);
439439
await runViteInstall(fullPath, options.interactive);
440440
prompts.outro(`✔ Created ${accent(projectDir)}!`);
441-
log(`${styleText('bold', 'Next steps:')}`);
441+
log(styleText('bold', 'Next steps:'));
442442
log(` ${accent(`cd ${projectDir}`)}`);
443443
log(` ${accent(`vp dev ${InitialMonorepoAppDir}`)}`);
444444
return;
@@ -562,7 +562,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
562562
}
563563

564564
function showNextSteps(projectDir: string, isMonorepo: boolean) {
565-
log(`${styleText('bold', 'Next steps:')}`);
565+
log(styleText('bold', 'Next steps:'));
566566
if (isMonorepo) {
567567
log(` ${accent(`vp dev ${projectDir}`)}`);
568568
} else {

packages/global/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ if (args[0] === 'help' && args[1]) {
1111
const command = args[0];
1212

1313
if (command === 'create') {
14-
import('./create/bin.js');
14+
await import('./create/bin.js');
1515
} else if (command === 'migrate') {
16-
import('./migration/bin.js');
16+
await import('./migration/bin.js');
1717
} else if (command === '--version' || command === '-V') {
18-
import('./version.js');
18+
await import('./version.js');
1919
} else {
2020
// Delegate all other commands to local CLI
21-
import('./local/bin.js');
21+
await import('./local/bin.js');
2222
}

packages/global/src/local/bin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ if (!localCliMetadata) {
7474
prompts.outro(`Using local Vite+ CLI`);
7575
}
7676

77-
// delegate to local CLI
78-
import(pathToFileURL(join(localCliMetadata.path, 'dist', 'bin.js')).href);
77+
await import(pathToFileURL(join(localCliMetadata.path, 'dist', 'bin.js')).href);

packages/global/src/migration/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function parseArgs() {
8080
const nonInteractive = parsed['non-interactive'] ?? parsed.nonInteractive;
8181
const interactive = nonInteractive ? false : parsed.interactive;
8282

83-
let projectPath = parsed._[0] as string;
83+
let projectPath = parsed._[0];
8484
if (projectPath) {
8585
projectPath = path.resolve(process.cwd(), projectPath);
8686
} else {

packages/global/src/utils/terminal.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,18 @@ function gradient(count: number, startRgb: RGB, endRgb: RGB) {
6363
}
6464

6565
function colorize(text: string, colors: Array<RGB>) {
66-
const chars = [...text];
67-
if (chars.length === 0) {
66+
if (text.length === 0) {
6867
return '';
6968
}
7069

71-
const denom = Math.max(chars.length - 1, 1);
70+
const denom = Math.max(text.length - 1, 1);
7271
const maxIdx = colors.length - 1;
7372

7473
let out = '';
75-
for (let i = 0; i < chars.length; i++) {
74+
for (let i = 0; i < text.length; i++) {
7675
const idx = Math.round((i / denom) * maxIdx);
7776
const [r, g, b] = colors[idx];
78-
out += fgRgb(r, g, b) + chars[i];
77+
out += fgRgb(r, g, b) + text[i];
7978
}
8079
return out + RESET;
8180
}
@@ -213,10 +212,7 @@ export async function getVitePlusHeader() {
213212
return `VITE+ - ${textA}${textB}`;
214213
}
215214

216-
return `${styleText(
217-
'bold',
218-
`VITE+ - ${textA}${colorize(textB, await getGradientColors(textB))}`,
219-
)}`;
215+
return styleText('bold', `VITE+ - ${textA}${colorize(textB, await getGradientColors(textB))}`);
220216
}
221217

222218
export function log(message: string) {

packages/global/src/utils/yaml.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import fs from 'node:fs';
22

3-
import { type Document, type ParsedNode, parseDocument, parse as parseYaml, Scalar } from 'yaml';
3+
import { type Document, parseDocument, parse as parseYaml, Scalar } from 'yaml';
44

55
export function readYamlFile<T = Record<string, unknown>>(file: string): T {
66
const content = fs.readFileSync(file, 'utf-8');
77
return parseYaml(content) as T;
88
}
99

10-
export type YamlDocument = Document.Parsed<ParsedNode, true>;
10+
export type YamlDocument = Document.Parsed;
1111

1212
export function editYamlFile(file: string, callback: (doc: YamlDocument) => void) {
1313
const content = fs.readFileSync(file, 'utf-8');

packages/global/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ export async function printVersion(cwd: string) {
180180
}
181181
}
182182

183-
printVersion(process.cwd());
183+
await printVersion(process.cwd());

0 commit comments

Comments
 (0)