> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-cycle

[Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/no-cycle': 'error',
    },
  },
]);
```

## Rule Details

Ensures that an imported module does not have a resolvable dependency path back
to the linted module.

Examples of **incorrect** code for this rule:

```javascript
// dep-b.js
import "./dep-a.js";

// dep-a.js
import "./dep-b.js";
```

Examples of **correct** code for this rule:

```javascript
// dep-b.js
export const value = 1;

// dep-a.js
import { value } from "./dep-b.js";
```

This rule does not report direct self imports. Use `import/no-self-import` for
that case.

Type-only imports are ignored because they have no runtime effect. Named
type-only re-exports still participate in the dependency graph, matching
`eslint-plugin-import`.

Attribute-selected text and JSON views do not execute the target as a JavaScript module, so their authored dependency graph does not participate in cycle detection. Unknown host-defined loaders are also excluded because their runtime dependency behavior is not statically known.

## Options

### `maxDepth`

Limits how far the rule traverses the dependency graph. The value must be a
positive integer or `"∞"`.

```json
{ "import/no-cycle": ["error", { "maxDepth": 1 }] }
```

### `commonjs`

Checks `require()` calls in addition to ES module imports.

```json
{ "import/no-cycle": ["error", { "commonjs": true }] }
```

### `amd`

Checks AMD `require([...])` and `define([...])` dependencies.

```json
{ "import/no-cycle": ["error", { "amd": true }] }
```

### `ignoreExternal`

Skips modules treated as external, such as modules under `node_modules`.

```json
{ "import/no-cycle": ["error", { "ignoreExternal": true }] }
```

### `allowUnsafeDynamicCyclicDependency`

Allows a cycle when at least one dependency in the cycle is imported with
dynamic `import()`.

```json
{
  "import/no-cycle": [
    "error",
    { "allowUnsafeDynamicCyclicDependency": true }
  ]
}
```

### `esmodule`

Checks ES module `import`/`export` sources. Defaults to `true`; set to
`false` to disable them.

```json
{ "import/no-cycle": ["error", { "esmodule": false }] }
```

### `disableScc`

Accepted for compatibility with upstream configs. Upstream uses this to skip
building a strongly-connected-components graph, an internal traversal
optimization; this rule does not build one either way, so the option has no
observable effect here.

## Original Documentation

- [eslint-plugin-import: no-cycle](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-cycle.md)
- [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-cycle.js)
