Fix linting errors and add development tooling#11
Conversation
- Fix no-new-array lint error in scanner.ts by using Array.from instead - Add eslint-disable comments for intentional unused variables in test fixtures - Add typecheck script using tsc --noEmit - Expand .gitignore with standard entries (coverage, logs, env files, OS artifacts)
There was a problem hiding this comment.
Pull request overview
This PR focuses on resolving linting issues and improving developer tooling for the TypeScript codebase, including adding a dedicated type-check command and tightening generated-file ignores.
Changes:
- Replace
new Array(len)instripCommentsto satisfy linting (no-new-array). - Silence intentional
no-unused-varsviolations in test fixtures viaeslint-disable-next-line. - Add
typecheckscript (tsc --noEmit) and expand.gitignorefor common generated artifacts.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Consolidates coverage exclude configuration formatting. |
| src/scanner.ts | Updates result buffer initialization in stripComments to address lint rule. |
| src/tests/fixtures/strings/entry.ts | Suppresses unused-vars warnings for fixture-only constants. |
| src/tests/fixtures/mixed/entry.ts | Suppresses unused-vars warnings for fixture-only imports/expressions. |
| src/tests/fixtures/externals/local.ts | Suppresses unused-vars warning for intentionally unused import. |
| src/tests/fixtures/externals/entry.ts | Suppresses unused-vars warnings for intentionally unused external imports. |
| package.json | Adds typecheck script for tsc --noEmit. |
| .gitignore | Ignores common build, coverage, log, and env artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| export function stripComments(code: string): string { | ||
| const len = code.length; | ||
| const result: string[] = new Array(len); | ||
| const result: string[] = Array.from<string>({ length: len }); |
There was a problem hiding this comment.
Array.from({ length: len }) eagerly creates a dense array of len undefined values, which adds an extra O(n) initialization pass and more memory churn compared to the previous sparse new Array(len). Since result is fully assigned in the loop anyway, consider keeping the array sparse without using the Array constructor (e.g., initialize as [] and set result.length = len) to preserve performance while satisfying no-new-array.
| const result: string[] = Array.from<string>({ length: len }); | |
| const result: string[] = []; | |
| result.length = len; |
Summary
no-new-arraylint error in scanner.ts by usingArray.frominstead ofnew Array()eslint-disable-next-linecommentstypecheckscript usingtsc --noEmitfor TypeScript validationTest plan
npm run lintnpm run testnpm run typecheck