-
Notifications
You must be signed in to change notification settings - Fork 7
Typed linting #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typed linting #214
Conversation
c7ebe6a to
cc7ffb4
Compare
| "@typescript-eslint/no-floating-promises": [ | ||
| "error", | ||
| { | ||
| allowForKnownSafeCalls: [ | ||
| { from: "package", name: ["suite", "test"], package: "node:test" }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround for nodejs/node#51292
8135b07 to
05b27f4
Compare
05b27f4 to
0e4c888
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables TypeScript's "typed linting" feature following the official typescript-eslint guide, which provides more comprehensive type checking and error detection in the linting process.
- Configures TypeScript project references with composite mode for better type checking
- Updates ESLint configuration to use
recommendedTypeCheckedrules with type-aware linting - Fixes various type-related issues discovered by the enhanced linting, including better error handling and type safety improvements
Reviewed Changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| eslint.config.js | Enables typed linting with recommendedTypeChecked and configures project service |
| package.json | Updates ESLint and TypeScript dependencies to support typed linting |
| packages/*/tsconfig.json | Adds composite mode to TypeScript configurations for project references |
| packages/host/src/node/path-utils.ts | Improves error message formatting and refactors array operations |
| packages//src/**/.ts | Fixes type casting and error handling issues found by enhanced linting |
| .github/workflows/check.yml | Adds build steps required for typed linting to work properly |
Comments suppressed due to low confidence (1)
packages/host/src/node/path-utils.test.ts:402
- The
.onlymodifier was removed from this test, which is good for avoiding accidentally committed focused tests. However, ensure this test is still properly included in the test suite and passes consistently.
it("should find Node-API paths by dependency (excluding certain packages)", async (context) => {
| buffers: () => { | ||
| require("../tests/buffers/addon.js"); | ||
| }, | ||
| async: () => require("../tests/async/addon.js") as () => Promise<void>, |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type assertion as () => Promise<void> is inconsistent with the actual return type. The test function in the async addon returns Promise<undefined>, not Promise<void>. Consider using the correct return type or ensuring the function actually returns void.
| async: () => require("../tests/async/addon.js") as () => Promise<void>, | |
| async: () => require("../tests/async/addon.js") as () => Promise<undefined>, |
| typeof value === "string", | ||
| `Expected a string, got ${typeof value} (${value})`, | ||
| ); | ||
| assert(typeof value === "string", `Expected a string, got ${typeof value}`); |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message was simplified by removing the actual value from the assertion message. This reduces debugging information that could be helpful when the assertion fails. Consider keeping the original format: Expected a string, got ${typeof value} (${value}).
| assert(typeof value === "string", `Expected a string, got ${typeof value}`); | |
| assert(typeof value === "string", `Expected a string, got ${typeof value} (${value})`); |
| it(`should look for addons in common paths (${name} in "${relPath}")`, (context) => { | ||
| // Arrange | ||
| const tempDirectoryPath = setupTempDirectory(context, { | ||
| [relPath]: "// This is supposed to be a binary file", | ||
| }); | ||
| // Act | ||
| const actualPath = await findNodeAddonForBindings( | ||
| name, | ||
| tempDirectoryPath, | ||
| ); | ||
| const actualPath = findNodeAddonForBindings(name, tempDirectoryPath); |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test callback was changed from async to synchronous, but findNodeAddonForBindings is being called without await on line 498. If this function is actually asynchronous, this change introduces a bug. If it's synchronous, the original async was unnecessary but harmless.
Followed https://typescript-eslint.io/getting-started/typed-linting to enable "typed linting".