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

eslint(import/named) reports `not found` errors in 2.30.0

Open artaommahe opened this issue 1 year ago • 8 comments

After upgrading from 2.29.1 to 2.30.0 we got some not found errors from import/named rule

import Select, { ClearIndicatorProps, GroupBase, OptionProps, Props, createFilter } from 'react-select';
Error:   2:18  error  ClearIndicatorProps not found in 'react-select'  import/named
Error:   2:39  error  GroupBase not found in 'react-select'            import/named
Error:   2:50  error  OptionProps not found in 'react-select'          import/named
Error:   2:63  error  Props not found in 'react-select'                import/named

import { DocumentNode } from 'graphql';
Error:   5:10  error  DocumentNode not found in 'graphql'  import/named

in both cases only imported interfaces are marked with error

artaommahe avatar Sep 04 '24 08:09 artaommahe

if they're types, is there a reason you can't use import type?

ljharb avatar Sep 04 '24 20:09 ljharb

using import type helps, but it requires to do this manually. By default vscode add auto-imports without type. It's not a good idea to force developers manually check imports list and add type to random places (and frequently imports list is just collapsed by default).

artaommahe avatar Sep 05 '24 08:09 artaommahe

I agree, and we do need a lint rule for that (#2390).

In the meantime, let's figure this out. Can you confirm you're using the latest version of the TS resolver?

ljharb avatar Sep 05 '24 18:09 ljharb

This "rule change" seems to be very inconsistent, as it seems to only trigger on external dependencies, at least in our project. Any internal types and interfaces imported as "import { SomeType } from "./someInterface"" are not affected. image

We would very much like to keep using our old importing style, and would appreciate if this, if not a bug, could be configured. This issue seems to happen after upgrading "eslint-module-utils" to version"2.9.0" or above. Our temporary solution has been to pin both "eslint-module-utils" and "eslint-plugin-import" to "2.8.2" and "2.29.0" respectively.

Pespiri avatar Sep 09 '24 06:09 Pespiri

@ljharb what's ts resolver?) just in case "typescript": "5.5.4",

artaommahe avatar Sep 09 '24 08:09 artaommahe

@artaommahe eslint-import-resolver-typescript - it’s required to be able to lint typescript files properly with this plugin; see the readme.

ljharb avatar Sep 09 '24 14:09 ljharb

@ljharb [email protected]

artaommahe avatar Sep 10 '24 07:09 artaommahe

any updates?

hiurylf avatar Sep 17 '24 20:09 hiurylf

Seeing this as well with [email protected]and [email protected].

We're currently disabling the import/named rule and letting typescript handle the import issues as a workaround

clementoriol avatar Dec 11 '24 09:12 clementoriol