Skip to content

Commit

Permalink
build(npm): ⬆️ @babel/core, @babel/plugin-transform-modules-commonjs,…
Browse files Browse the repository at this point in the history
… @typescript-eslint/eslint-plugin, @typescript-eslint/parser, acorn, acorn-loose, ajv, eslint, eslint-config-moving-meadow, eslint-config-prettier, eslint-plugin-budapestian, eslint-plugin-unicorn, lint-staged, mocha, upem
  • Loading branch information
sverweij committed Oct 17, 2020
1 parent 351031c commit da52418
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 137 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"extends": ["moving-meadow"],
"rules": {
"security/detect-non-literal-fs-filename": "off",
"unicorn/no-null": "off"
"unicorn/no-null": "off",
"unicorn/prefer-string-slice": "off"
},
"overrides": [
{
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@
"version": "npm-run-all build depcruise:graph:doc scm:stage"
},
"dependencies": {
"acorn": "8.0.3",
"acorn-loose": "8.0.0",
"acorn": "8.0.4",
"acorn-loose": "8.0.1",
"acorn-walk": "8.0.0",
"ajv": "6.12.5",
"ajv": "6.12.6",
"chalk": "4.1.0",
"commander": "6.1.0",
"enhanced-resolve": "5.2.0",
Expand All @@ -140,34 +140,34 @@
"wrap-ansi": "7.0.0"
},
"devDependencies": {
"@babel/core": "7.11.6",
"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"@babel/core": "7.12.3",
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"@typescript-eslint/eslint-plugin": "4.4.1",
"@typescript-eslint/parser": "4.4.1",
"chai": "4.2.0",
"chai-json-schema": "1.5.1",
"coffeescript": "2.5.1",
"eslint": "7.10.0",
"eslint-config-moving-meadow": "2.0.4",
"eslint-config-prettier": "6.12.0",
"eslint-plugin-budapestian": "2.0.0",
"eslint": "7.11.0",
"eslint-config-moving-meadow": "2.0.7",
"eslint-config-prettier": "6.13.0",
"eslint-plugin-budapestian": "2.3.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-mocha": "8.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-unicorn": "22.0.0",
"eslint-plugin-unicorn": "23.0.0",
"husky": "4.3.0",
"intercept-stdout": "0.1.2",
"lint-staged": "10.4.0",
"mocha": "8.1.3",
"lint-staged": "10.4.2",
"mocha": "8.2.0",
"normalize-newline": "3.0.0",
"npm-run-all": "4.1.5",
"nyc": "15.1.0",
"prettier": "2.1.2",
"shx": "0.3.2",
"symlink-dir": "4.1.0",
"typescript": "4.0.3",
"upem": "4.0.1",
"upem": "5.0.0",
"vue-template-compiler": "2.6.12",
"yarn": "1.22.10"
},
Expand Down
4 changes: 2 additions & 2 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function extractBabelConfigOptions(pCruiseOptions) {
}

function setUpListener(pCruiseOptions) {
const STRING2LISTENER = {
const lString2Listener = {
"cli-feedback": setUpCliFeedbackListener,
"performance-log": setUpPerformanceLogListener,
};
Expand All @@ -71,7 +71,7 @@ function setUpListener(pCruiseOptions) {
"progress",
_get(pCruiseOptions, "ruleSet.options.progress.type")
);
const lListenerFunction = _get(STRING2LISTENER, lListenerID);
const lListenerFunction = _get(lString2Listener, lListenerID);
/* istanbul ignore next */
if (Boolean(lListenerFunction)) {
lListenerFunction(bus);
Expand Down
12 changes: 6 additions & 6 deletions src/cli/init-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const {
const PACKAGE_MANIFEST = `./${$defaults.PACKAGE_MANIFEST}`;

function getOneshotConfig(pOneShotConfigId) {
const BASE_CONFIG = {
const lBaseConfig = {
isMonoRepo: isLikelyMonoRepo(),
combinedDependencies: false,
useTsConfig: hasTSConfigCandidates(),
Expand All @@ -33,21 +33,21 @@ function getOneshotConfig(pOneShotConfigId) {
useBabelConfig: hasBabelConfigCandidates(),
babelConfig: getBabelConfigCandidates().shift(),
};
const ONESHOT_CONFIGS = {
const lOneshotConfigs = {
preset: {
configType: "preset",
preset: "dependency-cruiser/configs/recommended-strict",
...BASE_CONFIG,
...lBaseConfig,
},
yes: BASE_CONFIG,
yes: lBaseConfig,
"experimental-scripts": {
updateManifest: fileExists(PACKAGE_MANIFEST),
...BASE_CONFIG,
...lBaseConfig,
},
};

// eslint-disable-next-line security/detect-object-injection
return ONESHOT_CONFIGS[pOneShotConfigId] || BASE_CONFIG;
return lOneshotConfigs[pOneShotConfigId] || lBaseConfig;
}

function manifestIsUpdateable(pNormalizedInitConfig) {
Expand Down
10 changes: 5 additions & 5 deletions src/cli/init-config/write-run-scripts-to-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function addRunScriptsToManifest(pManifest, pAdditionalRunScripts) {
}

function getSuccessMessage(pDestinationManifestFileName) {
const EXPLANATION_INDENT = 6;
const lExplanationIndent = 6;

return (
` ${chalk.green(
Expand All @@ -73,22 +73,22 @@ function getSuccessMessage(pDestinationManifestFileName) {
`\n ${chalk.green(figures.play)} npm run depcruise` +
`\n${wrapAndIndent(
"validates against the rules in .dependency-cruiser.json and writes the outcome to stdout",
EXPLANATION_INDENT
lExplanationIndent
)}` +
`\n\n ${chalk.green(figures.play)} npm run depcruise:html` +
`\n${wrapAndIndent(
"validates against the rules in .dependency-cruiser.js and writes it to 'dependendency-violation-report.html' with a friendly layout",
EXPLANATION_INDENT
lExplanationIndent
)}` +
`\n\n ${chalk.green(figures.play)} npm run depcruise:graph` +
`\n${wrapAndIndent(
"writes a detailed internal graph of your app to 'dependency-graph.html'",
EXPLANATION_INDENT
lExplanationIndent
)}` +
`\n\n ${chalk.green(figures.play)} npm run depcruise:graph-archi` +
`\n${wrapAndIndent(
"writes a high-level internal graph of your app to 'high-level-dependency-graph.html'",
EXPLANATION_INDENT
lExplanationIndent
)}` +
`\n\n`
);
Expand Down
6 changes: 3 additions & 3 deletions src/cli/parse-babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getJSON5Config(pBabelConfigFileName) {
}

function getConfig(pBabelConfigFileName) {
const EXTENSION_TO_PARSE_FN = {
const lExtensionToParseFunction = {
".js": getCommonJSConfig,
".cjs": getCommonJSConfig,
"": getJSON5Config,
Expand All @@ -63,14 +63,14 @@ function getConfig(pBabelConfigFileName) {
};
const lExtension = path.extname(pBabelConfigFileName);

if (!_has(EXTENSION_TO_PARSE_FN, lExtension)) {
if (!_has(lExtensionToParseFunction, lExtension)) {
throw new Error(
`The babel config '${pBabelConfigFileName}' is in a format ('${lExtension}')\n` +
" dependency-cruiser doesn't support yet.\n"
);
}
// eslint-disable-next-line security/detect-object-injection
return EXTENSION_TO_PARSE_FN[lExtension](pBabelConfigFileName);
return lExtensionToParseFunction[lExtension](pBabelConfigFileName);
}

module.exports = function parseBabelConfig(pBabelConfigFileName) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/parse-ts-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = function parseConfig(pTSConfigFileName) {
pTSConfigFileName
);

if (lReturnValue.errors.length !== 0) {
if (lReturnValue.errors.length > 0) {
throw new Error(
typescript.formatDiagnostics(
lReturnValue.errors,
Expand Down
9 changes: 6 additions & 3 deletions src/cli/utl/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ function writeToFile(pOutputTo, pDependencyString) {
*/
function writeToStdOut(pString, pBufferSize = PIPE_BUFFER_SIZE) {
const lNumberOfChunks = Math.ceil(pString.length / pBufferSize);
let i = 0;
let lIndex = 0;

/* eslint no-plusplus: 0 */
for (i = 0; i < lNumberOfChunks; i++) {
for (lIndex = 0; lIndex < lNumberOfChunks; lIndex++) {
// eslint-disable-next-line unicorn/prefer-string-slice
process.stdout.write(pString.substr(i * pBufferSize, pBufferSize), "utf8");
process.stdout.write(
pString.substr(lIndex * pBufferSize, pBufferSize),
"utf8"
);
}
}
function write(pOutputTo, pContent) {
Expand Down
12 changes: 6 additions & 6 deletions src/extract/ast-extractors/extract-cjs-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ function pushRequireCallsToDependencies(
pExoticRequireStrings
) {
return (pNode) => {
for (let pName of ["require"].concat(pExoticRequireStrings)) {
if (estreeHelpers.isRequireOfSomeSort(pNode, pName)) {
for (let pString of pryStringsFromArguments(pNode.arguments)) {
for (let lName of ["require"].concat(pExoticRequireStrings)) {
if (estreeHelpers.isRequireOfSomeSort(pNode, lName)) {
for (let lString of pryStringsFromArguments(pNode.arguments)) {
pDependencies.push({
module: pString,
module: lString,
moduleSystem: pModuleSystem,
dynamic: false,
...(pName === "require"
...(lName === "require"
? { exoticallyRequired: false }
: { exoticallyRequired: true, exoticRequire: pName }),
: { exoticallyRequired: true, exoticRequire: lName }),
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/extract/resolve/module-classifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function determineFollowableExtensions(pResolveOptions) {
let lReturnValue = new Set(pResolveOptions.extensions);

// we could include things like pictures, movies, html, xml
// etc in KNOWN_UNFOLLOWABLES as well. Typically in
// etc in lKnownUnfollowables as well. Typically in
// javascript-like sources you don't import non-javascript
// stuff without mentioning the extension (`import 'styles.scss`
// is more clear than`import 'styles'` as you'd expect that
Expand All @@ -64,7 +64,7 @@ function determineFollowableExtensions(pResolveOptions) {
// nonetheless - they can contain import statements and the
// fallback javascript parser will happily parse them, which
// will result in false positives.
const KNOWN_UNFOLLOWABLES = [
const lKnownUnfollowables = [
".json",
".node",
".css",
Expand All @@ -74,7 +74,7 @@ function determineFollowableExtensions(pResolveOptions) {
".less",
];

KNOWN_UNFOLLOWABLES.forEach((pUnfollowable) => {
lKnownUnfollowables.forEach((pUnfollowable) => {
lReturnValue.delete(pUnfollowable);
});
return lReturnValue;
Expand Down
4 changes: 2 additions & 2 deletions src/graph-utl/compare.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function severity2number(pSeverity) {
const SEVERITY2NUMBER = {
const lSeverity2Number = {
error: 1,
warn: 2,
info: 3,
ignore: 4,
};

// eslint-disable-next-line security/detect-object-injection
return SEVERITY2NUMBER[pSeverity] || -1;
return lSeverity2Number[pSeverity] || -1;
}

function severities(pFirstSeverity, pSecondSeverity) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ function validateResultAgainstSchema(pResult) {
}

function reportWithReSummarization(pResult, pFormatOptions) {
const lReportFn = report.getReporter(pFormatOptions.outputType);
const lReportFunction = report.getReporter(pFormatOptions.outputType);

return lReportFn(
return lReportFunction(
reSummarizeResults(pResult, pFormatOptions),
// passing format options here so reporters that read collapse patterns
// from the result take the one passed in the format options instead
Expand Down
18 changes: 9 additions & 9 deletions src/main/options/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function normalizeReporterOptions(pReporterOptions) {
function normalizeFilterOptions(pOptions, pFilterOptionKeys) {
let lReturnValue = { ...pOptions };

for (let pFilterOptionKey of pFilterOptionKeys) {
if (pOptions[pFilterOptionKey]) {
lReturnValue[pFilterOptionKey] = normalizeFilterOption(
lReturnValue[pFilterOptionKey]
for (let lFilterOptionKey of pFilterOptionKeys) {
if (pOptions[lFilterOptionKey]) {
lReturnValue[lFilterOptionKey] = normalizeFilterOption(
lReturnValue[lFilterOptionKey]
);
}
}
Expand All @@ -53,12 +53,12 @@ function normalizeFilterOptions(pOptions, pFilterOptionKeys) {

function normalizeCollapse(pCollapse) {
let lReturnValue = pCollapse;
const ONE_OR_MORE_NON_SLASHES = "[^/]+";
const FOLDER_PATTERN = `${ONE_OR_MORE_NON_SLASHES}/`;
const FOLDER_BELOW_NODE_MODULES = `node_modules/${ONE_OR_MORE_NON_SLASHES}`;
const SINGLE_DIGIT_RE = /^\d$/;
const lOneOrMoreNonSlashes = "[^/]+";
const FOLDER_PATTERN = `${lOneOrMoreNonSlashes}/`;
const FOLDER_BELOW_NODE_MODULES = `node_modules/${lOneOrMoreNonSlashes}`;
const lSingleDigitRe = /^\d$/;

if (typeof pCollapse === "number" || pCollapse.match(SINGLE_DIGIT_RE)) {
if (typeof pCollapse === "number" || pCollapse.match(lSingleDigitRe)) {
lReturnValue = `${FOLDER_BELOW_NODE_MODULES}|^${FOLDER_PATTERN.repeat(
Number.parseInt(pCollapse, 10)
)}`;
Expand Down
4 changes: 2 additions & 2 deletions src/main/rule-set/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function safeRule(pRule, pSection, pCondition) {
}

function checkRuleSafety(pRule) {
const REGEX_CONDITIONS = [
const lRegexConditions = [
{ section: "from", condition: "path" },
{ section: "to", condition: "path" },
{ section: "from", condition: "pathNot" },
Expand All @@ -36,7 +36,7 @@ function checkRuleSafety(pRule) {
];

if (
REGEX_CONDITIONS.some(
lRegexConditions.some(
(pCondition) => !safeRule(pRule, pCondition.section, pCondition.condition)
)
) {
Expand Down
16 changes: 8 additions & 8 deletions src/report/anon/random-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const UPPERCASE = 2;
const NOTHING_SPECIAL = 3;

function isSeparator(pChar) {
const SEPARATORS_RE = /[-_.]/;
const lSeparatorsRe = /[-_.]/;

return SEPARATORS_RE.test(pChar);
return lSeparatorsRe.test(pChar);
}

function isUpperCase(pChar) {
Expand All @@ -23,20 +23,20 @@ function classifyChar(pChar) {
}

function getRandomChar(pChar) {
const LOWER_CASE_CHARS = "abcdefghijklmnopqrstuvwxyz";
const MAX_DECIMAL_CHAR = 9;
const lLowerCaseChars = "abcdefghijklmnopqrstuvwxyz";
const lMaxDecimalChar = 9;

switch (classifyChar(pChar)) {
case SEPARATOR:
return pChar;
case NUMBER:
return _random(0, MAX_DECIMAL_CHAR);
return _random(0, lMaxDecimalChar);
case UPPERCASE:
return LOWER_CASE_CHARS[
_random(0, LOWER_CASE_CHARS.length - 1)
return lLowerCaseChars[
_random(0, lLowerCaseChars.length - 1)
].toUpperCase();
default:
return LOWER_CASE_CHARS[_random(0, LOWER_CASE_CHARS.length - 1)];
return lLowerCaseChars[_random(0, lLowerCaseChars.length - 1)];
}
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/utl/wrap-and-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const wrapAnsi = require("wrap-ansi");

const DEFAULT_INDENT = 4;
module.exports = function wrapAndIndent(pString, pIndent = DEFAULT_INDENT) {
const DOGMATIC_MAX_CONSOLE_WIDTH = 78;
const MAX_WIDTH = DOGMATIC_MAX_CONSOLE_WIDTH - pIndent;
const lDogmaticMaxConsoleWidth = 78;
const MAX_WIDTH = lDogmaticMaxConsoleWidth - pIndent;

return indentString(wrapAnsi(pString, MAX_WIDTH), pIndent);
};
Loading

0 comments on commit da52418

Please sign in to comment.