Socket
Socket
Sign inDemoInstall

doctor

Package Overview
Dependencies
14
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.27 to 0.1.28

test/fixture/examine/amd-exports-function/files/foo.js

5

lib/report.js

@@ -81,4 +81,6 @@ var nast = require('./nice-ast');

var item = self.items[key];
// sometimes have to remove groups
if (item.type === 'group') {
throw new Error('cannot delete group');
console.log(item);
throw new Error('cannot delete group: ' + item.key);
}

@@ -99,2 +101,3 @@ if (item.groups) {

Report.prototype.add = function (item) {
var self = this;

@@ -101,0 +104,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Create documentation from a JavaScript AST.",
"version": "0.1.27",
"version": "0.1.28",
"homepage": "https://github.com/jdeal/doctor",

@@ -8,0 +8,0 @@ "repository": {

@@ -226,2 +226,5 @@ var Path = require('path');

var properties = {};
if (typeof valueNode === 'string') {
return node.item('var.' + valueNode);
}
if (valueNode.type === 'object') {

@@ -377,3 +380,3 @@ type = 'object';

function exportModule(exports, exportName) {
function exportModule(node, exports, exportName) {
var items = [];

@@ -395,6 +398,8 @@ if (!exports) {

if (key !== 'prototype') {
items = items.concat(exportModule(obj, nextExportName));
items = items.concat(exportModule(node, obj, nextExportName));
}
});
// re-key items from other modules
var moduleName = node.item('module');
var keyMap = {};
_(items).each(function (item) {

@@ -404,8 +409,18 @@ var key = item.key;

var keyModuleName = key.substring(0, key.indexOf('.'));
var moduleName = exports.node.item('module');
if (keyModuleName !== moduleName) {
var subKey = key.substring(key.indexOf('.'));
item.key = exports.node.item('module') + subKey;
keyMap[item.key] = moduleName + subKey;
item.key = moduleName + subKey;
item.groups.push(moduleName);
item.groups = _.without(item.groups, keyModuleName);
item.groups = item.groups.map(function (group) {
if (group in keyMap) {
return keyMap[group];
} else {
return group;
}
});
if (item.type === 'class') {
item.module = moduleName;
}
}

@@ -690,2 +705,51 @@ }

/*
define([], function () {});
define(function () {});
requirejs([], function () {});
requirejs(function () {});
*/
rules.push({
type: 'call',
match: function (node) {
return node.likeSource('define()') ||
node.likeSource('requirejs()');
},
report: function (node, report) {
var factoryNode = null;
var deps = null;
if (node.likeSource('__name__(function(){})')) {
factoryNode = node.nodes[1].nodes[0];
} else if (node.likeSource('__name__([], function(){})')) {
factoryNode = node.nodes[1].nodes[1];
deps = node.nodes[1].nodes[0].nodes;
var depArgs = factoryNode.nodes[1].nodes;
deps = deps.slice(0, depArgs.length);
_(deps).each(function (dep, i) {
if (dep.value && depArgs[i].value) {
saveVar(node, depArgs[i].value, fullRequirePath(node, dep.value));
}
});
}
if (factoryNode) {
factoryNode.isAmdFactory = true;
}
}
});
/*
return exports from AMD factory
*/
rules.push({
type: 'return',
match: function (node) {
return node.nodes.length > 0 && node.nodes[0].type !== 'undefined' &&
node.item('scopeNode').isAmdFactory;
},
report: function (node, report) {
var exportValue = node.nodes[0];
saveVar(node, ['module', 'exports'], exportValue);
}
});
/*
_.extend(...)

@@ -787,3 +851,3 @@ */

}
return exportModule(exportsObj);
return exportModule(node, exportsObj);
}

@@ -790,0 +854,0 @@ });

@@ -30,2 +30,15 @@ var Path = require('path');

function addDep(path, node) {
var ext = Path.extname(path);
if (ext === '.js' || ext === '') {
//if (path[0] === '.') {
path = Path.join(Path.dirname(node.item('fullPath')), path);
// if (ext === '') {
// path += '.js';
// }
node.item('requires')[path] = path;
//}
}
}
rules.push({

@@ -38,12 +51,23 @@ type: 'call',

var requirePath = node.nodes[1].nodes[0].value;
var ext = Path.extname(requirePath);
if (ext === '.js' || ext === '') {
if (requirePath[0] === '.') {
requirePath = Path.join(Path.dirname(node.item('fullPath')), requirePath);
// if (ext === '') {
// requirePath += '.js';
// }
node.item('requires')[requirePath] = requirePath;
addDep(requirePath, node);
}
});
/*
define([], function () {});
requirejs([], function () {});
*/
rules.push({
type: 'call',
match: function (node) {
return node.likeSource('define([], function(){})') ||
node.likeSource('requirejs([], function(){})');
},
report: function (node, report) {
var deps = node.nodes[1].nodes[0].nodes;
deps.forEach(function (dep) {
if (dep.value) {
addDep(dep.value, node);
}
}
});
}

@@ -50,0 +74,0 @@ });

var rules = [];
rules.push({
type: 'script',
transform: function (node) {
node.item('path', node.path);
}
});
/* merge and normalize comments */

@@ -114,3 +121,3 @@ rules.push({

} catch (e) {
var file = node.parent.path;
var file = node.item('path');
var comment = node.commentText;

@@ -117,0 +124,0 @@ var msg = 'Error parsing comment tag in file ' + file + ':' + node.line + ' - ' + e +

'use strict';
/*global alert: false */
/*global alert: false, $: false */

@@ -321,4 +321,14 @@ SyntaxHighlighter.defaults['gutter'] = false;

if (item.type === 'readme') {
var brushes = ['bash', 'shell', 'cpp', 'c', 'css', 'diff', 'patch',
'js', 'jscript', 'javascript', 'plain', 'text', 'ps',
'powershell', 'sql', 'xml', 'xhtml', 'xslt', 'html',
'xhtml'];
content.append(item.content);
$('.highlight').find('pre[lang=js]').addClass('brush:js');
$('.highlight pre').each(function (i, pre) {
var brush = $(pre).attr('lang');
if (brushes.indexOf(brush) < 0) {
brush = 'plain';
}
$(pre).addClass('brush:' + brush);
});
SyntaxHighlighter.highlight();

@@ -325,0 +335,0 @@ return;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc