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 3032dda
Show file tree
Hide file tree
Showing 18 changed files with 2,763 additions and 2,720 deletions.
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
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
2 changes: 1 addition & 1 deletion src/extract/resolve/external-module-helpers.mjs
Original file line number Diff line number Diff line change
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
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
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
6 changes: 3 additions & 3 deletions src/main/rule-set/normalize.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DEFAULT_RULE = "unnamed";
const DEFAULT_SCOPE = "module";

function normalizeSeverity(pSeverity) {
const lSeverity = pSeverity ? pSeverity : DEFAULT_SEVERITY;
const lSeverity = pSeverity ?? DEFAULT_SEVERITY;

return VALID_SEVERITIES.test(lSeverity) ? lSeverity : DEFAULT_SEVERITY;
}
Expand All @@ -26,15 +26,15 @@ function normalizeSeverity(pSeverity) {
* @returns {string}
*/
function normalizeName(pRuleName) {
return pRuleName ? pRuleName : DEFAULT_RULE;
return pRuleName ?? DEFAULT_RULE;
}

/**
* @param {RuleScopeType} pScope?
* @returns {RuleScopeType}
*/
function normalizeScope(pScope) {
return pScope ? pScope : DEFAULT_SCOPE;
return pScope ?? DEFAULT_SCOPE;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/report/dot-webpage/svg-in-html-snippets/script.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getHoverHandler(pTitle2ElementMap) {
var closestTitleText = getTitleText(closestNodeOrEdge);

if (
!(currentHighlightedTitle === closestTitleText) &&
currentHighlightedTitle !== closestTitleText &&
gMode.get() === gMode.HOVER
) {
resetNodesAndEdges();
Expand All @@ -40,12 +40,12 @@ function getSelectHandler(pTitle2ElementMap) {
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 @@ -216,7 +216,7 @@ function addHighlight(pGroup) {
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/utl/get-extension.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { extname } from "node:path";

const EXTENSION_RE = /(?<extension>(?:(?:\.d\.(?:c|m)?ts)|\.coffee\.md)$)/;
const EXTENSION_RE = /(?<extension>(?:(?:\.d\.(?:[cm])?ts)|\.coffee\.md)$)/;

/**
* Returns the extension of the given file name path.
Expand Down
2 changes: 1 addition & 1 deletion tools/overview.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 types/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="1027pt" height="350pt"
Expand Down Expand Up @@ -732,7 +732,7 @@
var closestTitleText = getTitleText(closestNodeOrEdge);

if (
!(currentHighlightedTitle === closestTitleText) &&
currentHighlightedTitle !== closestTitleText &&
gMode.get() === gMode.HOVER
) {
resetNodesAndEdges();
Expand All @@ -754,12 +754,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 @@ -930,7 +930,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 types/overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3032dda

Please sign in to comment.