`no-cycle` does not raise error on circular dependency?
See original GitHub issueThere are three files:
src/a.ts
:
import y from "./b";
const x: number = y + 1;
export default x;
src/b.ts
:
import x from "./a";
const y: number = x + 1;
export default y;
src/c.ts
:
import x from "./a";
import y from "./b";
console.log(x, y);
and the configuration is:
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"plugins": [
"@typescript-eslint",
"import"
],
"parser": "@typescript-eslint/parser",
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [
".ts",
".tsx"
]
}
},
"rules": {
"import/no-cycle": [
"error",
{
"maxDepth": 10,
"ignoreExternal": true
}
]
}
}
Given the command
$ yarn eslint src\c.ts
yarn run v1.22.10
$ D:\Projects\graphact\server\node_modules\.bin\eslint src\c.ts
Done in 2.03s.
no error occurs while c.ts
imports both a.ts
and b.ts
, which are circular importing each other!
Is it the desired behavior, or I missed something?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:5 (1 by maintainers)
Top Results From Across the Web
no-cycle does not raise error on circular dependency? #2004
no error occurs while c.ts imports both a.ts and b.ts , which are circular importing each other! Is it the desired behavior, ...
Read more >How to config the `no-cycle` rule in eslint-plugin-import for ...
It won't raise the lint error in c.ts file because the circular dependency is between a.ts and b.ts . ESLint no-cycle rule description....
Read more >How to fix nasty circular dependency issues once and for all in ...
Luckily, as I will demonstrate below, there is a consistent way in which these dependency issues can be fixed. The case. The module...
Read more >How to Analyze Circular Dependencies in ES6? - Railsware
It is caused by circular dependencies that cannot be resolved synchronously by webpack. One is undefined, hence the error.
Read more >API with NestJS #61. Dealing with circular dependencies
The rule that we want is called import/no-cycle, and it ensures that no circular dependencies are present between our files. In our NestJS ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still not working after adding
import/extensions
.I setup a test project on https://github.com/Yaojian/no-cycle-test
Check out #2103.
The next step here, I think, is to install
eslint-plugin-import
via setting a specific commit ID in the package.json and to test if we can find a commit where either of these bugs were not present. There’s not many commits, so most of the work involved here (should) be just starting/stopping costs of taking on a next task and waiting for npm installs.