[Dev] Add non type imports depcruiser check (#5901)

* Forbid non type imports in type and enum files

* Allow orphans in src/@types
This commit is contained in:
Sirz Benjie 2025-06-04 23:57:10 -05:00 committed by GitHub
parent 9dcb904649
commit fb6d6f5b69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,17 @@
/** @type {import('dependency-cruiser').IConfiguration} */ /** @type {import('dependency-cruiser').IConfiguration} */
module.exports = { module.exports = {
forbidden: [ forbidden: [
{
name: "only-type-imports",
severity: "error",
comment: "Files in enums and @types may only use type imports.",
from: {
path: ["(^|/)src/@types", "(^|/)src/enums"],
},
to: {
dependencyTypesNot: ["type-only"],
},
},
{ {
name: "no-circular-at-runtime", name: "no-circular-at-runtime",
severity: "warn", severity: "warn",
@ -31,6 +42,8 @@ module.exports = {
"[.]d[.]ts$", // TypeScript declaration files "[.]d[.]ts$", // TypeScript declaration files
"(^|/)tsconfig[.]json$", // TypeScript config "(^|/)tsconfig[.]json$", // TypeScript config
"(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$", // other configs "(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$", // other configs
// anything in src/@types
"(^|/)src/@types/",
], ],
}, },
to: {}, to: {},