Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

depcheck

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depcheck - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

dist/index.js

@@ -14,3 +14,3 @@ "use strict";

var _minimatch = _interopRequireDefault(require("minimatch"));
var _multimatch = _interopRequireDefault(require("multimatch"));

@@ -50,5 +50,3 @@ var _ignore = _interopRequireDefault(require("ignore"));

function isIgnored(ignoreMatches, dependency) {
const match = _lodash.default.partial(_minimatch.default, dependency);
return ignoreMatches.some(match);
return Boolean((0, _multimatch.default)(dependency, ignoreMatches).length);
}

@@ -55,0 +53,0 @@

@@ -14,22 +14,50 @@ "use strict";

var _nodeSassTildeImporter = _interopRequireDefault(require("node-sass-tilde-importer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _utils = require("../utils");
const sass = require('sass');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function unixSlashes(packagePath) {
return packagePath.replace(/\\/g, '/');
}
const sass = (0, _utils.tryRequire)('node-sass');
function removeNodeModulesOrTildaFromPath(packagePath) {
const nodeModulesIndex = packagePath.indexOf('node_modules/');
async function parseSASS(filename, deps, rootDir) {
const {
stats
} = sass.renderSync({
file: filename,
includePaths: [_path.default.dirname(filename)],
importer: _nodeSassTildeImporter.default
});
const result = (0, _lodash.default)(stats.includedFiles).map(file => _path.default.relative(rootDir, file)).filter(file => file.indexOf('node_modules') >= 0) // refer to node_modules
.map(file => file.replace(/\\/g, '/')) // normalize paths in Windows
.map(file => file.substring(file.indexOf('node_modules/') + 'node_modules/'.length)) // avoid heading slash
.map(_requirePackageName.default).uniq().value();
if (nodeModulesIndex > -1) {
return packagePath.substring(nodeModulesIndex + 'node_modules/'.length);
}
if (packagePath.indexOf(`~`) === 0) {
return packagePath.substring(1);
}
return packagePath;
}
async function parseSASS(filename) {
const includedFiles = [];
let sassDetails = {};
try {
// sass processor does not respect the custom importer
sassDetails = sass.renderSync({
file: filename,
includePaths: [_path.default.dirname(filename)],
importer: [function importer(url) {
includedFiles.push(url);
return {
contents: `
h1 {
font-size: 40px;
}`
};
}]
});
} catch (e) {
sassDetails.stats = {
includedFiles
};
}
const result = (0, _lodash.default)(sassDetails.stats.includedFiles).filter(packagePath => packagePath !== filename).map(unixSlashes).map(removeNodeModulesOrTildaFromPath).map(_requirePackageName.default).uniq().filter(x => x).value();
return result;

@@ -36,0 +64,0 @@ }

@@ -20,14 +20,43 @@ "use strict";

function findStringPlugins(pluginElementsArray) {
return pluginElementsArray.filter(e => e.type === 'StringLiteral').map(e => e.value);
}
function findResolvePlugins(pluginElementsArray) {
return pluginElementsArray.filter(e => e.type === 'ObjectExpression').map(e => e.properties).reduce((acc, props) => acc.concat(props), []).filter(resolvePropCandidate => resolvePropCandidate.key.value === 'resolve' && resolvePropCandidate.value && resolvePropCandidate.value.type === 'StringLiteral').map(resolveProp => resolveProp.value.value);
}
function findNestedPlugins(pluginElementsArray) {
return pluginElementsArray.filter(e => e.type === 'ObjectExpression').map(e => e.properties).reduce((acc, props) => acc.concat(props), []).filter(optionsPropCandidate => optionsPropCandidate && optionsPropCandidate.key && optionsPropCandidate.key.value === 'options' && optionsPropCandidate.value && optionsPropCandidate.value.type === 'ObjectExpression') // eslint-disable-next-line no-use-before-define
.map(optionsNode => findPluginsInObjectExpression(optionsNode.value)).reduce((deps, dep) => deps.concat(dep), []);
}
function findPluginsInObjectExpression(node) {
const dependencies = [];
node.properties.forEach(prop => {
if (prop.value.type === 'ArrayExpression' && (prop.key.name === 'plugins' || prop.key.value === 'plugins')) {
const vals = [];
vals.push(...findResolvePlugins(prop.value.elements));
vals.push(...findStringPlugins(prop.value.elements));
vals.push(...findNestedPlugins(prop.value.elements));
dependencies.push(...vals);
}
});
return dependencies;
}
/**
*
*
* @param {Object} node Root node of the gatsby.config.js file
*
*/
function parseConfigModuleExports(node) {
// node.left must be assigning to module.exports
if (node && node.type === 'AssignmentExpression' && node.left.type === 'MemberExpression' && node.left.object && node.left.object.type === 'Identifier' && node.left.object.name === 'module' && node.left.property && node.left.property.type === 'Identifier' && node.left.property.name === 'exports') {
const config = {};
node.right.properties.forEach(prop => {
if (prop.value.type === 'ArrayExpression' && prop.key.name === 'plugins') {
const vals = [];
prop.value.elements.filter(e => e.type === 'StringLiteral').forEach(e => vals.push(e.value));
config[prop.key.name] = vals;
}
});
return config;
const plugins = findPluginsInObjectExpression(node.right);
return {
plugins
};
}

@@ -34,0 +63,0 @@

{
"name": "depcheck",
"version": "v1.1.0",
"version": "1.2.0",
"description": "Check dependencies in your node module",

@@ -62,5 +62,5 @@ "main": "dist/index.js",

"json5": "^2.1.3",
"lodash": "^4.17.15",
"lodash": "^4.17.19",
"minimatch": "^3.0.4",
"node-sass-tilde-importer": "^1.0.2",
"multimatch": "^4.0.0",
"please-upgrade-node": "^3.2.0",

@@ -70,2 +70,3 @@ "readdirp": "^3.4.0",

"resolve": "^1.17.0",
"sass": "^1.26.10",
"vue-template-compiler": "^2.6.11",

@@ -94,3 +95,3 @@ "yargs": "^15.4.0"

"fs-extra": "^9.0.1",
"mocha": "^8.0.1",
"mocha": "^8.1.1",
"node-sass": "^4.14.1",

@@ -97,0 +98,0 @@ "nyc": "^15.1.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc