'use strict'; var _docsUrl = require('../docsUrl'); var _docsUrl2 = _interopRequireDefault(_docsUrl); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } module.exports = { meta: { docs: { url: (0, _docsUrl2.default)('dynamic-import-chunkname') }, schema: [{ type: 'object', properties: { importFunctions: { type: 'array', uniqueItems: true, items: { type: 'string' } }, webpackChunknameFormat: { type: 'string' } } }] }, create: function (context) { const config = context.options[0]; var _ref = config || {}, _ref$importFunctions = _ref.importFunctions; const importFunctions = _ref$importFunctions === undefined ? [] : _ref$importFunctions; var _ref2 = config || {}, _ref2$webpackChunknam = _ref2.webpackChunknameFormat; const webpackChunknameFormat = _ref2$webpackChunknam === undefined ? '[0-9a-zA-Z-_/.]+' : _ref2$webpackChunknam; const commentFormat = ` webpackChunkName: "${webpackChunknameFormat}" `; const commentRegex = new RegExp(commentFormat); return { CallExpression(node) { if (node.callee.type !== 'Import' && importFunctions.indexOf(node.callee.name) < 0) { return; } const sourceCode = context.getSourceCode(); const arg = node.arguments[0]; const leadingComments = sourceCode.getComments(arg).leading; if (!leadingComments || leadingComments.length !== 1) { context.report({ node, message: 'dynamic imports require a leading comment with the webpack chunkname' }); return; } const comment = leadingComments[0]; if (comment.type !== 'Block') { context.report({ node, message: 'dynamic imports require a /* foo */ style comment, not a // foo comment' }); return; } const webpackChunkDefinition = comment.value; if (!webpackChunkDefinition.match(commentRegex)) { context.report({ node, message: `dynamic imports require a leading comment in the form /*${commentFormat}*/` }); } } }; } }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL2R5bmFtaWMtaW1wb3J0LWNodW5rbmFtZS5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsImRvY3MiLCJ1cmwiLCJzY2hlbWEiLCJ0eXBlIiwicHJvcGVydGllcyIsImltcG9ydEZ1bmN0aW9ucyIsInVuaXF1ZUl0ZW1zIiwiaXRl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