mthadley / eslint-plugin-sort-destructure-keys

ESLint plugin to check if keys should be sorted in an object pattern.
https://www.npmjs.com/package/eslint-plugin-sort-destructure-keys
ISC License
95 stars 9 forks source link

TypeError: Cannot read properties of undefined (reading 'getScope') #277

Closed mrstork closed 6 months ago

mrstork commented 6 months ago

Error message:

TypeError: Cannot read properties of undefined (reading 'getScope')
Occurred while linting [...].js:25
Rule: "sort-destructure-keys/sort-destructure-keys"
at ObjectPattern (/[...]/node_modules/eslint-plugin-sort-destructure-keys/lib/rules/sort-destructure-keys.js:220:34)
...

Versions:

Notes:

The issue seems to be coming from the following code block:

const scope = sourceCode.getScope ? sourceCode.getScope(objectPatternNode) : context.getScope();

There looks to be a patch in master that ensures sourceCode is defined before calling getScope on it, however this change isn't in the 1.6.0 tag. Would we be able to include it in a v1.6.1 release?

mthadley commented 6 months ago

@mrstork Are you able to install v2.0.0?

mrstork commented 6 months ago

Sorry about this, I see this is also resolved in the latest version 2.0.0 which is sufficient for me.

mthadley commented 6 months ago

No problem! Glad it is working for you.

Closing since if other people have this issue, I'll have the same recommendation of upgrading to v2.0.0.