Skip to content

Commit

Permalink
refactor: uses node imports aliasses in package.json for validate
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Oct 8, 2023
1 parent 76e1f9b commit 3315882
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 31 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"#main/*": "./src/main/*",
"#meta": "./src/meta.js",
"#report/*": "./src/report/*",
"#utl/*": "./src/utl/*"
"#utl/*": "./src/utl/*",
"#validate/*": "./src/validate/*"
},
"exports": {
".": {
Expand Down
4 changes: 2 additions & 2 deletions src/enrich/add-validations.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validate from "../validate/index.mjs";
import validate from "#validate/index.mjs";

function addDependencyViolations(pModule, pDependency, pRuleSet, pValidate) {
return {
Expand Down Expand Up @@ -26,7 +26,7 @@ export default function addValidations(pModules, pRuleSet, pValidate) {
...pModule,
...(pValidate ? validate.module(pRuleSet, pModule) : { valid: true }),
dependencies: pModule.dependencies.map((pDependency) =>
addDependencyViolations(pModule, pDependency, pRuleSet, pValidate)
addDependencyViolations(pModule, pDependency, pRuleSet, pValidate),
),
}));
}
6 changes: 3 additions & 3 deletions src/enrich/derive/folders/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import validate from "../../../validate/index.mjs";
import aggregateToFolders from "./aggregate-to-folders.mjs";
import validate from "#validate/index.mjs";

/**
* @param {import("../../../../types/dependency-cruiser.js").IFolder} pFolder
Expand All @@ -18,7 +18,7 @@ function addFolderDependencyViolations(pOptions) {
...pFolder,

dependencies: pFolder.dependencies.map(
validateFolderDependency(pFolder, pOptions)
validateFolderDependency(pFolder, pOptions),
),
});
}
Expand All @@ -34,7 +34,7 @@ export default function deriveFolderMetrics(pModules, pOptions) {
if (pOptions.metrics) {
lReturnValue = {
folders: aggregateToFolders(pModules).map(
addFolderDependencyViolations(pOptions)
addFolderDependencyViolations(pOptions),
),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/enrich/derive/reachable.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable security/detect-object-injection, no-inline-comments */
import has from "lodash/has.js";
import matchers from "../../validate/matchers.mjs";
import matchers from "#validate/matchers.mjs";
import IndexedModuleGraph from "#graph-utl/indexed-module-graph.mjs";
import { extractGroups } from "#utl/regex-util.mjs";

Expand Down
2 changes: 1 addition & 1 deletion test/configs/no-orphans.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { equal } from "node:assert/strict";
import noOrphansRule from "../../configs/rules/no-orphans.js";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

describe("[I] configs/rules/no-orphans", () => {
it("flags non-excepted orphans as orphan rule transgression", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.core.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - core", () => {
const lNotToCoreRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.could-not-resolve.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - couldNotResolve", () => {
const lNotToUnresolvableRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.cycle-via-not.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index dependency - cycle viaNot", () => {
const lCycleViaNotRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.cycle-via-some-not.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index dependency - cycle viaSomeNot - with group matching", () => {
const lCycleButNotViaGroupMatchRuleSet = {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.cycle-via.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index dependency - cycle via", () => {
const lCycleViaRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.exotic-require.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - exoticallyRequired", () => {
const lExoticallyRequiredRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.groupmatching.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index group matching - path group matched in a pathnot", () => {
const lGroupToPathNotRuleSet = {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.license.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - license", () => {
const lLicenseRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.more-than-one-dependency-type.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] index/validate - moreThanOneDependencyType", () => {
it(`no relations with modules of > 1 dep type (e.g. specified 2x in package.json)`, () => {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.more-unstable.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - stability checks", () => {
const lForbiddenRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.orphans.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - orphans", () => {
const lOrphanRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.pre-compilation-only.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - preCompilationOnly", () => {
const lPreCompilationOnlyRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.reachable.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - reachable (in forbidden set)", () => {
const lReachableFalseRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.required-rules.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index - required rules", () => {
const lRequiredRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] validate/index dependency - generic tests", () => {
it("is ok with the empty validation", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/index.type-only.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual } from "node:assert/strict";
import validate from "../../src/validate/index.mjs";
import parseRuleSet from "./parse-ruleset.utl.mjs";
import validate from "#validate/index.mjs";

describe("[I] [I] validate/index - type-only", () => {
const lTypeOnlyRuleSet = parseRuleSet({
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-folder-dependency-rule.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchFolderRule from "../../src/validate/match-folder-dependency-rule.mjs";
import matchFolderRule from "#validate/match-folder-dependency-rule.mjs";

describe("[I] validate/match-folder-dependency-rule - match generic", () => {
const lEmptyRule = { scope: "folder", from: {}, to: {} };
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-module-rule.dependents.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

const EMPTY_RULE = { from: {}, module: {} };
const ANY_DEPENDENTS = {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-module-rule.orphan.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

const EMPTY_RULE = { from: {}, to: {} };
const ANY_ORPHAN = { from: { orphan: true }, to: {} };
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-module-rule.reachable.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

const EMPTY_RULE = { from: {}, to: {} };
const ANY_UNREACHABLE = {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-module-rule.reaches.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

const EMPTY_RULE = { from: {}, to: {} };
const ANY_REACHABLE = {
Expand Down
2 changes: 1 addition & 1 deletion test/validate/match-module-rule.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import matchModuleRule from "../../src/validate/match-module-rule.mjs";
import matchModuleRule from "#validate/match-module-rule.mjs";

const EMPTY_RULE = { from: {}, to: {} };
const ORPHAN_RULE = { from: { orphan: true }, to: {} };
Expand Down
2 changes: 1 addition & 1 deletion test/validate/violates-required-rule.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal } from "node:assert/strict";
import violatesRequiredRule from "../../src/validate/violates-required-rule.mjs";
import violatesRequiredRule from "#validate/violates-required-rule.mjs";

const SIMPLE_RULE = {
module: {
Expand Down

0 comments on commit 3315882

Please sign in to comment.