Skip to content

Bug: RuleTester doesn't fix properly when there are multiple fixes on the same line #8251

Closed as not planned
@StyleShit

Description

@StyleShit

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

Repro Code

See: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/space-infix-ops.test.ts#L1021-L1049

{
  invalid: [
    {
      code: `
        type Test=|string|(((() => void)))|string;
      `,
      output: `
        type Test = |string | (((() => void))) | string;
      `,
      errors: [
        {
          messageId: 'missingSpace',
          column: 18,
          line: 2,
        },
        {
          messageId: 'missingSpace',
          column: 19,
          line: 2,
        },
        {
          messageId: 'missingSpace',
          column: 26,
          line: 2,
        },
        {
          messageId: 'missingSpace',
          column: 43,
          line: 2,
        },
      ],
    },
  ],
}

Description

Splits from this thread:
#8065 (comment)

The code should be fixed properly when there are multiple fixes on the same line.
In the repro code, the fix should actually be

type Test = | string | (((() => void))) | string;

And in the thread, it should've been fixed regardless of me adding space as a workaround
(you can see that I've changed it from ${'a'}${'b'} to ${'a'} ${'b'})

Opened a draft PR to start an investigation.
Seems like there are some actual wrong fixes in the tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: rule-testerIssues related to the @typescript-eslint/rule-tester packageworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions