Skip to content

Conversation

@kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen self-assigned this Aug 3, 2025
@kraenhansen kraenhansen added CI Continuous integration Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) labels Aug 3, 2025
@kraenhansen kraenhansen force-pushed the kh/type-aware-linting branch from c7ebe6a to cc7ffb4 Compare August 3, 2025 13:52
Comment on lines +28 to +36
"@typescript-eslint/no-floating-promises": [
"error",
{
allowForKnownSafeCalls: [
{ from: "package", name: ["suite", "test"], package: "node:test" },
],
},
],
},
Copy link
Collaborator Author

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

@kraenhansen kraenhansen force-pushed the kh/type-aware-linting branch 3 times, most recently from 8135b07 to 05b27f4 Compare August 4, 2025 14:13
@kraenhansen kraenhansen force-pushed the kh/type-aware-linting branch from 05b27f4 to 0e4c888 Compare August 6, 2025 08:02
@kraenhansen kraenhansen requested a review from Copilot August 6, 2025 08:02
@kraenhansen kraenhansen marked this pull request as ready for review August 6, 2025 08:03
Copy link
Contributor

Copilot AI left a 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 recommendedTypeChecked rules 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 .only modifier 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>,
Copy link

Copilot AI Aug 6, 2025

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.

Suggested change
async: () => require("../tests/async/addon.js") as () => Promise<void>,
async: () => require("../tests/async/addon.js") as () => Promise<undefined>,

Copilot uses AI. Check for mistakes.
typeof value === "string",
`Expected a string, got ${typeof value} (${value})`,
);
assert(typeof value === "string", `Expected a string, got ${typeof value}`);
Copy link

Copilot AI Aug 6, 2025

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}).

Suggested change
assert(typeof value === "string", `Expected a string, got ${typeof value}`);
assert(typeof value === "string", `Expected a string, got ${typeof value} (${value})`);

Copilot uses AI. Check for mistakes.
Comment on lines +492 to +498
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);
Copy link

Copilot AI Aug 6, 2025

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.

Copilot uses AI. Check for mistakes.
@kraenhansen kraenhansen merged commit 5903eca into main Aug 6, 2025
6 checks passed
@kraenhansen kraenhansen deleted the kh/type-aware-linting branch August 6, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) CI Continuous integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants