used-deps-analyzer
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

used-deps-analyzer

Analyse js code to force match between installed & used deps

Build status Coverage status Dependency status Dev dependency status Issues Pull requests

Installation

$ npm install used-deps-analyzer

Features

  • Analyse a directory content to find unused installed deps
  • Analyse a directory content to find used uninstalled deps

Doc

Content

check the TypeScript definition file

Examples

check the TypeScript compilation tests

Options

  • noDev | --no-dev : do not use dev deps for comparaison (used files, don't use it to analyze test or build scripts)
  • onlyDev | --only-dev : use only dev deps for comparaison (test or build scripts, don't use it to analyze used files)
  • overkill | --overkill : list of deps which should not be used but can be still present for unknown reasons (do not fail, trigger only warnings)
  • misscalled | --misscalled Array : list of deps which are not called by this name in the code
  • shadows | --shadows Array : list of deps which are used in the code but not required (to force a sub-dep version for example)
interface iSubModule {
	"module": string;
	"call": string;
}

Run

cd ./myProject/ && npx used-deps-analyzer -- "./package.json" "./dir" --no-dev
const usedDepsAnalyzer = require("used-deps-analyzer");

usedDepsAnalyzer("./package.json", "./src", {
	"noDev": true,
	"overkill": [
		"node-promfs"
	],
	"misscalled": [
		{
			"module": "colors",
			"call": "colors/safe"
		}
	],
	"shadows": [
		"newer-version",
		"not-called-front-lib"
	]
}).then((analyze) => {

	if (analyze.warnings) {

		analyze.warnings.forEach((a) => {
			console.warn(a);
		});

	}

	if (analyze.result) {
		console.log("all ok");
	}
	else {

		analyze.errors.forEach((a) => {
			console.error(a);
		});

	}

}).catch((err) => {
	console.log(err);
});

Tests

$ npm run-script tests

License

ISC

Readme

Keywords

Package Sidebar

Install

npm i used-deps-analyzer

Weekly Downloads

5

Version

0.1.8

License

ISC

Unpacked Size

30.3 kB

Total Files

32

Last publish

Collaborators

  • psychopoulet