Skip to content

Release detect-invalid-spies#2318

Open
samchungy wants to merge 5 commits intomainfrom
detect-invalid-spies
Open

Release detect-invalid-spies#2318
samchungy wants to merge 5 commits intomainfrom
detect-invalid-spies

Conversation

@samchungy
Copy link
Copy Markdown
Contributor

@samchungy samchungy commented Mar 30, 2026

Vibe coded a little something something for detecting invalid spy usage when migrating from Jest -> Vitest. This was a little difficult to throw into a lint rule and I figure it'll mostly be for 1 time runs to get from Jest -> Vitest.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

🦋 Changeset detected

Latest commit: 08f178c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@samchungy samchungy marked this pull request as ready for review March 30, 2026 13:47
@samchungy samchungy requested a review from a team as a code owner March 30, 2026 13:47
const identifiers = root.findAll({
rule: {
kind: 'identifier',
regex: `^${functionName}$`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can/should we be bothered to escape this just in case people have some funky function names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah it should be okay, we aren't automatically running this via lint or anything so nothing malicious should result of it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we call out that this won't detect re exporting things eg. something weird like this

// impl.ts
export const doThing = () => 'x';
export const caller = () => doThing();
// index.ts
export { doThing as default } from './impl';
// spy.ts
import * as index from './index.ts';

jest.spyOn(index, 'default');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reckon that's a skill issue if so

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