eslint-plugin-mozilla sometimes causes "TypeError: Cannot read property 'ecmaFeatures' of undefined"

RESOLVED FIXED in Firefox 57

Status

Testing
Lint
P1
normal
RESOLVED FIXED
4 months ago
3 months ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

Version 3
mozilla57
Points:
---

Firefox Tracking Flags

(firefox57 fixed)

Details

MozReview Requests

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

4 months ago
Ian reported this to me for screenshots, that eslint-plugin-mozilla was causing linting of their repository to fail all files:

TypeError: Cannot read property 'ecmaFeatures' of undefined

I've dug into it a bit, and managed to get a stack out:

    at Parser.parseTopLevel (/Users/mark/dev/screenshots/node_modules/eslint-plugin-mozilla/node_modules/espree/espree.js:311:22)
    at Parser.parse (/Users/mark/dev/screenshots/node_modules/acorn/dist/acorn.js:543:15)
    at Object.parse (/Users/mark/dev/screenshots/node_modules/acorn/dist/acorn.js:3670:37)
    at Object.parse (/Users/mark/dev/screenshots/node_modules/espree/espree.js:763:21)
    at parse (/Users/mark/dev/screenshots/node_modules/eslint/lib/linter.js:678:23)
    at Linter.verify (/Users/mark/dev/screenshots/node_modules/eslint/lib/linter.js:813:27)
    at processText (/Users/mark/dev/screenshots/node_modules/eslint/lib/cli-engine.js:203:31)
    at processFile (/Users/mark/dev/screenshots/node_modules/eslint/lib/cli-engine.js:245:18)
    at executeOnFile (/Users/mark/dev/screenshots/node_modules/eslint/lib/cli-engine.js:585:25)
    at fileList.forEach.fileInfo (/Users/mark/dev/screenshots/node_modules/eslint/lib/cli-engine.js:622:13)

The interesting bit here is that Object.parse starts in node_modules/espree/espree.js then the error comes from node_modules/eslint-plugin-mozilla/node_modules/espree/espree.js

So it looks like we're getting two different espree installed and for some reason, it sometimes picks the wrong one.

The espree installed at the top level is 3.5.0, where as the eslint-plugin-mozilla version is fixed at 3.4.3.

I think as we're a plugin, the easiest thing to do is to remove the eslint-plugin-mozilla dependencies for espree & other items that eslint provide. There's already a peer dependency for ESLint, and installing ESLint will get the required sub-packages, so we should still be good.

I've tested it locally with installing a cut down dependency version of eslint-plugin-mozilla into screenshots and it seems to be good.
(Assignee)

Comment 1

4 months ago
One minor issue, changing the dependency tree here also causes us to pick up espree 3.5.0. This is causing errors against mozilla-central, which I've just filed as:

https://github.com/eslint/espree/issues/352

I think at the moment it is best to wait for that to be fixed before I try and change anything.
(Assignee)

Comment 2

3 months ago
Quick update, the espree fix we need should be released at the end of the week. I'm not pushing for any earlier since the photon work is taking priority this week.
Comment hidden (mozreview-request)
(Assignee)

Comment 4

3 months ago
With Espree now fixed, I've updated the relevant modules. Try seems happy as well :-)

Comment 5

3 months ago
mozreview-review
Comment on attachment 8908789 [details]
Bug 1395879 - Remove espree/escope etc from the direct dependencies of eslint-plugin-mozilla since they are really peerDependencies supplied by the existing eslint peer.

https://reviewboard.mozilla.org/r/180404/#review185592
Attachment #8908789 - Flags: review?(dtownsend) → review+

Comment 6

3 months ago
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/740cc074c30f
Remove espree/escope etc from the direct dependencies of eslint-plugin-mozilla since they are really peerDependencies supplied by the existing eslint peer. r=mossop

Comment 7

3 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/740cc074c30f
Status: NEW → RESOLVED
Last Resolved: 3 months ago
status-firefox57: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
(Assignee)

Updated

3 months ago
Blocks: 1399946
You need to log in before you can comment on or make changes to this bug.