Open arpowers opened 10 months ago
any update on this? @antfu as a work around, if there is a better way to make sure there are no circular imports I'm interested.
I don't know. I am not using that rule and not sure if it's a problem with this config or the plugin - Investigating yourself might get your problem solved faster.
Hi, @arpowers
I found that this issue might caused by eslint-plugin-import
doesn't support flatConfig, see https://github.com/un-ts/eslint-plugin-import-x/issues/29
But we could use @eslint/eslintrc
compact as a workaround 👇
I'm not sure if it's the best workaround, at least it works for me. Also, I don't know how to override the import settings in antfu()
composer, looks like import
doesn't provide override options like other rule sets (for example react
)
import { combine, javascript, renamePluginInConfigs, typescript } from '@antfu/eslint-config';
import { FlatCompat } from '@eslint/eslintrc';
import importPlugin from 'eslint-plugin-import-x';
const compat = new FlatCompat({});
export default combine(
javascript(),
typescript(),
// rename the `import-x` to `import` to keep sync with antfu default naming
renamePluginInConfigs([...compat.config(importPlugin.configs.recommended), importPlugin.configs.typescript], { 'import-x': 'import' }),
[{
rules: {
'import/no-cycle': 'error',
},
}],
);
eslint-plugin-import-x
doesn't have built-in flat config exports, but almost all rules work with flat config (except no-unused-modules
). You can always compose your own flat config just like how @antfu/eslint-config
already did. No compat util is needed.
Hi @SukkaW
You are right.
Adding these settings into antfu config also makes the import/no-cycle rule work.
{
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
'import-x/resolver': {
node: {
extensions: ['.ts'],
},
},
},
}
Describe the bug
One of the handiest eslint rules is the no-cycle rule which detects circular imports (because these can be such a nightmare)
However, the rule doesn't appear to be working inside this library.
Config:
Reproduction
https://github.com/arpowers/eslint-testing
System Info
Used Package Manager
npm
Validations