Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not found in imported package from eslint(import/named) #210

Open
demosofa opened this issue Dec 18, 2024 · 1 comment
Open

Not found in imported package from eslint(import/named) #210

demosofa opened this issue Dec 18, 2024 · 1 comment

Comments

@demosofa
Copy link

Description

I got this error when trying to migrate eslint 8.57 to latest version which is eslint 9.17. I have followed both doc from this package and eslint-import-resolver-typescript nothing worked.

  • Result

image

  • Here is my eslint.config.mjs
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslintJS from '@eslint/js';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import _import from 'eslint-plugin-import';
import unusedImports from 'eslint-plugin-unused-imports';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tsEslint from 'typescript-eslint';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
	baseDirectory: __dirname,
	recommendedConfig: eslintJS.configs.recommended,
	allConfig: eslintJS.configs.all
});

export default tsEslint.config(
	{
		ignores: ['**/next/', '**/dist/', '**/node_modules/', '**/*.js']
	},
	fixupConfigRules(compat.extends('next/core-web-vitals', 'prettier')),
	tsEslint.configs.strictTypeChecked,
	tsEslint.configs.stylisticTypeChecked,
	_import.flatConfigs.recommended,
	_import.flatConfigs.typescript,
	{
		plugins: {
			'unused-imports': unusedImports,
			import: fixupPluginRules(_import)
		},

		languageOptions: {
			parserOptions: {
				projectService: true,
				tsconfigRootDir: import.meta.dirname
			}
		},

		settings: {
			'import/resolver-next': [
				createTypeScriptImportResolver({
					alwaysTryTypes: true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
				})
			]
		},

		rules: {
			'prefer-const': [
				'error',
				{
					destructuring: 'all',
					ignoreReadBeforeAssign: false
				}
			],

			'no-duplicate-imports': 'error',
			'no-duplicate-case': 'error',
			'import/named': 'error',
			'import/default': 'error',
			'import/namespace': 'error',
			'import/no-unresolved': 'error',
			'import/no-duplicates': 'error',
			'@typescript-eslint/no-empty-object-type': 'warn',
			'@typescript-eslint/consistent-type-definitions': 'warn',
			'@typescript-eslint/array-type': 'warn',
			'@typescript-eslint/prefer-nullish-coalescing': 'warn',
			'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
			'@typescript-eslint/no-dynamic-delete': 'warn',
			'@typescript-eslint/no-unsafe-return': 'warn',
			'@typescript-eslint/no-unsafe-argument': 'warn',
			'@typescript-eslint/no-extraneous-class': 'off',
			'@typescript-eslint/no-base-to-string': 'off',
			'@typescript-eslint/prefer-promise-reject-errors': 'off',
			'@typescript-eslint/no-confusing-void-expression': 'warn',
			'@typescript-eslint/no-empty-function': 'off',
			'@typescript-eslint/restrict-template-expressions': [
				'error',
				{
					allowNumber: true
				}
			],
			'@typescript-eslint/no-unsafe-assignment': 'warn',
			'@typescript-eslint/no-var-requires': 'off',
			'@typescript-eslint/no-unused-vars': 'off',
			'no-unused-vars': 'off',
			'unused-imports/no-unused-imports': 'error',
			'unused-imports/no-unused-vars': [
				'warn',
				{
					vars: 'all',
					varsIgnorePattern: '^_',
					args: 'after-used',
					argsIgnorePattern: '^_'
				}
			]
		}
	}
);
  • Here is my installed packages
├── @commitlint/[email protected]
├── @commitlint/[email protected]
├── @eslint/[email protected]
├── @eslint/[email protected]
├── @eslint/[email protected]
├── @next/[email protected]
├── @reduxjs/[email protected]
├── @sentry/[email protected]
├── @tiptap/[email protected]
├── @tiptap/[email protected]
├── @tiptap/[email protected]
├── @tiptap/[email protected]
├── @tiptap/[email protected]
├── @tiptap/[email protected]
├── @trivago/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── eslint-plugin-import@npm:[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
@SukkaW
Copy link
Collaborator

SukkaW commented Dec 18, 2024

Thanks for your detailed report! I will look into this, but currently I am focusing on landing #208 now.

In the meantime, a minimum reproduction (with only the cloudinary and relevant eslint plugins and resolvers installed, only a index.ts file, and a bare minimum eslint.config.mjs) would be much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants