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

RESOLVED FIXED in Firefox 57

Status

defect
P1
normal
RESOLVED FIXED
2 years ago
7 months ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

3 Branch
mozilla57
Dependency tree / graph

Firefox Tracking Flags

(firefox57 fixed)

Details

Attachments

(1 attachment)

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.
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.
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.
With Espree now fixed, I've updated the relevant modules. Try seems happy as well :-)
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+
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
https://hg.mozilla.org/mozilla-central/rev/740cc074c30f
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Product: Testing → Firefox Build System
Version: Version 3 → 3 Branch
You need to log in before you can comment on or make changes to this bug.