Skip to content

Bug: rule-tester still crashes on (non-normalized) relative paths that are not inside cwd #11476

@kirkwaiblinger

Description

@kirkwaiblinger

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

rule-tester

Playground Link

No response

Repro Code

new RuleTester().run('rule-name', rule, {
  valid: [
    {
      filename: './../../escaped/cwd/file.ts',
      code: '"whatever"'
    }),
  invalid: []
})

ESLint Config

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

filename should not cause problems since #9906 was fixed (as well as its follow-ons).

Actual Result

running tests causes "No matching configuration found for './../../escaped/cwd/file.ts'."

Additional Info

The .startsWith('..') check in the following doesn't work with non-normalized paths (e.g. ./../foo.ts)

if (
filename != null &&
(path.isAbsolute(filename) || filename.startsWith('..'))
) {
basePath = path.parse(
path.resolve(basePath ?? process.cwd(), filename),
).root;
}

Versions

package version
@typescript-eslint/rule-tester 8.39.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions