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

eslint-plugin-import upgrade issues on no-cycle #3113

Open
saravanakumar2504 opened this issue Dec 11, 2024 · 8 comments
Open

eslint-plugin-import upgrade issues on no-cycle #3113

saravanakumar2504 opened this issue Dec 11, 2024 · 8 comments

Comments

@saravanakumar2504
Copy link

saravanakumar2504 commented Dec 11, 2024

The upgrade of eslint-plugin-import from version 2.26.0 to 2.31.0(to support flat config) has resulted in increased processing time for ESLint, primarily due to the import/no-cycle rule. Included screenshot as well

"import/no-cycle": [
      2,
      {
       "maxDepth": null,
       "ignoreExternal": false
      }
    ],

I followed this github thread and played with those configs(like toggling disableScc), but no luck. Can someone assit on this ?

Image

@ljharb
Copy link
Member

ljharb commented Dec 11, 2024

What happens if you set ignoreExternal to true?

@saravanakumar2504
Copy link
Author

saravanakumar2504 commented Dec 12, 2024

@ljharb : Facing same issue after setting ignoreExternal to true
Image

@ljharb
Copy link
Member

ljharb commented Dec 12, 2024

cc @soryy708

@soryy708
Copy link
Contributor

Possible duplicate of #3060
Upgrading from 2.26.0 to 2.31.0 is a superset of upgrading 2.27.5 to 2.31.0.
If somewhere around 2.27.5 there was a performance regression, then upgrading from 2.26.0 would hit the same one, not a distinct one.

@soryy708
Copy link
Contributor

@saravanakumar2504 Can you please share some metadata about the project in which no-cycle performs pathologically?
How many lines of code? How many files? Anything special about the project configuration?
Is it a single project? Or a mono-repository with multiple projects?

As it is it's difficult to pin-point what causes some projects to benefit from SCC and others to be hindered. In a perfect world, a reproduction repository would be great, but practically those are usually proprietary.

@saravanakumar2504
Copy link
Author

@soryy708 : I undersrand your query. Since we are using mono-repo and our project files is very huge(1 lakh file) its difficult for me to mimic it.

@ljharb
Copy link
Member

ljharb commented Dec 13, 2024

(i believe a lakh is 100K)

@saravanakumar2504
Copy link
Author

saravanakumar2504 commented Dec 20, 2024

@soryy708 / @ljharb

I found the minimal config to replicate my issue. Kindly find my eslint.config.js below and when i remove config('import/resolver') its working as expected

'import/resolver': {
			// node needs to be declared first. see https://github.com/benmosher/eslint-plugin-import/issues/1396
			node: {},
			[resolverPath]: {
				debug: false,
			},
		},
const path = require('path');
const babelParser = require('@babel/eslint-parser');
const tsParser = require('@typescript-eslint/parser');
const js = require('@eslint/js');
const globals = require('globals');

const { FlatCompat } = require('@eslint/eslintrc');

const resolverPath = path.resolve(`${__dirname}/build/monorepo-utils/resolvers/eslint-resolver.js`);

const compat = new FlatCompat({
	baseDirectory: __dirname,
	recommendedConfig: js.configs.recommended,
});

const config = [
	...compat.extends(
		'airbnb-base',
		'airbnb/rules/react',
		'prettier',
		'prettier/react',
		'plugin:compat/recommended',
	),
	...compat.plugins(
		'jest',
		'react',
		'react-hooks',
		'json',
		'import',
		'formatjs',
		'@emotion',
	),
	{
		files: ['**/*.{js,jsx,ts,tsx,json}'],
		name: 'base config',
		plugins: {
			jsdoc: require('eslint-plugin-jsdoc'),
			'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
		},
		languageOptions: {
			parser: babelParser,
			globals: {
				...globals.browser,
			},
		},
		settings: {
			'import/extensions': ['.js', '.ts', '.tsx'],
			'import/resolver': {
				// node needs to be declared first. see https://github.com/benmosher/eslint-plugin-import/issues/1396
				node: {},
				[resolverPath]: {
					debug: false,
				},
			},
			'import/parsers': {
				'@babel/eslint-parser': ['.js'],
				'@typescript-eslint/parser': ['.ts', '.tsx'],
			},
		},
	},
	{
		name: 'typescript',
		files: ['**/*.{ts,tsx}'],
		languageOptions: {
			parser: tsParser,
			parserOptions: {
				sourceType: 'module',
				ecmaFeatures: {
					jsx: true,
				},
			},
		},
		rules: {
			'import/no-cycle': 2,
		},
	},
];

module.exports = config;

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

No branches or pull requests

3 participants