Skip to content

False positives on reactive declarations starting from 2.11.0 #277

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
marekdedic opened this issue Oct 27, 2022 · 5 comments · Fixed by sveltejs/svelte-eslint-parser#234
Closed
2 tasks done

Comments

@marekdedic
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.26.0

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

2.11.0

What did you do?

let currentTab:
    | "confirmation"
    | "destination-selection"
    | "done"
    | "introduction"
    | "moving"
    | "source-selection" = "introduction";

$: progress =
    currentTab === "introduction"
      ? 1 / 5
      : currentTab === "source-selection"
      ? 2 / 5
      : currentTab === "destination-selection"
      ? 3 / 5
      : currentTab === "confirmation"
      ? 4 / 5
      : 0;

What did you expect to happen?

No errors

What actually happened?

9:16 error Placing a void expression inside another expression is forbidden. Move it to its own statement instead @typescript-eslint/no-confusing-void-expression
9:16 error Missing return type on function @typescript-eslint/explicit-function-return-type
10:5 error Unreachable code no-unreachable

Link to Minimal Reproducible Example

skaut/shared-drive-mover#1109 - it's not minimal, I can add a minimal repro if this doesn't help...

Additional comments

This only happens on 2.11.0, see skaut/shared-drive-mover#1109

@marekdedic marekdedic changed the title False positives on reactive declarations False positives on reactive declarations starting from 2.11.0 Oct 27, 2022
@ota-meshi
Copy link
Member

Thank you for reporting the issue.
It seems to parse incorrectly if there is a newline after =.
I will try to fix it.

@ota-meshi
Copy link
Member

I have fixed the parser.
Could you please update svelte-eslint-parser to 0.19.1 and give it a try?

@marekdedic
Copy link
Contributor Author

Hi,
gets even worse :(

Oops! Something went wrong! :(

ESLint: 8.26.0

TypeError: Cannot read properties of undefined (reading 'left')
Occurred while linting /home/user/project/src/frontend/App.svelte:47
Rule: "@typescript-eslint/no-misused-promises"
    at checkAssignment (/home/user/project/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-misused-promises.js:199:62)
    at ruleErrorHandler (/home/user/project/node_modules/eslint/lib/linter/linter.js:1115:28)
    at /home/user/project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/user/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/user/project/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/home/user/project/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/home/user/project/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (/home/user/project/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
    at /home/user/project/node_modules/eslint/lib/linter/linter.js:1150:32

@ota-meshi
Copy link
Member

I have fixed the parser. I tried it on your repository as well and it worked.
Could you please update svelte-eslint-parser to 0.19.2 and give it a try again?

@marekdedic
Copy link
Contributor Author

I can confirm it works now - thank you very much!

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