Skip to content

Commit

Permalink
build(npm): updates external dependencies + minor refactor
Browse files Browse the repository at this point in the history
Apart from the update
- removes export default where also a regular export exists (which fixes lint issues that stem from a _breaking change_ in the minor eslint-plugin-import update)
- fixes an issue stemming from a breaking change in prettier (which interestingly isn't part of the current bump set ?-/)

Up'em just updated these outdated dependencies in package.json:

@swc/core                         1.7.22   -> 1.7.26   devDependencies   (policy: latest)
@types/node                       22.5.1   -> 22.5.5   devDependencies   (policy: latest)
@typescript-eslint/eslint-plugin  8.3.0    -> 8.6.0    devDependencies   (policy: latest)
@typescript-eslint/parser         8.3.0    -> 8.6.0    devDependencies   (policy: latest)
@vue/compiler-sfc                 3.4.38   -> 3.5.7    devDependencies   (policy: latest)
acorn-walk                        8.3.3    -> 8.3.4    dependencies      (policy: latest)
eslint                            8.57.0   -> 8.57.1   devDependencies   (policy: wanted)
eslint-plugin-import              2.29.1   -> 2.30.0   devDependencies   (policy: latest)
husky                             9.1.5    -> 9.1.6    devDependencies   (policy: latest)
ignore                            5.3.2    -> 6.0.2    dependencies      (policy: latest)
lint-staged                       15.2.9   -> 15.2.10  devDependencies   (policy: latest)
picocolors                        1.0.1    -> 1.1.0    dependencies      (policy: latest)
typescript                        5.5.4    -> 5.6.2    devDependencies   (policy: latest)
  • Loading branch information
sverweij committed Sep 20, 2024
1 parent c7802df commit c96bbaf
Show file tree
Hide file tree
Showing 28 changed files with 384 additions and 351 deletions.
422 changes: 240 additions & 182 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@
"acorn-jsx": "^5.3.2",
"acorn-jsx-walk": "^2.0.0",
"acorn-loose": "^8.4.0",
"acorn-walk": "^8.3.3",
"acorn-walk": "^8.3.4",
"ajv": "^8.17.1",
"commander": "^12.1.0",
"enhanced-resolve": "^5.17.1",
"ignore": "^5.3.2",
"ignore": "^6.0.2",
"interpret": "^3.1.1",
"is-installed-globally": "^1.0.0",
"json5": "^2.2.3",
"memoize": "^10.0.0",
"picocolors": "^1.0.1",
"picocolors": "^1.1.0",
"picomatch": "^4.0.2",
"prompts": "^2.4.2",
"rechoir": "^0.8.0",
Expand All @@ -232,35 +232,35 @@
"@babel/core": "7.25.2",
"@babel/plugin-transform-modules-commonjs": "7.24.8",
"@babel/preset-typescript": "7.24.7",
"@swc/core": "1.7.22",
"@types/node": "22.5.1",
"@swc/core": "1.7.26",
"@types/node": "22.5.5",
"@types/prompts": "2.4.9",
"@typescript-eslint/eslint-plugin": "8.3.0",
"@typescript-eslint/parser": "8.3.0",
"@vue/compiler-sfc": "3.4.38",
"@typescript-eslint/eslint-plugin": "8.6.0",
"@typescript-eslint/parser": "8.6.0",
"@vue/compiler-sfc": "3.5.7",
"c8": "10.1.2",
"clean-pkg-json": "1.2.0",
"coffeescript": "2.7.0",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-moving-meadow": "4.0.2",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-budapestian": "6.0.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-mocha": "10.5.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-security": "3.0.1",
"eslint-plugin-unicorn": "^55.0.0",
"husky": "9.1.5",
"lint-staged": "15.2.9",
"husky": "9.1.6",
"lint-staged": "15.2.10",
"mocha": "10.7.3",
"normalize-newline": "4.1.0",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"proxyquire": "2.1.3",
"svelte": "^4.2.19",
"symlink-dir": "6.0.2",
"typescript": "5.5.4",
"typescript": "5.6.2",
"upem": "9.0.4",
"vue-template-compiler": "2.7.16",
"yarn": "1.22.22"
Expand Down Expand Up @@ -309,4 +309,4 @@
"vue-template-compiler": ">=2.0.0 <3.0.0",
"@vue/compiler-sfc": ">=3.0.0 <4.0.0"
}
}
}
4 changes: 2 additions & 2 deletions src/enrich/summarize/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getModulesCruised,
getDependenciesCruised,
} from "./get-stats.mjs";
import compare from "#graph-utl/compare.mjs";
import { compareViolations } from "#graph-utl/compare.mjs";

/**
*
Expand All @@ -31,7 +31,7 @@ export default function summarize(
) {
const lViolations = summarizeModules(pModules, pOptions.ruleSet)
.concat(summarizeFolders(pFolders || [], pOptions.ruleSet))
.sort(compare.violations);
.sort(compareViolations);

return {
violations: lViolations,
Expand Down
4 changes: 2 additions & 2 deletions src/enrich/summarize/summarize-modules.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isSameViolation from "./is-same-violation.mjs";
import { findRuleByName } from "#graph-utl/rule-set.mjs";
import compare from "#graph-utl/compare.mjs";
import { compareViolations } from "#graph-utl/compare.mjs";
import { uniqWith } from "#utl/array-util.mjs";

function cutNonTransgressions(pModule) {
Expand Down Expand Up @@ -135,7 +135,7 @@ export default function summarizeModules(pModules, pRuleSet) {
return uniqWith(
extractDependencyViolations(pModules, pRuleSet)
.concat(extractModuleViolations(pModules, pRuleSet))
.sort(compare.violations),
.sort(compareViolations),
isSameViolation,
);
}
6 changes: 3 additions & 3 deletions src/extract/acorn/extract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from "node:path";
import extractES6Deps from "./extract-es6-deps.mjs";
import extractCommonJSDeps from "./extract-cjs-deps.mjs";
import extractAMDDeps from "./extract-amd-deps.mjs";
import parse from "./parse.mjs";
import { getASTCached } from "./parse.mjs";
import extractStats from "./extract-stats.mjs";

export function extract(
Expand All @@ -11,7 +11,7 @@ export function extract(
pTranspileOptions,
) {
let lDependencies = [];
const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);

if (moduleSystems.includes("cjs")) {
extractCommonJSDeps(lAST, lDependencies, "cjs", exoticRequireStrings);
Expand All @@ -27,6 +27,6 @@ export function extract(
}

export function getStats({ baseDir }, pFileName, pTranspileOptions) {
const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
return extractStats(lAST);
}
6 changes: 0 additions & 6 deletions src/extract/acorn/parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,3 @@ export const getASTCached = memoize(getAST);
export function clearCache() {
memoizeClear(getASTCached);
}

export default {
getASTFromSource,
getASTCached,
clearCache,
};
12 changes: 6 additions & 6 deletions src/extract/clear-caches.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import tscParse from "./tsc/parse.mjs";
import acornParse from "./acorn/parse.mjs";
import swcParse from "./swc/parse.mjs";
import { clearCache as tscClearCache } from "./tsc/parse.mjs";
import { clearCache as acornClearCache } from "./acorn/parse.mjs";
import { clearCache as swcClearCache } from "./swc/parse.mjs";
import { clearCache as externalModuleHelpers_clearCache } from "./resolve/external-module-helpers.mjs";
import { clearCache as getManifest_clearCache } from "./resolve/get-manifest.mjs";
import { clearCache as resolveAMD_clearCache } from "./resolve/resolve-amd.mjs";
import { clearCache as resolve_clearCache } from "./resolve/resolve.mjs";

export default function clearCaches() {
tscParse.clearCache();
acornParse.clearCache();
swcParse.clearCache();
tscClearCache();
acornClearCache();
swcClearCache();
externalModuleHelpers_clearCache();
getManifest_clearCache();
resolveAMD_clearCache();
Expand Down
8 changes: 3 additions & 5 deletions src/extract/swc/extract.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { join } from "node:path/posix";
import { isTypeScriptCompatible } from "../helpers.mjs";
import extractSwcDeps from "./extract-swc-deps.mjs";
import parse from "./parse.mjs";
import { getASTCached, isAvailable } from "./parse.mjs";

export function shouldUse({ parser }, pFileName) {
return (
parser === "swc" && parse.isAvailable() && isTypeScriptCompatible(pFileName)
);
return parser === "swc" && isAvailable() && isTypeScriptCompatible(pFileName);
}

export function extract(
{ baseDir, exoticRequireStrings, moduleSystems },
pFileName,
) {
return extractSwcDeps(
parse.getASTCached(join(baseDir, pFileName)),
getASTCached(join(baseDir, pFileName)),
exoticRequireStrings,
).filter(({ moduleSystem }) => moduleSystems.includes(moduleSystem));
}
36 changes: 14 additions & 22 deletions src/extract/swc/parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,23 @@ function getAST(pFileName) {
return swc.parseFileSync(pFileName, SWC_PARSE_OPTIONS);
}

/**
* Compiles the file identified by pFileName into an (swc)
* AST and returns it. Subsequent calls for the same file name will
* return the result from a cache
*
* @param {string} pFileName - the name of the file to compile
* @return {import('@swc/core').ModuleItem[]} - an (swc) AST
*/
export const getASTCached = memoize(getAST);

export function clearCache() {
memoizeClear(getASTCached);
}

export default {
getASTFromSource,

/**
* @return {boolean} - true if the swc compiler is available,
* false in all other cases
*/
// @ts-expect-error dfdfd
isAvailable: () => swc !== false,

/**
* Compiles the file identified by pFileName into an (swc)
* AST and returns it. Subsequent calls for the same file name will
* return the result from a cache
*
* @param {string} pFileName - the name of the file to compile
* @return {import('@swc/core').ModuleItem[]} - an (swc) AST
*/
getASTCached,

clearCache,
};
/**
* @return {boolean} - true if the swc compiler is available,
* false in all other cases
*/
// @ts-expect-error dfdfd
export const isAvailable = () => swc !== false;
8 changes: 4 additions & 4 deletions src/extract/tsc/extract.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { join } from "node:path";
import { isTypeScriptCompatible } from "../helpers.mjs";
import extractTypeScriptDeps from "./extract-typescript-deps.mjs";
import parse from "./parse.mjs";
import { getASTCached, isAvailable } from "./parse.mjs";
import extractStats from "./extract-stats.mjs";

export function shouldUse({ tsPreCompilationDeps, parser }, pFileName) {
return (
(tsPreCompilationDeps || parser === "tsc") &&
parse.isAvailable() &&
isAvailable() &&
isTypeScriptCompatible(pFileName)
);
}
Expand All @@ -18,12 +18,12 @@ export function extract(
pTranspileOptions,
) {
return extractTypeScriptDeps(
parse.getASTCached(join(baseDir, pFileName), pTranspileOptions),
getASTCached(join(baseDir, pFileName), pTranspileOptions),
exoticRequireStrings,
).filter(({ moduleSystem }) => moduleSystems.includes(moduleSystem));
}

export function getStats({ baseDir }, pFileName, pTranspileOptions) {
const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
return extractStats(lAST);
}
36 changes: 14 additions & 22 deletions src/extract/tsc/parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,22 @@ function getAST(pFileName, pTranspileOptions) {
);
}

/**
* Compiles the file identified by pFileName into a (typescript)
* AST and returns it. Subsequent calls for the same file name will
* return the result from a cache
*
* @param {string} pFileName - the name of the file to compile
* @return {object} - a (typescript) AST
*/
export const getASTCached = memoize(getAST);

/**
* @return {boolean} - true if the typescript compiler is available,
* false in all other cases
*/
export const isAvailable = () => typescript !== false;

export function clearCache() {
memoizeClear(getASTCached);
}

export default {
getASTFromSource,

/**
* @return {boolean} - true if the typescript compiler is available,
* false in all other cases
*/
isAvailable: () => typescript !== false,

/**
* Compiles the file identified by pFileName into a (typescript)
* AST and returns it. Subsequent calls for the same file name will
* return the result from a cache
*
* @param {string} pFileName - the name of the file to compile
* @return {object} - a (typescript) AST
*/
getASTCached,

clearCache,
};
22 changes: 11 additions & 11 deletions src/graph-utl/compare.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ function severity2number(pSeverity) {
return lSeverity2Number.get(pSeverity) || -1;
}

export function severities(pFirstSeverity, pSecondSeverity) {
export function compareSeverities(pFirstSeverity, pSecondSeverity) {
return Math.sign(
severity2number(pFirstSeverity) - severity2number(pSecondSeverity)
severity2number(pFirstSeverity) - severity2number(pSecondSeverity),
);
}

export function violations(pFirstViolation, pSecondViolation) {
export function compareViolations(pFirstViolation, pSecondViolation) {
return (
severities(pFirstViolation.rule.severity, pSecondViolation.rule.severity) ||
compareSeverities(
pFirstViolation.rule.severity,
pSecondViolation.rule.severity,
) ||
pFirstViolation.rule.name.localeCompare(pSecondViolation.rule.name) ||
pFirstViolation.from.localeCompare(pSecondViolation.from) ||
pFirstViolation.to.localeCompare(pSecondViolation.to)
);
}

export function rules(pLeftRule, pRightRule) {
export function compareRules(pLeftRule, pRightRule) {
return (
severities(pLeftRule.severity, pRightRule.severity) ||
compareSeverities(pLeftRule.severity, pRightRule.severity) ||
pLeftRule.name.localeCompare(pRightRule.name)
);
}

export function modules(pLeftModule, pRightModule) {
export function compareModules(pLeftModule, pRightModule) {
return pLeftModule.source > pRightModule.source ? 1 : -1;
}

export default {
modules,
rules,
severities,
violations,
violations: compareViolations,
};
4 changes: 2 additions & 2 deletions src/graph-utl/consolidate-module-dependencies.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compare from "./compare.mjs";
import { compareRules } from "./compare.mjs";
import { uniq } from "#utl/array-util.mjs";

function mergeDependency(pLeftDependency, pRightDependency) {
Expand All @@ -10,7 +10,7 @@ function mergeDependency(pLeftDependency, pRightDependency) {
),
rules: pLeftDependency.rules
.concat(pRightDependency?.rules ?? [])
.sort(compare.rules),
.sort(compareRules),
valid: pLeftDependency.valid && pRightDependency.valid,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/graph-utl/consolidate-modules.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compare from "./compare.mjs";
import { compareRules } from "./compare.mjs";
import { uniqBy } from "#utl/array-util.mjs";

function mergeModule(pLeftModule, pRightModule) {
Expand All @@ -11,7 +11,7 @@ function mergeModule(pLeftModule, pRightModule) {
),
rules: pLeftModule.rules
.concat(pRightModule?.rules ?? [])
.sort(compare.rules),
.sort(compareRules),
valid: pLeftModule.valid && pRightModule.valid,
consolidated:
Boolean(pLeftModule.consolidated) || Boolean(pRightModule.consolidated),
Expand Down
Loading

0 comments on commit c96bbaf

Please sign in to comment.