Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Circular DependencyNew to Visual Studio Code? Get it now.

Circular Dependency

牡龙

|
115 installs
| (0) | Free
The VSCode's extendsion to detect circular dependency
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Circular Dependency Icon

Circular Dependency

The VSCode's extendsion to detect circular dependencies

View in the VSCode extension marketplace

中文介绍


Features

  • Custom Alarm mode:

    • [x] Support for configuring alarm levels: error, warning, no warning.
  • Detect circular dependencies:

    • [x] Circular dependency detection for JavaScript/TypeScript.
    • [x] Identify ESM, CommonJS.
    • [x] Support for default suffixes and default index files.
    • [x] Identifying aliases, third-party packages, and so on.
    • [x] Identify dependencies such as Vite that use glob for bulk imports.
    • [x] Identify the comments.
    • [x] Custom import syntax, which can be used for circular dependency detection in other languages or other module format syntax by configuring it.
  • View circular dependencies:

    • [x] Jump to ring file.
    • [x] View the dependency loop diagram.
    • [x] Jump any file in a dependent ring.

Usages

  • Basic

  • Support for automatic completion of module suffixes

  • The default index of module is supported

  • Glob import syntax is supported

  • Supports jumping to any dependency in the circular dependency

Configuration

Unless otherwise specified, the configuration content is the plugin default.

Features toggle

{
  // Configure the warning level with an enumeration value: ["error", "warning", "none"].
  "vscode-circular-dependency.error-level": "error",

  // Allows extended persistence of cached data. When enabled, the cached data is recovered after VSCode restart.
  "vscode-circular-dependency.allow-persistent-caching": true,

  // During suspension, a dependency diagram is displayed for circular dependencies, and jumps to the corresponding file are supported
  "vscode-circular-dependency.enable-dependency-loop": false
}

Project environment

{
  // The relative path where the third-party package is stored, which is used to detect whether the dependency is a third-party package, and then ends the branch.
  "vscode-circular-dependency.packages-root": "node_modules",

  // The project path alias is configured, with `key` as the alias and `value` as the actual path to point to.
  // Values are generally relative paths, but absolute paths are also supported.
  // Alias nesting is not supported now.
  "vscode-circular-dependency.alias-map": {
    "@": "src",
    "src": "src",
    "~": "src"
  }
}

Syntax checking

{
  // Comment configuration
  // Only line and block comment characters are supported
  "vscode-circular-dependency.comment-chars": [
    // Configure single-line comments
    ["//"],
    // Configure block comments
    ["/*", "*/"],
    ["/**", "*/"]
  ],

  // Match the regular expression of the import module
  "vscode-circular-dependency.import-statement-regexp": [
    // Match the ESM static import module syntax, such as:
    // `import A from 'xxx'` or `import { xxx } from 'xxx'`
    // `import type {} from 'xxx'` does not match because it does not affect builds and does not cause circular dependencies
    "(?:import\\s+(?:[^\\{\\s]+|\\{(?:.*?)\\})\\s+from\\s+)(?<quote>['\"])(.*?)\\k<quote>",
    // Match the ESM Dynamic Import Module, such as: `import()`
    "(?:import\\s*\\(\\s*)(?<quote>['\"])(.*?)\\k<quote>",
    // Match the CommonJS Dynamic Import Module, such as: `require()`
    "(?:require\\s*\\(\\s*)(?<quote>['\"])(.*?)\\k<quote>"
  ],

  // Match `glob` dynamic import
  "vscode-circular-dependency.glob-import-statement-regexp": [
    // Matches the glob import syntax of Vite
    "(?:import\\.meta\\.glob\\(\\s*)(?<quote>['\"])(.*?)\\k<quote>"
  ]
}

Configure the default behavior for resolving address-dependent

{
  // When the import module is not found, support automatic completion of the file suffix, according to the order of array matching
  "vscode-circular-dependency.autofill-suffix-list": [
    "ts",
    "js",
    "cjs",
    "mjs"
  ],

  // Import module as a directory, automatically find the default file, you need to fill in the full file name, does not support omitting the suffix, according to the array order match
  "vscode-circular-dependency.default-indexs": [
    "index.ts",
    "index.js",
    "index.cjs",
    "index.mjs"
  ]
}

Thanks

  • threedayAAAAA suggested the idea of supporting the default index file and the corresponding feature PR

Sponsor me

If this project helps you, please sponsor me for a cup of coffee to better provide follow-up services.

WeChat ALi

License

GPL License © 2021-Present 牡龙

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft