Skip to content

Conversation

@paescuj
Copy link
Contributor

@paescuj paescuj commented Oct 26, 2025

Fixes #799

In #785 the options schema was corrected from the previously invalid schema

pattern: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
format: 'regex',
default: defaultPattern.source,
},

to a valid one
pattern: {
type: 'string',
format: 'regex',
default: defaultPattern.source,
},

As pointed out in #799 it used to be possible to use a RegExp for the rules options (due to the invalid schema and options retrievement via context).

Since, according to the official ESLint documentation 1, rule options need to consist of JSON data types, I would stick with the fixed schema, which means the options must be passed as a string regex, for example:

    'vitest/consistent-test-filename': ['error', { pattern: '.*\.test\.[tj]sx?$' }]
    // or if preferred
    'vitest/consistent-test-filename': ['error', { pattern: /.*\.test\.[tj]sx?$/.source }]

However, what I've missed in #785 is that the Options type should also just accept strings and that it makes more sense to pass the default options in this format as well.

Footnotes

  1. https://eslint.org/docs/latest/use/configure/configuration-files#configuring-rules

Copy link
Member

@veritem veritem left a comment

Choose a reason for hiding this comment

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

thanks

@veritem veritem merged commit 8a14d46 into vitest-dev:main Oct 26, 2025
5 checks passed
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.

vitest/consistent-test-filename breaks eslint as of version 1.3.20

2 participants