import-js/eslint-plugin-import

After upgrade from 2.29.1 to 2.30.0 get "Parse errors" in react-toastify: "parser.parse is not a function (undefined:undefined) import/no-deprecated"

corneliusroemer opened this issue ยท 16 comments

When upgrading eslint-plugin-import from 2.29.1 to 2.30.0 I suddenly get an error for react-toastify.esm.mjs:

Error:   3:32  error  Parse errors in imported module 'react-toastify': parser.parse is not a function (undefined:undefined)  import/no-deprecated

is this intended?

Error while parsing /codebuild/output/src262100263/src/actions-runner/_work/loculus/loculus/website/node_modules/react-toastify/dist/react-toastify.esm.mjs
Line 4, column 0: Unknown token at 15458, expected: "}", actual: ""
`parseForESLint` from parser `/codebuild/output/src262[10](https://github.com/loculus-project/loculus/actions/runs/10779022293/job/29891619759?pr=2732#step:6:11)0263/src/actions-runner/_work/loculus/loculus/website/node_modules/astro-eslint-parser/lib/index.js` is invalid and will just be ignored

/codebuild/output/src262100263/src/actions-runner/_work/loculus/loculus/website/src/layouts/BaseLayout.astro
Error:   3:32  error  Parse errors in imported module 'react-toastify': parser.parse is not a function (undefined:undefined)  import/no-deprecated

see https://github.com/loculus-project/loculus/actions/runs/10779022293/job/29891619759?pr=2732#step:6:10

I don't know enough about react-toastify and eslint-plugin-import and JS/TS in general to know where the error lies.

Discovered in this dependabot PR: loculus-project/loculus#2732

See issue in react-toastify: fkhadra/react-toastify#1154

Thanks! Strangely I can't reproduce actually after a fresh checkout and npm ci.

Wait, I can reproduce it again. The eslint cache might have thrown me.

The error does get triggered by the upgrade to 2.30.0. It might well be that the astro-eslint-parser contributes but some code change in eslint-plug-import makes it happen only now.

and you're sure it's not from updating @typescript-eslint/parser? (the astro parser wraps that)

Yep, that one's still bumped here and it doesn't error (in that place): https://github.com/loculus-project/loculus/actions/runs/10781731886/job/29900275170?pr=2739

Does it happen with v2.29.1 of the import plugin and v2.10.0 of eslint-module-utils?

Nope, doesn't happen in that case, that diff doesn't trigger it either:

Yes indeed, I can trigger it just by updating:

 npm i eslint-module-utils@2.10.0
image

What version did you have previously? 1079e70 is the only change in v2.10.0 that's not in v2.9.0, and that doesn't seem like it could be relevant. 806e3c2 was added in v2.9.0, but that only added .mjs and .cjs as valid default extensions.

2.8.1, see screenshot above

ah, thanks :-) could you try v2.8.2 and v2.9.0, just to be sure?

Indeed it is the upgrade from 2.8.2 -> 2.9.0

โŒ1 โฏ npm i eslint-module-utils@2.8.2

changed 1 package, and audited 1181 packages in 2s

390 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

loculus/website on ๎‚  dependabot/npm_and_yarn/website/minorandpatch-b0e14b6152 [$!?] is ๐Ÿ“ฆ v0.0.1 via ๎œ˜ v22.8.0 in โ˜ธ aws (default) on โ˜๏ธ  (us-east-1)
โฏ npm exec eslint /Users/corneliusromer/code/loculus/website/src/layouts/BaseLayout.astro
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.6.2

Please only submit bug reports when using the officially supported version.

=============

loculus/website on ๎‚  dependabot/npm_and_yarn/website/minorandpatch-b0e14b6152 [$!?] is ๐Ÿ“ฆ v0.0.1 via ๎œ˜ v22.8.0 in โ˜ธ aws (default) on โ˜๏ธ  (us-east-1) took 6s
โฏ npm i eslint-module-utils@2.9

changed 1 package, and audited 1181 packages in 970ms

390 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

loculus/website on ๎‚  dependabot/npm_and_yarn/website/minorandpatch-b0e14b6152 [$!?] is ๐Ÿ“ฆ v0.0.1 via ๎œ˜ v22.8.0 in โ˜ธ aws (default) on โ˜๏ธ  (us-east-1)
โฏ npm exec eslint /Users/corneliusromer/code/loculus/website/src/layouts/BaseLayout.astro
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.6.2

Please only submit bug reports when using the officially supported version.

=============

Error while parsing /Users/corneliusromer/code/loculus/website/node_modules/react-toastify/dist/react-toastify.esm.mjs
Line 4, column 0: Unknown token at 15458, expected: "}", actual: ""
`parseForESLint` from parser `/Users/corneliusromer/code/loculus/website/node_modules/astro-eslint-parser/lib/index.js` is invalid and will just be ignored

/Users/corneliusromer/code/loculus/website/src/layouts/BaseLayout.astro
  3:32  error  Parse errors in imported module 'react-toastify': parser.parse is not a function (undefined:undefined)  import/no-deprecated

โœ– 1 problem (1 error, 0 warnings)

cc @michaelfaith it'd be great to get a fix for this in its own PR/commit (i think you may already be looking at it for #2996)

Do you have a repo that can easily reproduce this, or steps to reproduce it in this repo's examples? That'll help with testing and validation.
Also maybe it is the mjs / cjs addition after all? I wouldn't have thought that'd have caused such a thing, but I notice the path in the parsing error has an mjs extension. Is the astrolint-eslint-parser able to parse esm files?
Either way, if I can reliably reproduce it, I'll work on putting a fix up.

@corneliusroemer just checking in, did you still want me to take a look at this? If so, any repro steps or a minimum reproduction repo demonstrating the issue would be super helpful.

The latest version of eslint-plugin-import (2.31.0) has fixed the simalar issue we were facing

2.30.0
Image

2.31.0
Image

Glad to hear it.