Skip to content

Change Request: Flat Rule Tester support filename for non-JavaScript files #17577

@DMartens

Description

@DMartens

ESLint version

8.49.0

What problem do you want to solve?

The Flat Rule Tester currently reports an error when setting the filename of a test case to a non-JavaScript file (e.g. file.ts):
No matching configuration found for file.ts.
As I understand it, this is because files ending with .js are always matched in the flat config system even if there is no files property.

What do you think is the correct solution?

Translate the filename property to files in the config passed to the linter:

...
const itemConfig = { ...item }
if (item.filename) {
	itemConfig.files = [item.filename]
}
...

This ensures that the generated config matches the file.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

This problem can also be circumvented by providing a baseConfig but this solution is more ergonomical and this was also not required when using the "legacy" rule tester, so this may be seen as a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussioncoreRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLint

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions