Skip to content

refactor(test): migrate rules to TypeScript - #3036

Merged
FloEdelmann merged 20 commits into
vuejs:masterfrom
9romise:test/migrate-ts
Mar 3, 2026
Merged

FloEdelmann merged 20 commits into
vuejs:masterfrom
9romise:test/migrate-ts

Conversation

@9romise

@9romise 9romise commented Feb 27, 2026 •

Copy link
Copy Markdown
Collaborator
  • Move all test files to TypeScript

Test files count:
Before:
image

After:
image

# Conflicts:
#	tests/lib/utils/ts-utils/index/get-component-emits.ts
#	tests/lib/utils/ts-utils/index/get-component-props.ts
#	tests/lib/utils/ts-utils/index/get-component-slots.ts
#	vitest.config.mts
@changeset-bot

changeset-bot Bot commented Feb 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3aabcfe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@9romise
9romise marked this pull request as ready for review February 27, 2026 06:30
@FloEdelmann

This comment has been minimized.

@9romise

This comment has been minimized.

@9romise
9romise marked this pull request as draft February 28, 2026 09:14
# Conflicts:
#	tests/lib/rules/no-unsupported-features/define-model.test.ts
#	tests/lib/rules/no-unsupported-features/define-options.test.ts
#	tests/lib/rules/no-unsupported-features/define-slots.test.ts
#	tests/lib/rules/no-unsupported-features/dynamic-directive-arguments.test.ts
#	tests/lib/rules/no-unsupported-features/is-attribute-with-vue-prefix.test.ts
#	tests/lib/rules/no-unsupported-features/script-setup.test.ts
#	tests/lib/rules/no-unsupported-features/slot-scope-attribute.test.ts
#	tests/lib/rules/no-unsupported-features/style-css-vars-injection.test.ts
#	tests/lib/rules/no-unsupported-features/v-bind-attr-modifier.test.ts
#	tests/lib/rules/no-unsupported-features/v-bind-prop-modifier-shorthand.test.ts
#	tests/lib/rules/no-unsupported-features/v-bind-same-name-shorthand.test.ts
#	tests/lib/rules/no-unsupported-features/v-is.test.ts
#	tests/lib/rules/no-unsupported-features/v-memo.test.ts
#	tests/lib/rules/no-unsupported-features/v-model-argument.test.ts
#	tests/lib/rules/no-unsupported-features/v-model-custom-modifiers.test.ts
#	tests/lib/rules/no-unsupported-features/v-slot.test.ts
#	tests/lib/utils/casing.test.ts
#	tests/lib/utils/core-rules/wrap-core-rule.test.ts
#	tests/lib/utils/index.test.ts
#	tests/lib/utils/regexp.test.ts
#	tests/lib/utils/vue-component.test.ts
#	typings/eslint/index.d.ts
#	vitest.config.mts
9romise added 2 commits March 2, 2026 08:56
# Conflicts:
#	tests/lib/rules/comma-style.test.ts
#	tests/lib/rules/func-call-spacing.test.ts
#	tests/lib/rules/no-dupe-keys.test.ts
#	tests/lib/rules/no-restricted-props.test.ts
#	tests/lib/rules/no-undef-properties.test.ts
#	tests/lib/rules/no-unused-emit-declarations.test.ts
#	tests/lib/rules/no-unused-properties.test.ts
#	tests/lib/rules/padding-lines-in-component-definition.test.ts
#	tests/lib/rules/prefer-prop-type-boolean-first.test.ts
#	tests/lib/rules/prop-name-casing.test.ts
#	tests/lib/rules/require-emit-validator.test.ts
#	tests/lib/rules/require-explicit-emits.test.ts
#	tests/lib/rules/require-explicit-slots.test.ts
#	tests/lib/rules/require-prop-comment.test.ts
#	tests/lib/rules/require-prop-type-constructor.test.ts
#	tests/lib/rules/require-prop-types.test.ts
#	tests/lib/rules/require-valid-default-prop.test.ts
#	tests/lib/rules/return-in-emits-validator.test.ts
#	tests/test-utils/eslint-stylistic.ts
@9romise 9romise changed the title refactor(test): move to TypeScript refactor(test): migrate rules to TypeScript Mar 2, 2026
# Conflicts:
#	tests/integrations/eslint-plugin-import.test.ts
#	tests/integrations/flat-config.test.ts
#	tests/lib/meta.test.ts
@9romise
9romise marked this pull request as ready for review March 2, 2026 17:45
Comment thread tests/lib/rules/script-indent.test.ts Resolved

Copilot AI left a comment

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.

Pull request overview

This PR migrates the rule test suite from CommonJS JavaScript to TypeScript/ESM, aligning test execution with Vitest’s TS workflow and updating a few related typings and rule JSDoc annotations.

Changes:

  • Update Vitest test discovery patterns to target *.test.ts files.
  • Replace CommonJS require(...) usage in many tests with ESM import (and introduce a new tests/eslint-compat.ts helper).
  • Add/adjust some TypeScript typings and a few tests (e.g., new config tests, block-order test), plus minor rule JSDoc return type fixes.

Reviewed changes

Copilot reviewed 236 out of 241 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vitest.config.mts Narrow test include globs to *.test.ts and simplify excludes.
typings/eslint/index.d.ts Refine RuleTester typing (constructor + merged namespace aliases).
tests/eslint-compat.ts New ESM TypeScript replacement for tests/eslint-compat.js using eslint-compat-utils.
tests/eslint-compat.js Removed legacy CommonJS compat helper.
tests/lib/configs/flat.test.ts New/ported tests validating flat-config exports and suppression behavior.
tests/lib/configs/eslintrc.test.ts New/ported tests validating legacy plugin:vue/* config loading.
tests/lib/rules/block-order.test.ts New/ported block-order tests using both RuleTester and ESLint API.
tests/lib/rules/script-indent.test.ts Migrated to ESM/TS; uses createRequire but still references __dirname.
tests/lib/rules/html-indent.test.ts Migrated to ESM/TS; still references __dirname and require.resolve.
tests/lib/rules/no-export-in-script-setup.test.ts Migrated to ESM/TS; still uses require.resolve for TS parser resolution.
tests/lib/rules/require-default-prop.test.ts Migrated to ESM/TS; still uses require.resolve for TS parser resolution in parserOptions.
tests/lib/rules/*.test.ts Bulk migration of rule tests from CJS to TS/ESM (imports + parser wiring).
lib/rules/use-v-on-exact.js JSDoc return type updated from Object to RuleListener.
lib/rules/this-in-template.js JSDoc return type updated from Object to RuleListener.
lib/rules/no-template-target-blank.js JSDoc return type updated from Object to RuleListener.
Comments suppressed due to low confidence (5)

tests/lib/rules/script-indent.test.ts:16

  • __dirname is used in an ESM test module (this file already uses import.meta.url/createRequire). In ESM, __dirname is undefined, so FIXTURE_ROOT will throw at runtime. Compute the directory from import.meta.url (e.g., via fileURLToPath/path.dirname) or build the fixture path using new URL(..., import.meta.url) instead.
    tests/lib/rules/html-indent.test.ts:13
  • __dirname is referenced in this ESM test file, but __dirname is not defined in ESM. This will crash when computing FIXTURE_ROOT. Use new URL('../../fixtures/html-indent/', import.meta.url) (or derive a dirname from import.meta.url) instead.
    tests/lib/rules/html-indent.test.ts:45
  • This ESM test file still calls require.resolve(...), but require is not defined in ESM, so resolving fixture-provided parsers will throw at runtime. Use a createRequire(import.meta.url) instance (as in script-indent.test.ts) and call nodeRequire.resolve(...) here instead (or switch to passing the imported parser object if supported).
    tests/lib/rules/no-export-in-script-setup.test.ts:76
  • This ESM test file uses require.resolve('@typescript-eslint/parser'), but require is not defined in ESM, so these test cases will crash when evaluated. Use a createRequire(import.meta.url) instance to resolve the parser, or avoid require.resolve by passing the imported parser directly if vue-eslint-parser accepts parser objects in parserOptions.parser.
    tests/lib/rules/require-default-prop.test.ts:247
  • These test cases configure parserOptions.parser via require.resolve('@typescript-eslint/parser'), but this file is ESM so require is undefined at runtime. Use createRequire(import.meta.url).resolve(...) (or pass the imported TS parser directly, if supported) to avoid a runtime crash.

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

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you so much for pushing the TypeScript migration along!

@FloEdelmann
FloEdelmann merged commit b5d8f14 into vuejs:master Mar 3, 2026
21 checks passed
@9romise
9romise deleted the test/migrate-ts branch March 3, 2026 10:13
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.

3 participants