mizdra / eslint-interactive

The CLI tool to fix huge number of ESLint errors
MIT License
363 stars 9 forks source link

“Disable per line” results in wrong fix when lint error is in template literals #365

Closed uhyo closed 4 weeks ago

uhyo commented 1 month ago

Hello, thank you for the great tool again 😃

This time I would like to report a wrong behavior when utilizing the disable per line action to fix lint errors found in template literals.

Thanks.

Reproduction

ESLint Config

export default [
  {
    files: ["**/*.js"],
    rules: {
      eqeqeq: "error"
    }
  }
];

Code before applying fix

const foo = `
  This is a template literal
  ${bar == baz}
`;

Code after applying fix

const foo = `
  This is a template literal
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  // eslint-disable-next-line eqeqeq
  ${bar == baz}
`;

Expected behavior

Possibly:

const foo = `
  This is a template literal
  ${
  // eslint-disable-next-line eqeqeq
  bar == baz
  }
`;

Or maybe bail out at least without producing wrong fix.