The VSCode's extendsion to detect circular dependencies
View in the VSCode extension marketplace
-
Custom Alarm mode:
- Support for configuring alarm levels: error, warning, no warning.
-
Detect circular dependencies:
- Circular dependency detection for JavaScript/TypeScript.
- Identify ESM, CommonJS.
- Support for default suffixes and default index files.
- Identifying aliases, third-party packages, and so on.
- Identify dependencies such as Vite that use glob for bulk imports.
- Identify the comments.
- 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:
- Jump to ring file.
- View the dependency loop diagram.
- Jump any file in a dependent ring.
- 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
Unless otherwise specified, the configuration content is the plugin default.
{
// 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
}
{
// 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"
}
}
{
// 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>"
]
}
{
// 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"
],
// Used to handle boundary issues for large projects.
// File names with specific suffixes are ignored.
// Ignore by default: `.md`、`.d.ts`。
"vscode-circular-dependency.exclude-suffix-list": [
".md",
".d.ts"
],
// Used to handle boundary issues for large projects.
// All files in a specific directory are ignored.
// Ignore by default: `node_modules`。
// Relative/absolute paths are supported, and the default relative project root is used when relative paths are used.
"vscode-circular-dependency.exclude-directories": [
"./node_modules"
],
// Used to handle boundary issues for large projects.
// All imports for a particular module are ignored.
// Will be directly associated with the 'import' statement.
// When configured to 'A/B' , importing 'A/B' , 'A/B/C' , 'A/B/C/D' and so on will be ignored. Used for common purposes such as `monorepo` or `cross-project` usage
"vscode-circular-dependency.exclude-modules": [
"./node_modules"
]
}
- threedayAAAAA suggested the idea of supporting the default index file and the corresponding feature PR
If this project helps you, please sponsor me for a cup of coffee to better provide follow-up services.