-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(enrich): converts to esm (#786)
- Loading branch information
Showing
39 changed files
with
200 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...nrich/derive/dependents/get-dependents.js → ...rich/derive/dependents/get-dependents.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const { isDependent } = require("../module-utl"); | ||
import { isDependent } from "../module-utl.mjs"; | ||
|
||
module.exports = function getDependents(pModule, pModules) { | ||
export default function getDependents(pModule, pModules) { | ||
// perf between O(n) in an unconnected graph and O(n^2) in a fully connected one | ||
return pModules | ||
.filter(isDependent(pModule.source)) | ||
.map((pDependentModule) => pDependentModule.source); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import getDependents from "./get-dependents.mjs"; | ||
|
||
export default function addDependents(pModules) { | ||
return pModules.map((pModule) => ({ | ||
...pModule, | ||
dependents: getDependents(pModule, pModules), | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import validate from "../../../validate/index.js"; | ||
import aggregateToFolders from "./aggregate-to-folders.mjs"; | ||
|
||
/** | ||
* @param {import("../../../../types/dependency-cruiser.js").IFolder} pFolder | ||
* @param {import('../../../../types/dependency-cruiser.js').IOptions} pOptions | ||
* @returns | ||
*/ | ||
function validateFolderDependency(pFolder, pOptions) { | ||
return (pDependency) => ({ | ||
...pDependency, | ||
...validate.folder(pOptions.ruleSet || {}, pFolder, pDependency), | ||
}); | ||
} | ||
|
||
function addFolderDependencyViolations(pOptions) { | ||
return (pFolder) => ({ | ||
...pFolder, | ||
|
||
dependencies: pFolder.dependencies.map( | ||
validateFolderDependency(pFolder, pOptions) | ||
), | ||
}); | ||
} | ||
|
||
/** | ||
* | ||
* @param {import('../../../../types/dependency-cruiser.js').IModule[]} pModules | ||
* @param {import('../../../../types/dependency-cruiser.js').IOptions} pOptions | ||
* @returns {any} | ||
*/ | ||
export default function deriveFolderMetrics(pModules, pOptions) { | ||
let lReturnValue = {}; | ||
if (pOptions.metrics) { | ||
lReturnValue = { | ||
folders: aggregateToFolders(pModules).map( | ||
addFolderDependencyViolations(pOptions) | ||
), | ||
}; | ||
} | ||
return lReturnValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/enrich/derive/metrics/index.js → src/enrich/derive/metrics/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
const { | ||
import { | ||
addInstabilityMetric, | ||
deNormalizeInstabilityMetricsToDependencies, | ||
} = require("./get-module-metrics"); | ||
} from "./get-module-metrics.mjs"; | ||
|
||
module.exports = function deriveModulesMetrics(pModules, pOptions) { | ||
export default function deriveModulesMetrics(pModules, pOptions) { | ||
if (pOptions.metrics) { | ||
return pModules | ||
.map(addInstabilityMetric) | ||
.map(deNormalizeInstabilityMetricsToDependencies); | ||
} | ||
return pModules; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/enrich/derive/orphan/index.js → src/enrich/derive/orphan/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const isOrphan = require("./is-orphan"); | ||
import isOrphan from "./is-orphan.mjs"; | ||
|
||
module.exports = function deriveOrphans(pModules) { | ||
export default function deriveOrphans(pModules) { | ||
return pModules.map((pModule) => ({ | ||
...pModule, | ||
orphan: isOrphan(pModule, pModules), | ||
})); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.