eslint-plugin icon indicating copy to clipboard operation
eslint-plugin copied to clipboard

eslint-plugin-lingui tried to access typescript error

Open nmoinvaz opened this issue 1 year ago • 5 comments

Describe the bug After upgrading eslint-plugin-lingui from 0.8.1 to 0.9.0 I get the following error:

ESLint: 8.57.1

Error: Failed to load plugin 'lingui' declared in '.eslintrc.json': eslint-plugin-lingui tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: typescript
Required by: eslint-plugin-lingui@virtual:852b4441a6a75c926a70d0844547c3df7516293a0007e3a7[15]

Expected behavior No error

Additional context React 17 Yarn PNP Vite JS

nmoinvaz avatar Jan 02 '25 19:01 nmoinvaz

@swernerx FYI

timofei-iatsenko avatar Jan 03 '25 07:01 timofei-iatsenko

Thanks for the report. Indeed we have added TypeScript support. I was not aware that this was not a listed dependency before. But indeed it is only in dev-dependencies.

I see that our no-unlocalized-strings rule is using types from the typescript package but does not import and functional stuff from it... – at least this was my first thought but indeed TypeFlags is a helper object for checking the flags property in our code.

I don't think it's a good idea to implement the functionality without using the official constants (e.g. replicating it)... as we already have @typescript-eslint/utils in our dependencies it's probably a good idea to add the base typescript package as well... what do you guys think?

swernerx avatar Jan 07 '25 10:01 swernerx

I tried a fix here: https://github.com/lingui/eslint-plugin/pull/98 - this should fix your issue @nmoinvaz

swernerx avatar Jan 07 '25 13:01 swernerx

It still does not fix it in 0.11.0.

vite v7.0.6 building for production...
[sentry-vite-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.
transforming...

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load plugin 'lingui' declared in '.eslintrc.json': eslint-plugin-lingui tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: typescript
Required by: eslint-plugin-lingui@virtual:91eb05eb4d5d0fa7601b3395d27313e6637dd1d0419c897a9cf6ccf923c7a413fc77c257883e15eb01b80a494ff2b66043d6057035c33779921c3335d9dadeb0#npm:0.11.0 (via /home/runner/work/myproject/.yarn/__virtual__/eslint-plugin-lingui-virtual-bc3ce44357/4/.yarn/berry/cache/eslint-plugin-lingui-npm-0.11.0-f7e8d3e826-10c0.zip/node_modules/eslint-plugin-lingui/lib/rules/)

nmoinvaz avatar Sep 23 '25 23:09 nmoinvaz

I took a look at https://github.com/lingui/eslint-plugin/pull/98 and I don't see where typescript is added to your package.json. Can you add it to your dependencies, while still allowing it to load to conditionally (which I assume is what you were trying to do)?

nmoinvaz avatar Oct 03 '25 19:10 nmoinvaz