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

bug: TypeError: Cannot read property 'type' of undefined\nOccurred while linting #11521

Assignees
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

Comments

@aladdin-add
Copy link
Member

it was detected by fuzzer. see https://travis-ci.org/eslint/eslint/jobs/507427588

Tell us about your environment

  • ESLint Version: master
  • Node Version: n/w
  • npm Version: n/w

What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:

Configuration
            "config": {

                "rules": {

                    "implicit-arrow-linebreak": [

                        2,

                        "beside"

                    ]

                },

                "parserOptions": {

                    "sourceType": "script",

                    "ecmaVersion": 2018

                }

            },

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

What did you expect to happen?
TBF

What actually happened? Please include the actual, raw output from ESLint.
TBF

Are you willing to submit a pull request to fix this bug?
not atm :(

@aladdin-add aladdin-add 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 labels Mar 17, 2019
@aladdin-add
Copy link
Member Author

it might be introduced in 29dbca7

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Mar 17, 2019

Smaller reproducible example (causes a crash with implicit-arrow-linebreak on the default settings):

() => /*
*/ (a = () => b) => c

(I've been working on an enhancement to the fuzzer that minimizes the examples that it produces, but the enhancement isn't ready yet.)

(Demo: here)

@not-an-aardvark not-an-aardvark added regression Something broke patch candidate This issue may necessitate a patch release in the next few days labels Mar 17, 2019
@not-an-aardvark not-an-aardvark self-assigned this Mar 17, 2019
not-an-aardvark added a commit that referenced this issue Mar 17, 2019
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.
matheus1lva pushed a commit to matheus1lva/proxy-all-the-things that referenced this issue 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
2 participants