Skip to content
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

[one-var] Autofixing this rule drops some exported vars #13834

Closed
scinos opened this issue Nov 11, 2020 · 3 comments · Fixed by #13891
Closed

[one-var] Autofixing this rule drops some exported vars #13834

scinos opened this issue Nov 11, 2020 · 3 comments · Fixed by #13891
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@scinos
Copy link

scinos commented Nov 11, 2020

Tell us about your environment

Can be reproduced in Eslint demo

Check how 'Fixed code' doesn't export both consts.

What did you do?

/*eslint one-var: ["error", "never"]*/
/*eslint-env es6*/

export const foo=1, bar=2;

What did you expect to happen?
I expect the rule to be autofixed to

/*eslint one-var: ["error", "never"]*/
/*eslint-env es6*/

export const foo=1; export const bar=2;

I.e. both const are exported.

What actually happened?

Only the first const is exported:

/*eslint one-var: ["error", "never"]*/
/*eslint-env es6*/

export const foo=1; const bar=2;

Are you willing to submit a pull request to fix this bug?
Yes

@scinos scinos added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Nov 11, 2020
@scinos scinos changed the title [one-var] Wrong auto-fix when the vars are exported [one-var] Autofixing this rule drops some exported vars Nov 11, 2020
@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion autofix This change is related to ESLint's autofixing capabilities rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Nov 11, 2020
@mdjermanovic
Copy link
Member

Hi @scinos, thanks for the bug report!

I can confirm this in online demo, PR is welcome.

@anikethsaha
Copy link
Member

anikethsaha commented Nov 28, 2020

@scinos are you planning to work on this ?
Else I can submit a PR.

Let me know

@scinos
Copy link
Author

scinos commented Nov 28, 2020 via email

anikethsaha added a commit to anikethsaha/eslint that referenced this issue Nov 29, 2020
btmills pushed a commit that referenced this issue Dec 5, 2020
* Fix: one-var autofixing for export (fixes #13834)

* Chore: added export placement for adjacent tokens
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 4, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants