Skip to content

Commit

Permalink
refactor: addresses small linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Nov 22, 2024
1 parent 09e9e41 commit aae6edd
Show file tree
Hide file tree
Showing 34 changed files with 2,843 additions and 2,789 deletions.
2 changes: 1 addition & 1 deletion bin/depcruise-baseline.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {
.arguments("<files-or-directories>")
.parse(process.argv);

if (Boolean(program.args[0])) {
if (program.args[0]) {
process.exitCode = await cli(program.args, {
...program.opts(),
cache: false,
Expand Down
2 changes: 1 addition & 1 deletion doc/assets/filtering/focus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/real-world-samples/dependency-cruiser-archi-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/real-world-samples/dependency-cruiser-dir-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,696 changes: 1,360 additions & 1,336 deletions doc/real-world-samples/dependency-cruiser-without-node_modules.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/dependency-cruiser-archi-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
<!-- Generated by graphviz version 12.2.0 (20241103.1931)
-->
<!-- Title: dependency&#45;cruiser output Pages: 1 -->
<svg width="310pt" height="278pt"
Expand Down Expand Up @@ -470,7 +470,7 @@
var closestTitleText = getTitleText(closestNodeOrEdge);

if (
!(currentHighlightedTitle === closestTitleText) &&
currentHighlightedTitle !== closestTitleText &&
gMode.get() === gMode.HOVER
) {
resetNodesAndEdges();
Expand All @@ -492,12 +492,12 @@
var closestNodeOrEdge = pMouseEvent.target.closest(".edge, .node");
var closestTitleText = getTitleText(closestNodeOrEdge);

if (!!closestNodeOrEdge) {
if (closestNodeOrEdge) {
gMode.setToSelect();
} else {
gMode.setToHover();
}
if (!(currentHighlightedTitle === closestTitleText)) {
if (currentHighlightedTitle !== closestTitleText) {
resetNodesAndEdges();
addHighlight(closestNodeOrEdge);
pTitle2ElementMap.get(closestTitleText).forEach(addHighlight);
Expand Down Expand Up @@ -668,7 +668,7 @@
var gHints = {
HIDDEN: 1,
SHOWN: 2,
state: this.HIDDEN,
state: 1, // === HIDDEN
show: function () {
document.getElementById("hints").removeAttribute("style");
gHints.state = gHints.SHOWN;
Expand Down
2,704 changes: 1,364 additions & 1,340 deletions docs/dependency-cruiser-dependency-graph.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/dependency-cruiser-dir-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
<!-- Generated by graphviz version 12.2.0 (20241103.1931)
-->
<!-- Title: dependency&#45;cruiser output Pages: 1 -->
<svg width="1357pt" height="475pt"
Expand Down Expand Up @@ -1149,7 +1149,7 @@
var closestTitleText = getTitleText(closestNodeOrEdge);

if (
!(currentHighlightedTitle === closestTitleText) &&
currentHighlightedTitle !== closestTitleText &&
gMode.get() === gMode.HOVER
) {
resetNodesAndEdges();
Expand All @@ -1171,12 +1171,12 @@
var closestNodeOrEdge = pMouseEvent.target.closest(".edge, .node");
var closestTitleText = getTitleText(closestNodeOrEdge);

if (!!closestNodeOrEdge) {
if (closestNodeOrEdge) {
gMode.setToSelect();
} else {
gMode.setToHover();
}
if (!(currentHighlightedTitle === closestTitleText)) {
if (currentHighlightedTitle !== closestTitleText) {
resetNodesAndEdges();
addHighlight(closestNodeOrEdge);
pTitle2ElementMap.get(closestTitleText).forEach(addHighlight);
Expand Down Expand Up @@ -1347,7 +1347,7 @@
var gHints = {
HIDDEN: 1,
SHOWN: 2,
state: this.HIDDEN,
state: 1, // === HIDDEN
show: function () {
document.getElementById("hints").removeAttribute("style");
gHints.state = gHints.SHOWN;
Expand Down
10 changes: 5 additions & 5 deletions docs/schema-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
<!-- Generated by graphviz version 12.2.0 (20241103.1931)
-->
<!-- Title: dependency&#45;cruiser output Pages: 1 -->
<svg width="962pt" height="762pt"
Expand Down Expand Up @@ -865,7 +865,7 @@
var closestTitleText = getTitleText(closestNodeOrEdge);

if (
!(currentHighlightedTitle === closestTitleText) &&
currentHighlightedTitle !== closestTitleText &&
gMode.get() === gMode.HOVER
) {
resetNodesAndEdges();
Expand All @@ -887,12 +887,12 @@
var closestNodeOrEdge = pMouseEvent.target.closest(".edge, .node");
var closestTitleText = getTitleText(closestNodeOrEdge);

if (!!closestNodeOrEdge) {
if (closestNodeOrEdge) {
gMode.setToSelect();
} else {
gMode.setToHover();
}
if (!(currentHighlightedTitle === closestTitleText)) {
if (currentHighlightedTitle !== closestTitleText) {
resetNodesAndEdges();
addHighlight(closestNodeOrEdge);
pTitle2ElementMap.get(closestTitleText).forEach(addHighlight);
Expand Down Expand Up @@ -1063,7 +1063,7 @@
var gHints = {
HIDDEN: 1,
SHOWN: 2,
state: this.HIDDEN,
state: 1, // === HIDDEN
show: function () {
document.getElementById("hints").removeAttribute("style");
gHints.state = gHints.SHOWN;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function setUpListener(pCruiseOptions) {

const lListenerFunction = lString2Listener.get(lListenerID);
/* c8 ignore next 6 */
if (Boolean(lListenerFunction)) {
if (lListenerFunction) {
lListenerFunction(
bus,
pCruiseOptions?.ruleSet?.options?.progress?.maximumLevel ?? INFO,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/listeners/performance-log/format-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function formatMessage(pMessage, pLevel) {
export function formatTime(
pNumber,
pConversionMultiplier = MS_PER_SECOND,
pLevel,
pLevel = INFO,
) {
return formatMessage(
gTimeFormat(pConversionMultiplier * pNumber)
Expand Down
3 changes: 1 addition & 2 deletions src/cli/utl/io.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ function writeToFile(pOutputTo, pDependencyString) {
*/
function writeToStdOut(pString, pBufferSize = PIPE_BUFFER_SIZE) {
const lNumberOfChunks = Math.ceil(pString.length / pBufferSize);
let lIndex = 0;

/* eslint no-plusplus: 0 */
for (lIndex = 0; lIndex < lNumberOfChunks; lIndex++) {
for (let lIndex = 0; lIndex < lNumberOfChunks; lIndex++) {
const lChunkStart = lIndex * pBufferSize;
process.stdout.write(
pString.substring(lChunkStart, lChunkStart + pBufferSize),
Expand Down
8 changes: 4 additions & 4 deletions src/config-utl/extract-known-violations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import makeAbsolute from "./make-absolute.mjs";
*/
function makeForwardCompatible(pKnownViolation) {
let lReturnValue = pKnownViolation;
if (Boolean(pKnownViolation.cycle)) {
if (pKnownViolation.cycle) {
lReturnValue = {
...pKnownViolation,
cycle: pKnownViolation.cycle.map((pModule) => {
if (Boolean(pModule.name)) {
if (pModule.name) {
return pModule;
}
return {
Expand All @@ -35,11 +35,11 @@ function makeForwardCompatible(pKnownViolation) {
}),
};
}
if (Boolean(pKnownViolation.via)) {
if (pKnownViolation.via) {
lReturnValue = {
...pKnownViolation,
via: pKnownViolation.via.map((pModule) => {
if (Boolean(pModule.name)) {
if (pModule.name) {
return pModule;
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/enrich/soften-known-violations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function softenKnownViolations(
pKnownViolations,
pSoftenedSeverity = "ignore",
) {
if (Boolean(pKnownViolations)) {
if (pKnownViolations) {
bus.info("analyzing: comparing against known errors");
return pModules.map((pModule) =>
softenKnownViolation(pModule, pKnownViolations, pSoftenedSeverity),
Expand Down
4 changes: 2 additions & 2 deletions src/extract/extract-dependencies.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ function extractDependencies(pCruiseOptions, pFileName, pTranspileOptions) {
}

function matchesDoNotFollow({ resolved, dependencyTypes }, pDoNotFollow) {
const lMatchesPath = Boolean(pDoNotFollow.path)
const lMatchesPath = pDoNotFollow.path
? RegExp(pDoNotFollow.path, "g").test(resolved)
: false;
const lMatchesDependencyTypes = Boolean(pDoNotFollow.dependencyTypes)
const lMatchesDependencyTypes = pDoNotFollow.dependencyTypes
? intersects(dependencyTypes, pDoNotFollow.dependencyTypes)
: false;

Expand Down
4 changes: 2 additions & 2 deletions src/extract/resolve/determine-dependency-types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function determineManifestDependencyTypes(
/** @type {DependencyType[]} */
let lReturnValue = ["npm-unknown"];

if (Boolean(pPackageDependencies)) {
if (pPackageDependencies) {
lReturnValue = findModuleInPackageDependencies(
pPackageDependencies,
pModuleName,
Expand Down Expand Up @@ -89,7 +89,7 @@ function determineManifestDependencyTypes(
function dependencyIsBundled(pModule, pPackageDeps) {
let lReturnValue = false;

if (Boolean(pPackageDeps)) {
if (pPackageDeps) {
const lBundledDependencies =
pPackageDeps.bundledDependencies || pPackageDeps.bundleDependencies;

Expand Down
8 changes: 4 additions & 4 deletions src/extract/resolve/external-module-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { isScoped, isRelativeModuleName } from "./module-classifiers.mjs";
* @return {string} the module name root
*/
export function getPackageRoot(pModule) {
if (!Boolean(pModule) || isRelativeModuleName(pModule)) {
if (!pModule || isRelativeModuleName(pModule)) {
return pModule;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ function bareGetPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
try {
const lPackageJsonFilename = resolve(
join(getPackageRoot(pModuleName), "package.json"),
pFileDirectory ? pFileDirectory : process.cwd(),
pFileDirectory ?? process.cwd(),
{
...pResolveOptions,
// if a module has exports fields _and_ does not expose package.json
Expand Down Expand Up @@ -129,7 +129,7 @@ export function dependencyIsDeprecated(
pResolveOptions,
);

if (Boolean(lPackageJson)) {
if (lPackageJson) {
lReturnValue =
Object.hasOwn(lPackageJson, "deprecated") && lPackageJson.deprecated;
}
Expand All @@ -154,7 +154,7 @@ export function getLicense(pModuleName, pFileDirectory, pResolveOptions) {
);

if (
Boolean(lPackageJson) &&
lPackageJson &&
Object.hasOwn(lPackageJson, "license") &&
typeof lPackageJson.license === "string"
) {
Expand Down
4 changes: 2 additions & 2 deletions src/extract/resolve/module-classifiers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
// an object. To prevent the code from borking we check whether it's an array
// see https://github.com/sverweij/dependency-cruiser/issues/919
const lWorkspaces = getWorkspacesArray(pManifest?.workspaces);
if (lWorkspaces.length >= 0) {
if (lWorkspaces.length > 0) {
// workspaces are an array of globs that match the (sub) workspace
// folder itself only.
//
Expand Down Expand Up @@ -193,7 +193,7 @@ function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
// of the workspace, not the path of the workspace itself. So if it's
// in node_modules we need to check against the unresolved modulename.
//
// Other then the detection for when symlinks are resolved to their realpath
// Other than the detection for when symlinks are resolved to their realpath
// (the if above), this is a 'best effort' detection only for now; there's
// guaranteed to be scenarios where this will fail. How often is the
// --preserve-symlinks flag used in practice, though?
Expand Down
6 changes: 3 additions & 3 deletions src/extract/resolve/resolve-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export function addLicenseAttribute(
pModuleName,
pResolvedModuleName,
{ baseDirectory, fileDirectory },
pResolveOptions
pResolveOptions,
) {
let lReturnValue = {};
if (
pResolveOptions.resolveLicenses &&
isExternalModule(
pResolvedModuleName,
pResolveOptions.modules,
baseDirectory
baseDirectory,
)
) {
const lLicense = getLicense(pModuleName, fileDirectory, pResolveOptions);

if (Boolean(lLicense)) {
if (lLicense) {
lReturnValue.license = lLicense;
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/extract/swc/dependency-visitor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function argumentsAreUsable(pArguments) {
["StringLiteral", "TemplateLiteral"].includes(
pArguments[0].expression.type,
) &&
(!(pArguments[0].expression.type === "TemplateLiteral") ||
(pArguments[0].expression.type !== "TemplateLiteral" ||
isPlaceholderlessTemplateLiteral(pArguments[0]))
);
}
Expand Down Expand Up @@ -250,11 +250,7 @@ export default Visitor
// as visitors for some shapes of type annotations aren't completely
// implemented yet (1.2.51) pNode can come in as null (also see
// comments in accompanying unit test)
if (
Boolean(pNode) &&
Boolean(pNode.typeAnnotation) &&
Boolean(pNode.typeAnnotation.argument)
)
if (pNode && pNode.typeAnnotation && pNode.typeAnnotation.argument)
this.lResult.push({
module: pNode.typeAnnotation.argument.value,
moduleSystem: "es6",
Expand Down
Loading

0 comments on commit aae6edd

Please sign in to comment.