eslint-plugin-import: TypeError: Cannot read property 'lastIndexOf' of undefined after upgrading from 2.23.4 to 2.24.1

Steps to Reproduce npm install npm run fix:eslint

Repo link - https://github.com/tmtsoftware/esw-ocs-eng-ui/tree/eslint-plugin-import-issue Branch - eslint-plugin-import-issue

TypeError: Cannot read property 'lastIndexOf' of undefined
Occurred while linting /Users/himanshu/projects/tmt/esw-ocs-eng-ui/test/utils/test-utils.tsx:1
    at removeQuerystring (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-import-resolver-typescript/lib/cjs.js:124:31)
    at Object.resolve (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-import-resolver-typescript/lib/cjs.js:51:14)
    at v2 (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-module-utils/resolve.js:117:23)
    at withResolver (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-module-utils/resolve.js:122:14)
    at fullResolve (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-module-utils/resolve.js:139:22)
    at Function.relative (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-module-utils/resolve.js:84:10)
    at remotePath (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:743:379)
    at resolveImport (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:743:460)
    at Object.getImport (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:745:107)
    at ExportMap.get (/Users/himanshu/projects/tmt/esw-ocs-eng-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:710:667)
ERROR: "eslint:check" exited with 2.```

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 26 (10 by maintainers)

Commits related to this issue

Most upvoted comments

v2.24.2 is released; please give it a shot.

No crashes with v2.24.2!

Thank you @ljharb!

Yes, that would be great, thanks.

I was already downgrading and had lost the exact error message, but the callstack had the Webpack ESLint Resolver in it, so I think that whatever the issue is is not related to any specific resolver, although it certainly seems there’s some interplay here.

I’ll try to remember, at the end of my day, to reinstall 2.24.1 re-lint our project, and report back with the message.

Seems like a bunch of people are getting this – can someone other than me try to make a repro (since I failed at it)? Or at least share what pattern it’s happening on? Or at least say whether what I pasted above matches what you’re seeing? 😄

I tried it. I no longer get the crash, but when I change the import to be an invalid name, I no longer get a lint error. (I do get a TS error.)

import { invalidName } from ‘log4tvui’;

@NickHeiner @Slapbox i’m going to cut a patch release shortly; if there’s any way to try out the latest default branch of the plugin and confirm that it’ll fix your problem, that would be most helpful.

I assume it would still be './b', since I hadn’t changed that part of the expression.