Skip to content

Conversation

@Belco90
Copy link
Member

@Belco90 Belco90 commented Oct 9, 2025

Checks

Changes

  • Replace jest with vitest, including scripts and eslint plugin
  • In order to get certain tests running correctly with vitest, I've removed the dynamic generation for configs and rules, so they are generated statically. The plugin should work the same way for the final user.

Context

Relates to #855

@Belco90 Belco90 self-assigned this Oct 9, 2025
@Belco90 Belco90 requested review from a team, MichaelDeBoey and y-hsgw and removed request for MichaelDeBoey and y-hsgw October 9, 2025 15:53
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is failing because of the dynamic import with require. I need to keep investigating.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in c2ddd3a

@Belco90 Belco90 added the chore Changes that affect the build system, CI config or other changes that don't modify src/test files label Oct 9, 2025
@Belco90 Belco90 mentioned this pull request Oct 9, 2025
8 tasks
@Belco90 Belco90 force-pushed the replace-jest-with-vitest branch from 9a4d5ea to a551ae2 Compare December 11, 2025 11:21
@Belco90 Belco90 marked this pull request as ready for review December 11, 2025 13:30
@Belco90 Belco90 marked this pull request as draft December 11, 2025 13:31
@Belco90 Belco90 changed the title chore: replace jest with vitest fix: generate configs and rules statically Dec 11, 2025
@Belco90 Belco90 marked this pull request as ready for review December 11, 2025 15:24
@Belco90 Belco90 requested a review from Copilot December 11, 2025 15:24
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 pull request migrates the project from Jest to Vitest for testing, and refactors the plugin to generate configs and rules statically instead of dynamically. The migration was necessary to get certain tests running correctly with Vitest. The plugin should work the same way for end users.

Key changes:

  • Replaced Jest with Vitest, including test runner, coverage tools, and ESLint plugin
  • Removed dynamic generation for configs and rules, replaced with static imports and exports
  • Updated test files to use Vitest imports instead of Jest globals

Reviewed changes

Copilot reviewed 19 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vitest.setup.mts New setup file configuring RuleTester for Vitest compatibility
vitest.config.mts New Vitest configuration with coverage thresholds
tsconfig.json Added **/*.mts to includes for TypeScript compilation
tsconfig.build.json Excluded vitest.* files from build
tools/generate-configs/utils.ts Updated to add Linter type import and satisfies clause
tests/lib/utils/is-testing-library-module.test.ts Added Vitest imports
tests/index.test.ts Replaced dynamic rule counting with filesystem-based validation
package.json Replaced Jest dependencies with Vitest equivalents
lib/utils/index.ts Removed file-import export
lib/utils/file-import.ts Deleted utility for dynamic imports
lib/rules/index.ts Changed from dynamic to static rule imports
lib/index.ts Changed from dynamic to static config generation
lib/configs/*.ts Added Linter type import and satisfies clause
lib/configs/index.ts Changed from dynamic to static config imports
jest.config.js Removed Jest configuration
eslint.config.mjs Replaced eslint-plugin-jest with @vitest/eslint-plugin

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"typescript": "^5.7.2",
"typescript-eslint": "^8.15.0"
"typescript-eslint": "^8.15.0",
"vitest": "^3.2.4"
Copy link
Member Author

Choose a reason for hiding this comment

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

Can't install vitest v4 since is not compatible with node v18.

'testing-library/render-result-naming-convention': 'error',
},
};
} satisfies Linter.LegacyConfig;
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding this for type validation purposes.

marko,
};

export default SUPPORTED_TESTING_FRAMEWORKS.reduce(
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove dynamic generation in favor of static generation.

const rulesDir = __dirname;
const excludedFiles = ['index'];

export default readdirSync(rulesDir)
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove dynamic generation in favor of static generation.

>),
};
...legacyConfigs,
'flat/dom': {
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove dynamic generation in favor of static generation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in c2ddd3a

const ruleNames = Object.keys(plugin.rules);

// eslint-disable-next-line jest/expect-expect
it('should export all existing rules', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This new test will take care of making sure that all rules within libs/rules are actually re-exported, so can be consumed by users installing the plugin.

The purpose for this check is to improve the DX when working on new rules, since it's quite easy to forget re-exporting the rules to the public API of the plugin.

Here, a demo of the test catching a rule not re-exported properly:

pr-1102-demo.mp4

}
expect(
existsSync(docPath),
`Could not find documentation file for rule "${rule}" in path "${docPath}"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Can be tested with expect assertion + custom error message with vitest.

});

// eslint-disable-next-line jest/expect-expect
it('should have the correct amount of rules', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is covered by the new test.

@Belco90 Belco90 merged commit 9b81dde into main Dec 11, 2025
32 checks passed
@Belco90 Belco90 deleted the replace-jest-with-vitest branch December 11, 2025 21:53
@github-actions
Copy link

🎉 This PR is included in version 7.13.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

chore Changes that affect the build system, CI config or other changes that don't modify src/test files released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants