You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

653 lines
62 KiB

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.recursivePatternCapture = recursivePatternCapture;
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _doctrine = require('doctrine');
var _doctrine2 = _interopRequireDefault(_doctrine);
var _debug = require('debug');
var _debug2 = _interopRequireDefault(_debug);
var _eslint = require('eslint');
var _parse = require('eslint-module-utils/parse');
var _parse2 = _interopRequireDefault(_parse);
var _resolve = require('eslint-module-utils/resolve');
var _resolve2 = _interopRequireDefault(_resolve);
var _ignore = require('eslint-module-utils/ignore');
var _ignore2 = _interopRequireDefault(_ignore);
var _hash = require('eslint-module-utils/hash');
var _unambiguous = require('eslint-module-utils/unambiguous');
var unambiguous = _interopRequireWildcard(_unambiguous);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const log = (0, _debug2.default)('eslint-plugin-import:ExportMap');
const exportCache = new Map();
class ExportMap {
constructor(path) {
this.path = path;
this.namespace = new Map();
// todo: restructure to key on path, value is resolver + map of names
this.reexports = new Map();
/**
* star-exports
* @type {Set} of () => ExportMap
*/
this.dependencies = new Set();
/**
* dependencies of this module that are not explicitly re-exported
* @type {Map} from path = () => ExportMap
*/
this.imports = new Map();
this.errors = [];
}
get hasDefault() {
return this.get('default') != null;
} // stronger than this.has
get size() {
let size = this.namespace.size + this.reexports.size;
this.dependencies.forEach(dep => {
const d = dep();
// CJS / ignored dependencies won't exist (#717)
if (d == null) return;
size += d.size;
});
return size;
}
/**
* Note that this does not check explicitly re-exported names for existence
* in the base namespace, but it will expand all `export * from '...'` exports
* if not found in the explicit namespace.
* @param {string} name
* @return {Boolean} true if `name` is exported by this module.
*/
has(name) {
if (this.namespace.has(name)) return true;
if (this.reexports.has(name)) return true;
// default exports must be explicitly re-exported (#328)
if (name !== 'default') {
for (let dep of this.dependencies) {
let innerMap = dep();
// todo: report as unresolved?
if (!innerMap) continue;
if (innerMap.has(name)) return true;
}
}
return false;
}
/**
* ensure that imported name fully resolves.
* @param {[type]} name [description]
* @return {Boolean} [description]
*/
hasDeep(name) {
if (this.namespace.has(name)) return { found: true, path: [this] };
if (this.reexports.has(name)) {
const reexports = this.reexports.get(name),
imported = reexports.getImport();
// if import is ignored, return explicit 'null'
if (imported == null) return { found: true, path: [this]
// safeguard against cycles, only if name matches
};if (imported.path === this.path && reexports.local === name) {
return { found: false, path: [this] };
}
const deep = imported.hasDeep(reexports.local);
deep.path.unshift(this);
return deep;
}
// default exports must be explicitly re-exported (#328)
if (name !== 'default') {
for (let dep of this.dependencies) {
let innerMap = dep();
if (innerMap == null) return { found: true, path: [this]
// todo: report as unresolved?
};if (!innerMap) continue;
// safeguard against cycles
if (innerMap.path === this.path) continue;
let innerValue = innerMap.hasDeep(name);
if (innerValue.found) {
innerValue.path.unshift(this);
return innerValue;
}
}
}
return { found: false, path: [this] };
}
get(name) {
if (this.namespace.has(name)) return this.namespace.get(name);
if (this.reexports.has(name)) {
const reexports = this.reexports.get(name),
imported = reexports.getImport();
// if import is ignored, return explicit 'null'
if (imported == null) return null;
// safeguard against cycles, only if name matches
if (imported.path === this.path && reexports.local === name) return undefined;
return imported.get(reexports.local);
}
// default exports must be explicitly re-exported (#328)
if (name !== 'default') {
for (let dep of this.dependencies) {
let innerMap = dep();
// todo: report as unresolved?
if (!innerMap) continue;
// safeguard against cycles
if (innerMap.path === this.path) continue;
let innerValue = innerMap.get(name);
if (innerValue !== undefined) return innerValue;
}
}
return undefined;
}
forEach(callback, thisArg) {
this.namespace.forEach((v, n) => callback.call(thisArg, v, n, this));
this.reexports.forEach((reexports, name) => {
const reexported = reexports.getImport();
// can't look up meta for ignored re-exports (#348)
callback.call(thisArg, reexported && reexported.get(reexports.local), name, this);
});
this.dependencies.forEach(dep => {
const d = dep();
// CJS / ignored dependencies won't exist (#717)
if (d == null) return;
d.forEach((v, n) => n !== 'default' && callback.call(thisArg, v, n, this));
});
}
// todo: keys, values, entries?
reportErrors(context, declaration) {
context.report({
node: declaration.source,
message: `Parse errors in imported module '${declaration.source.value}': ` + `${this.errors.map(e => `${e.message} (${e.lineNumber}:${e.column})`).join(', ')}`
});
}
}
exports.default = ExportMap; /**
* parse docs from the first node that has leading comments
*/
function captureDoc(source, docStyleParsers) {
const metadata = {};
// 'some' short-circuits on first 'true'
for (var _len = arguments.length, nodes = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
nodes[_key - 2] = arguments[_key];
}
nodes.some(n => {
try {
let leadingComments;
// n.leadingComments is legacy `attachComments` behavior
if ('leadingComments' in n) {
leadingComments = n.leadingComments;
} else if (n.range) {
leadingComments = source.getCommentsBefore(n);
}
if (!leadingComments || leadingComments.length === 0) return false;
for (let name in docStyleParsers) {
const doc = docStyleParsers[name](leadingComments);
if (doc) {
metadata.doc = doc;
}
}
return true;
} catch (err) {
return false;
}
});
return metadata;
}
const availableDocStyleParsers = {
jsdoc: captureJsDoc,
tomdoc: captureTomDoc
/**
* parse JSDoc from leading comments
* @param {...[type]} comments [description]
* @return {{doc: object}}
*/
};function captureJsDoc(comments) {
let doc;
// capture XSDoc
comments.forEach(comment => {
// skip non-block comments
if (comment.type !== 'Block') return;
try {
doc = _doctrine2.default.parse(comment.value, { unwrap: true });
} catch (err) {
/* don't care, for now? maybe add to `errors?` */
}
});
return doc;
}
/**
* parse TomDoc section from comments
*/
function captureTomDoc(comments) {
// collect lines up to first paragraph break
const lines = [];
for (let i = 0; i < comments.length; i++) {
const comment = comments[i];
if (comment.value.match(/^\s*$/)) break;
lines.push(comment.value.trim());
}
// return doctrine-like object
const statusMatch = lines.join(' ').match(/^(Public|Internal|Deprecated):\s*(.+)/);
if (statusMatch) {
return {
description: statusMatch[2],
tags: [{
title: statusMatch[1].toLowerCase(),
description: statusMatch[2]
}]
};
}
}
ExportMap.get = function (source, context) {
const path = (0, _resolve2.default)(source, context);
if (path == null) return null;
return ExportMap.for(childContext(path, context));
};
ExportMap.for = function (context) {
const path = context.path;
const cacheKey = (0, _hash.hashObject)(context).digest('hex');
let exportMap = exportCache.get(cacheKey);
// return cached ignore
if (exportMap === null) return null;
const stats = _fs2.default.statSync(path);
if (exportMap != null) {
// date equality check
if (exportMap.mtime - stats.mtime === 0) {
return exportMap;
}
// future: check content equality?
}
// check valid extensions first
if (!(0, _ignore.hasValidExtension)(path, context)) {
exportCache.set(cacheKey, null);
return null;
}
// check for and cache ignore
if ((0, _ignore2.default)(path, context)) {
log('ignored path due to ignore settings:', path);
exportCache.set(cacheKey, null);
return null;
}
const content = _fs2.default.readFileSync(path, { encoding: 'utf8' });
// check for and cache unambiguous modules
if (!unambiguous.test(content)) {
log('ignored path due to unambiguous regex:', path);
exportCache.set(cacheKey, null);
return null;
}
log('cache miss', cacheKey, 'for path', path);
exportMap = ExportMap.parse(path, content, context);
// ambiguous modules return null
if (exportMap == null) return null;
exportMap.mtime = stats.mtime;
exportCache.set(cacheKey, exportMap);
return exportMap;
};
ExportMap.parse = function (path, content, context) {
var m = new ExportMap(path);
try {
var ast = (0, _parse2.default)(path, content, context);
} catch (err) {
log('parse error:', path, err);
m.errors.push(err);
return m; // can't continue
}
if (!unambiguous.isModule(ast)) return null;
const docstyle = context.settings && context.settings['import/docstyle'] || ['jsdoc'];
const docStyleParsers = {};
docstyle.forEach(style => {
docStyleParsers[style] = availableDocStyleParsers[style];
});
// attempt to collect module doc
if (ast.comments) {
ast.comments.some(c => {
if (c.type !== 'Block') return false;
try {
const doc = _doctrine2.default.parse(c.value, { unwrap: true });
if (doc.tags.some(t => t.title === 'module')) {
m.doc = doc;
return true;
}
} catch (err) {/* ignore */}
return false;
});
}
const namespaces = new Map();
function remotePath(value) {
return _resolve2.default.relative(value, path, context.settings);
}
function resolveImport(value) {
const rp = remotePath(value);
if (rp == null) return null;
return ExportMap.for(childContext(rp, context));
}
function getNamespace(identifier) {
if (!namespaces.has(identifier.name)) return;
return function () {
return resolveImport(namespaces.get(identifier.name));
};
}
function addNamespace(object, identifier) {
const nsfn = getNamespace(identifier);
if (nsfn) {
Object.defineProperty(object, 'namespace', { get: nsfn });
}
return object;
}
function captureDependency(declaration) {
if (declaration.source == null) return null;
if (declaration.importKind === 'type') return null; // skip Flow type imports
const importedSpecifiers = new Set();
const supportedTypes = new Set(['ImportDefaultSpecifier', 'ImportNamespaceSpecifier']);
let hasImportedType = false;
if (declaration.specifiers) {
declaration.specifiers.forEach(specifier => {
const isType = specifier.importKind === 'type';
hasImportedType = hasImportedType || isType;
if (supportedTypes.has(specifier.type) && !isType) {
importedSpecifiers.add(specifier.type);
}
if (specifier.type === 'ImportSpecifier' && !isType) {
importedSpecifiers.add(specifier.imported.name);
}
});
}
// only Flow types were imported
if (hasImportedType && importedSpecifiers.size === 0) return null;
const p = remotePath(declaration.source.value);
if (p == null) return null;
const existing = m.imports.get(p);
if (existing != null) return existing.getter;
const getter = thunkFor(p, context);
m.imports.set(p, {
getter,
source: { // capturing actual node reference holds full AST in memory!
value: declaration.source.value,
loc: declaration.source.loc
},
importedSpecifiers
});
return getter;
}
const source = makeSourceCode(content, ast);
ast.body.forEach(function (n) {
if (n.type === 'ExportDefaultDeclaration') {
const exportMeta = captureDoc(source, docStyleParsers, n);
if (n.declaration.type === 'Identifier') {
addNamespace(exportMeta, n.declaration);
}
m.namespace.set('default', exportMeta);
return;
}
if (n.type === 'ExportAllDeclaration') {
const getter = captureDependency(n);
if (getter) m.dependencies.add(getter);
return;
}
// capture namespaces in case of later export
if (n.type === 'ImportDeclaration') {
captureDependency(n);
let ns;
if (n.specifiers.some(s => s.type === 'ImportNamespaceSpecifier' && (ns = s))) {
namespaces.set(ns.local.name, n.source.value);
}
return;
}
if (n.type === 'ExportNamedDeclaration') {
// capture declaration
if (n.declaration != null) {
switch (n.declaration.type) {
case 'FunctionDeclaration':
case 'ClassDeclaration':
case 'TypeAlias': // flowtype with babel-eslint parser
case 'InterfaceDeclaration':
case 'DeclareFunction':
case 'TSDeclareFunction':
case 'TSEnumDeclaration':
case 'TSTypeAliasDeclaration':
case 'TSInterfaceDeclaration':
case 'TSAbstractClassDeclaration':
case 'TSModuleDeclaration':
m.namespace.set(n.declaration.id.name, captureDoc(source, docStyleParsers, n));
break;
case 'VariableDeclaration':
n.declaration.declarations.forEach(d => recursivePatternCapture(d.id, id => m.namespace.set(id.name, captureDoc(source, docStyleParsers, d, n))));
break;
}
}
const nsource = n.source && n.source.value;
n.specifiers.forEach(s => {
const exportMeta = {};
let local;
switch (s.type) {
case 'ExportDefaultSpecifier':
if (!n.source) return;
local = 'default';
break;
case 'ExportNamespaceSpecifier':
m.namespace.set(s.exported.name, Object.defineProperty(exportMeta, 'namespace', {
get() {
return resolveImport(nsource);
}
}));
return;
case 'ExportSpecifier':
if (!n.source) {
m.namespace.set(s.exported.name, addNamespace(exportMeta, s.local));
return;
}
// else falls through
default:
local = s.local.name;
break;
}
// todo: JSDoc
m.reexports.set(s.exported.name, { local, getImport: () => resolveImport(nsource) });
});
}
// This doesn't declare anything, but changes what's being exported.
if (n.type === 'TSExportAssignment') {
const moduleDecls = ast.body.filter(bodyNode => bodyNode.type === 'TSModuleDeclaration' && bodyNode.id.name === n.expression.name);
moduleDecls.forEach(moduleDecl => {
if (moduleDecl && moduleDecl.body && moduleDecl.body.body) {
moduleDecl.body.body.forEach(moduleBlockNode => {
// Export-assignment exports all members in the namespace, explicitly exported or not.
const exportedDecl = moduleBlockNode.type === 'ExportNamedDeclaration' ? moduleBlockNode.declaration : moduleBlockNode;
if (exportedDecl.type === 'VariableDeclaration') {
exportedDecl.declarations.forEach(decl => recursivePatternCapture(decl.id, id => m.namespace.set(id.name, captureDoc(source, docStyleParsers, decl, exportedDecl, moduleBlockNode))));
} else {
m.namespace.set(exportedDecl.id.name, captureDoc(source, docStyleParsers, moduleBlockNode));
}
});
}
});
}
});
return m;
};
/**
* The creation of this closure is isolated from other scopes
* to avoid over-retention of unrelated variables, which has
* caused memory leaks. See #1266.
*/
function thunkFor(p, context) {
return () => ExportMap.for(childContext(p, context));
}
/**
* Traverse a pattern/identifier node, calling 'callback'
* for each leaf identifier.
* @param {node} pattern
* @param {Function} callback
* @return {void}
*/
function recursivePatternCapture(pattern, callback) {
switch (pattern.type) {
case 'Identifier':
// base case
callback(pattern);
break;
case 'ObjectPattern':
pattern.properties.forEach(p => {
recursivePatternCapture(p.value, callback);
});
break;
case 'ArrayPattern':
pattern.elements.forEach(element => {
if (element == null) return;
recursivePatternCapture(element, callback);
});
break;
case 'AssignmentPattern':
callback(pattern.left);
break;
}
}
/**
* don't hold full context object in memory, just grab what we need.
*/
function childContext(path, context) {
const settings = context.settings,
parserOptions = context.parserOptions,
parserPath = context.parserPath;
return {
settings,
parserOptions,
parserPath,
path
};
}
/**
* sometimes legacy support isn't _that_ hard... right?
*/
function makeSourceCode(text, ast) {
if (_eslint.SourceCode.length > 1) {
// ESLint 3
return new _eslint.SourceCode(text, ast);
} else {
// ESLint 4, 5
return new _eslint.SourceCode({ text, ast });
}
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9FeHBvcnRNYXAuanMiXSwibmFtZXMiOlsicmVjdXJzaXZlUGF0dGVybkNhcHR1cmUiLCJ1bmFtYmlndW91cyIsImxvZyIsImV4cG9ydENhY2hlIiwiTWFwIiwiRXhwb3J0TWFwIiwiY29uc3RydWN0b3IiLCJwYXRoIiwibmFtZXNwYWNlIiwicmVleHBvcnRzIiwiZGVwZW5kZW5jaWVzIiwiU2V0IiwiaW1wb3J0cyIsImVycm9ycyIsImhhc0RlZmF1bHQiLCJnZXQiLCJzaXplIiwiZm9yRWFjaCIsImRlcCIsImQiLCJoYXMiLCJuYW1lIiwiaW5uZXJNYXAiLCJoYXNE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oZC5pZCxcbiAgICAgICAgICAgICAgICBpZCA9PiBtLm5hbWVzcGFjZS5zZXQoaWQubmFtZSwgY2FwdHVyZURvYyhzb3VyY2UsIGRvY1N0eWxlUGFyc2VycywgZCwgbikpKSlcbiAgICAgICAgICAgIGJyZWFrXG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgY29uc3QgbnNvdXJjZSA9IG4uc291cmNlICYmIG4uc291cmNlLnZhbHVlXG4gICAgICBuLnNwZWNpZmllcnMuZm9yRWFjaCgocykgPT4ge1xuICAgICAgICBjb25zdCBleHBvcnRNZXRhID0ge31cbiAgICAgICAgbGV0IGxvY2FsXG5cbiAgICAgICAgc3dpdGNoIChzLnR5cGUpIHtcbiAgICAgICAgICBjYXNlICdFeHBvcnREZWZhdWx0U3BlY2lmaWVyJzpcbiAgICAgICAgICAgIGlmICghbi5zb3VyY2UpIHJldHVyblxuICAgICAgICAgICAgbG9jYWwgPSAnZGVmYXVsdCdcbiAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgY2FzZSAnRXhwb3J0TmFtZXNwYWNlU3BlY2lmaWVyJzpcbiAgICAgICAgICAgIG0ubmFtZXNwYWNlLnNldChzLmV4cG9ydGVkLm5hbWUsIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRNZXRhLCAnbmFtZXNwYWNlJywge1xuICAgICAgICAgICAgICBnZXQoKSB7IHJldHVybiByZXNvbHZlSW1wb3J0KG5zb3VyY2UpIH0sXG4gICAgICAgICAgICB9KSlcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIGNhc2UgJ0V4cG9ydFNwZWNpZmllcic6XG4gICAgICAgICAgICBpZiAoIW4uc291cmNlKSB7XG4gICAgICAgICAgICAgIG0ubmFtZXNwYWNlLnNldChzLmV4cG9ydGVkLm5hbWUsIGFkZE5hbWVzcGFjZShleHBvcnRNZXRhLCBzLmxvY2FsKSlcbiAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG4gICAg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ZWREZWNsID0gbW9kdWxlQmxvY2tOb2RlLnR5cGUgPT09ICdFeHBvcnROYW1lZERlY2xhcmF0aW9uJyA/XG4gICAgICAgICAgICAgIG1vZHVsZUJsb2NrTm9kZS5kZWNsYXJhdGlvbiA6XG4gICAgICAgICAgICAgIG1vZHVsZUJsb2NrTm9kZVxuXG4gICAgICAgICAgICBpZiAoZXhwb3J0ZWREZWNsLnR5cGUgPT09ICdWYXJpYWJsZURlY2xhcmF0aW9uJykge1xuICAgICAgICAgICAgICBleHBvcnRlZERlY2wuZGVjbGFyYXRpb25zLmZvckVhY2goKGRlY2wpID0+XG4gICAgICAgICAgICAgICAgcmVjdXJzaXZlUGF0dGVybkNhcHR1cmUoZGVjbC5pZCwoaWQpID0+IG0ubmFtZXNwYWNlLnNldChcbiAgICAgICAgICAgICAgICAgIGlkLm5hbWUsXG4gICAgICAgICAgICAgICAgICBjYXB0dXJlRG9jKHNvdXJjZSwgZG9jU3R5bGVQYXJzZXJzLCBkZWNsLCBleHBvcnRlZERlY2wsIG1vZHVsZUJsb2NrTm9kZSkpXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBtLm5hbWVzcGFjZS5zZXQoXG4gICAgICAgICAgICAgICAgZXhwb3J0ZWREZWNsLmlkLm5hbWUsXG4gICAgICAgICAgICAgICAgY2FwdHVyZURvYyhzb3VyY2UsIGRvY1N0eWxlUGFyc2VycywgbW9kdWxlQmxvY2tOb2RlKSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgICB9KVxuICAgIH1cbiAgfSlcblxuICByZXR1cm4gbVxufVxuXG4vKipcbiAqIFRoZSBjcmVhdGlvbiBvZiB0aGlzIGNsb3N1cmUgaXMgaXNvbGF0ZWQgZnJvbSBvdGhlciBzY29wZXNcbiAqIHRvIGF2b2lkIG92ZXItcmV0ZW50aW9uIG9mIHVucmVsYXRlZC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