Skip to content

Conversation

@ItsNickBarry
Copy link
Contributor

Similar to how the node plugin detects test files if node --test is present.

Documented here: https://tsx.is/node-enhancement#test-runner

Two issues:

  1. I may be using toBinary incorrectly. The tests are failing.
  2. I'm not sure why isEnabled wasn't being used for the tsx plugin before.

@ItsNickBarry ItsNickBarry marked this pull request as ready for review May 16, 2025 20:19
@ItsNickBarry
Copy link
Contributor Author

The binary issue seems to be fixed. Is my solution correct?

Copy link
Member

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nick! Happy to merge, but I do have a remark.

const resolveConfig: ResolveConfig<PackageJson> = localConfig => {
const scripts = localConfig.scripts;

const entries = [toDependency('tsx')];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should probably not be added here. If tsx is listed in package.json but not used anywhere we probably want it reported as unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,4 @@
{
"name": "tsx",
"bin": ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I typically do is add an empty index.js file with "bin": "./index.js".

Knip looks here for the tsx executable referenced in package.json#scripts and understands the tsx dependency is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 17, 2025

Open in StackBlitz

npm i https://pkg.pr.new/knip@1090

commit: 3e65590

import type { Plugin } from '../../types/config.js';
import type { PackageJson } from 'src/types/package-json.js';
import { toEntry } from 'src/util/input.js';
import { hasDependency } from 'src/util/plugin.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use relative imports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@webpro webpro merged commit 46658b9 into webpro-nl:main May 19, 2025
29 checks passed
@webpro
Copy link
Member

webpro commented May 19, 2025

Nice one! 🙏

@webpro
Copy link
Member

webpro commented May 20, 2025

🚀 This pull request is included in v5.57.0. See Release 5.57.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants