Skip to content

eslint --fix incorrectly changes the wrong line on each block with comment on separate line #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
DetachHead opened this issue Dec 18, 2022 · 1 comment · Fixed by sveltejs/svelte-eslint-parser#262

Comments

@DetachHead
Copy link
Contributor

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.

What version of ESLint are you using?

8.30.0

What version of eslint-plugin-svelte are you using?

2.14.1

What did you do?

Configuration
module.exports = {
  root: true,
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint"],
  ignorePatterns: ["*.cjs"],
  settings: {
    'import/parsers': {
      '@typescript-eslint/parser': [ '.ts', '.tsx', '.cts', '.mts' ],
      'espree': [ '.js', 'jsx', '.cjs', '.mjs' ],
    }
  },
  rules: {
    "spaced-comment": "error"
  },
  overrides: [
    {
      files: ["*.svelte"],
      parser: "svelte-eslint-parser",
      parserOptions: {
        parser: "@typescript-eslint/parser",
      },
    },
  ]
};
{#each f(
//asdf
d) as k}<Csdf></Csdf>{/each}
eslint . --fix

What did you expect to happen?

space added on line 2 after the //

What actually happened?

space added on line 1 after the {#, causing a syntax error:

{# each f(
//asdf
d) as k}<Csdf></Csdf>{/each}
> eslint . --fix

C:\projects\asdf\src\main.svelte
  1:2  error  Parsing error: Expected if, each or await

✖ 1 problem (1 error, 0 warnings)

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/DetachHead/eslint-plugin-svelte-issue/tree/d15d9f053c334ee05eb5b4c5ea161e879cbbf523

also same issue but different rule: https://ota-meshi.github.io/eslint-plugin-svelte/playground/#eJyrVkrOT0lVslKqVk5NTM5QSNOIydPXTyxOSYvJS9FUSCxWyK61cQZy9e2q9UEqapVqAbyyES0=

Additional comments

No response

@ota-meshi
Copy link
Member

Thank you for the many reports.
I can confirm that bug, but I'm too busy this week to fix it yet. Please wait.

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 a pull request may close this issue.

2 participants