mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
72 lines
8.0 KiB
JavaScript
72 lines
8.0 KiB
JavaScript
|
'use strict';var _path = require('path');var path = _interopRequireWildcard(_path);
|
||
|
var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
|
||
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}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;}}
|
||
|
|
||
|
module.exports = {
|
||
|
meta: {
|
||
|
type: 'problem',
|
||
|
docs: {
|
||
|
url: (0, _docsUrl2.default)('named') },
|
||
|
|
||
|
schema: [] },
|
||
|
|
||
|
|
||
|
create: function (context) {
|
||
|
function checkSpecifiers(key, type, node) {
|
||
|
// ignore local exports and type imports/exports
|
||
|
if (node.source == null || node.importKind === 'type' ||
|
||
|
node.importKind === 'typeof' || node.exportKind === 'type') {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!node.specifiers.
|
||
|
some(function (im) {return im.type === type;})) {
|
||
|
return; // no named imports/exports
|
||
|
}
|
||
|
|
||
|
const imports = _ExportMap2.default.get(node.source.value, context);
|
||
|
if (imports == null) return;
|
||
|
|
||
|
if (imports.errors.length) {
|
||
|
imports.reportErrors(context, node);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
node.specifiers.forEach(function (im) {
|
||
|
if (im.type !== type) return;
|
||
|
|
||
|
// ignore type imports
|
||
|
if (im.importKind === 'type' || im.importKind === 'typeof') return;
|
||
|
|
||
|
const deepLookup = imports.hasDeep(im[key].name);
|
||
|
|
||
|
if (!deepLookup.found) {
|
||
|
if (deepLookup.path.length > 1) {
|
||
|
const deepPath = deepLookup.path.
|
||
|
map(i => path.relative(path.dirname(context.getFilename()), i.path)).
|
||
|
join(' -> ');
|
||
|
|
||
|
context.report(im[key],
|
||
|
`${im[key].name} not found via ${deepPath}`);
|
||
|
} else {
|
||
|
context.report(im[key],
|
||
|
im[key].name + ' not found in \'' + node.source.value + '\'');
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
'ImportDeclaration': checkSpecifiers.bind(null,
|
||
|
'imported',
|
||
|
'ImportSpecifier'),
|
||
|
|
||
|
|
||
|
'ExportNamedDeclaration': checkSpecifiers.bind(null,
|
||
|
'local',
|
||
|
'ExportSpecifier') };
|
||
|
|
||
|
|
||
|
|
||
|
} };
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uYW1lZC5qcyJdLCJuYW1lcyI6WyJwYXRoIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJjaGVja1NwZWNpZmllcnMiLCJrZXkiLCJub2RlIiwic291cmNlIiwiaW1wb3J0S2luZCIsImV4cG9ydEtpbmQiLCJzcGVjaWZpZXJzIiwic29tZSIsImltIiwiaW1wb3J0cyIsIkV4cG9ydHMiLCJnZXQiLCJ2YWx1ZSIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsImZvckVhY2giLCJkZWVwTG9va3VwIiwiaGFzRGVlcCIsIm5hbWUiLCJmb3VuZCIsImRlZXBQYXRoIiwibWFwIiwiaSIsInJlbGF0aXZlIiwiZGlybmFtZSIsImdldEZpbGVuYW1lIiwiam9pbiIsInJlcG9ydCIsImJpbmQiXSwibWFwcGluZ3MiOiJhQUFBLDRCLElBQVlBLEk7QUFDWix5QztBQUNBLHFDOztBQUVBQyxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU07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