Skip to content

Commit 918b5be

Browse files
yangshunclaude
andcommitted
Fix lint and type errors in scripts
Type ranks as Record<string, number> to satisfy index-signature checks, drop the unused locale parameter, unwrap a single-element Promise.all, and prefix top-level async invocations with void. Add @types/lodash-es and a minimal tsconfig.json so type-aware lint resolves @types/node when run on individual files (e.g. via the vp staged pre-commit hook). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fbc985c commit 918b5be

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"tsx": "^4.15.1"
2727
},
2828
"devDependencies": {
29+
"@types/lodash-es": "^4.17.12",
2930
"typescript": "^5.8.2",
3031
"vite-plus": "catalog:"
3132
},

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,4 @@ async function generateAll() {
291291
);
292292
}
293293

294-
generateAll();
294+
void generateAll();

scripts/rank.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { QuestionMetadata } from './types';
55

66
const readFileAsync = util.promisify(fs.readFile);
77

8-
const ranks = {
8+
const ranks: Record<string, number> = {
99
'explain-hoisting': 1,
1010
'what-are-the-differences-between-variables-created-using-let-var-or-const': 2,
1111
'what-is-the-difference-between-double-equal-and-triple-equal': 3,
@@ -58,10 +58,10 @@ const ranks = {
5858
'how-does-javascript-garbage-collection-work': 50,
5959
};
6060

61-
async function rankQuestion(dirName: string, locale: string = 'en-US') {
61+
async function rankQuestion(dirName: string) {
6262
const metadataPath = path.join('./questions', dirName, 'metadata.json');
6363

64-
const [metadataFile] = await Promise.all([readFileAsync(metadataPath)]);
64+
const metadataFile = await readFileAsync(metadataPath);
6565

6666
const metadata: QuestionMetadata = JSON.parse(String(metadataFile));
6767

@@ -94,4 +94,4 @@ async function generate() {
9494
await rankQuestionList(qns);
9595
}
9696

97-
generate();
97+
void generate();

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"esModuleInterop": true,
7+
"resolveJsonModule": true,
8+
"strict": true,
9+
"skipLibCheck": true,
10+
"noEmit": true,
11+
"types": ["node"]
12+
},
13+
"include": ["scripts/**/*.ts", "vite.config.ts"]
14+
}

0 commit comments

Comments
 (0)