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

Fix: avoid moving comments in implicit-arrow-linebreak (fixes #11521) #11522

Merged
merged 1 commit into from Mar 18, 2019

Conversation

not-an-aardvark
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[x] Bug fix (#11521)

What changes did you make? (Give an overview)

Currently, the implicit-arrow-linebreak rule contains a lot of logic to determine how comments should be adjusted in code when an autofix is needed. The goal is to be able to autofix cases where there is a comment between an arrow token and the start of an arrow function body. Most other core rules simply decide not to fix cases when there is a comment interfering with the fix.

This logic accounts for a large fraction of the code in the rule, and seems to require a lot of different code for many individual cases. Unfortunately, bugs keep being reported identifying problems in the rule (e.g. #11268, #11521) and it's not clear that the fixes are moving us closer to making the rule correct in general, given that there are always more cases than we can explicitly account for.

To address those problems, this commit updates the implicit-arrow-linebreak rule to just skip autofixing when comments interfere, rather than trying to do an autofix anyway and find an alternate location for the comments. I'm reluctant to make this change given that a lot of time has been invested in the autofixing logic, but I think this is ultimately a better solution than trying to guess where the user wants their comments to go, and crashing/producing incorrect code if we get it wrong.

Is there anything you'd like reviewers to focus on?

Nothing in particular

Currently, the implicit-arrow-linebreak rule contains a lot of logic to determine how comments should be adjusted in code when an autofix is needed. The goal is to be able to autofix cases where there is a comment between an arrow token and the start of an arrow function body. Most other core rules simply decide not to fix cases when there is a comment interfering with the fix.

This logic accounts for a large fraction of the code in the rule, and seems to require a lot of different code for many individual cases. Unfortunately, bugs keep being reported identifying problems in the rule (e.g. #11268, #11521) and it's not clear that the fixes are moving us closer to making the rule correct in general, given that there are always more cases than we can explicitly account for.

To address those problems, this commit updates the implicit-arrow-linebreak rule to just skip autofixing when comments interfere, rather than trying to do an autofix anyway and find an alternate location for the comments. I'm reluctant to make this change given that a lot of time has been invested in the autofixing logic, but I think this is ultimately a better solution than trying to guess where the user wants their comments to go, and crashing/producing incorrect code if we get it wrong.
@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion regression Something broke patch candidate This issue may necessitate a patch release in the next few days labels Mar 17, 2019
Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@not-an-aardvark not-an-aardvark merged commit 71adc66 into master Mar 18, 2019
@not-an-aardvark not-an-aardvark deleted the implicit-arrow-linebreak-fix branch March 18, 2019 15:44
matheus1lva pushed a commit to matheus1lva/proxy-all-the-things that referenced this pull request Mar 18, 2019
## The devDependency [eslint](https://github.com/eslint/eslint) was updated from `5.15.2` to `5.15.3`.
This version is **not covered** by your **current version range**.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.

---

<details>
<summary>Release Notes for v5.15.3</summary>

<ul>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/71adc665b9649b173adc76f80723b8de20664ae1"><code>71adc66</code></a> Fix: avoid moving comments in implicit-arrow-linebreak (fixes <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="421906357" data-permission-text="Issue title is private" data-url="eslint/eslint#11521" data-hovercard-type="issue" data-hovercard-url="/eslint/eslint/issues/11521/hovercard" href="https://urls.greenkeeper.io/eslint/eslint/issues/11521">#11521</a>) (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="421978023" data-permission-text="Issue title is private" data-url="eslint/eslint#11522" data-hovercard-type="pull_request" data-hovercard-url="/eslint/eslint/pull/11522/hovercard" href="https://urls.greenkeeper.io/eslint/eslint/pull/11522">#11522</a>) (Teddy Katz)</li>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/1f715a20c145d8ccc38f3310afccd838495d09d4"><code>1f715a2</code></a> Chore: make test-case-property-ordering reasonable (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="421335627" data-permission-text="Issue title is private" data-url="eslint/eslint#11511" data-hovercard-type="pull_request" data-hovercard-url="/eslint/eslint/pull/11511/hovercard" href="https://urls.greenkeeper.io/eslint/eslint/pull/11511">#11511</a>) (Toru Nagashima)</li>
</ul>
</details>

<details>
<summary>Commits</summary>
<p>The new version differs by 4 commits.</p>
<ul>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/a6168f85f9017332777b2bac5af8c4a979e06298"><code>a6168f8</code></a> <code>5.15.3</code></li>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/cb57316b156e118caf726ad534bedc47f077bda2"><code>cb57316</code></a> <code>Build: changelog update for 5.15.3</code></li>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/71adc665b9649b173adc76f80723b8de20664ae1"><code>71adc66</code></a> <code>Fix: avoid moving comments in implicit-arrow-linebreak (fixes #11521) (#11522)</code></li>
<li><a href="https://urls.greenkeeper.io/eslint/eslint/commit/1f715a20c145d8ccc38f3310afccd838495d09d4"><code>1f715a2</code></a> <code>Chore: make test-case-property-ordering reasonable (#11511)</code></li>
</ul>
<p>See the <a href="https://urls.greenkeeper.io/eslint/eslint/compare/f3547701816d35ffdefa00d755f029109e15924f...a6168f85f9017332777b2bac5af8c4a979e06298">full diff</a></p>
</details>

<details>
  <summary>FAQ and help</summary>

  There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).
</details>

---


Your [Greenkeeper](https://greenkeeper.io) bot 🌴
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 15, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 15, 2019
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 bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days regression Something broke rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants