Fix ESLint crashing on rest operator: “Cannot read property ‘type’ of undefined”
This is a bit of an obscure one, but I tend to use the same dev tooling configuration (Prettier, ESLint, Babel, etc) for multiple projects so I’m likely to run into this again.
I encountered this in the middle of a project after a VSCode restart (to resolve other troublesome behavior). I was doing some refactoring and noticed that the magic that tells me what I’ve borked was conspicuously quiet, and a glance at the ESLint “output channel” in VSCode showed the titular error.
In my case, it wound up that I had been using an older version of ESLint (5.x) even as related dependencies (
eslint-plugin-react, and the ESLint extension for VSCode, among others) were updated. Fixing the issue was as easy as updating ESLint to the latest version (v7.11.0 at the moment of publication) and restarting VSCode again.