Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(init): adds exception to not-to-dev-dep for type-only dependencies #874

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@
"name": "not-to-dev-dep",
"severity": "error",
"comment": "In production code do not depend on external ('npm') modules not declared in your package.json's dependencies - otherwise a production only install (i.e. 'npm ci') will break. If this rule triggers on something that's only used during development, adapt the 'from' of the rule in the dependency-cruiser configuration.",
"from": { "path": "^(bin|src)" },
"from": {
"pathNot": ["^test/", "^tools/"]
},
"to": {
"dependencyTypes": ["npm-dev"],
"exoticallyRequired": false
"exoticallyRequired": false,
"dependencyTypesNot": ["type-only"],
"pathNot": ["node_modules/@types/"]
}
},
{
Expand Down
10 changes: 9 additions & 1 deletion src/cli/init-config/config-template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ module.exports = {
},
to: {
dependencyTypes: [
'npm-dev'
'npm-dev',
],
// type only dependencies are not a problem as they don't end up in the
// production code or are ignored by the runtime.
dependencyTypesNot: [
'type-only'
],
pathNot: [
'node_modules/@types/'
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion types/extract-ts-config.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParsedCommandLine } from "typescript";
import type { ParsedCommandLine } from "typescript";

/**
* Reads the file with name `pTSConfigFileName` and returns its parsed
Expand Down