internet-programming/lab3/node_modules/eslint-plugin-import/lib/rules/no-anonymous-default-export.js

103 lines
12 KiB
JavaScript

'use strict';
var _has = require('has');var _has2 = _interopRequireDefault(_has);
var _object = require('object.values');var _object2 = _interopRequireDefault(_object);
var _object3 = require('object.fromentries');var _object4 = _interopRequireDefault(_object3);
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };} /**
* @fileoverview Rule to disallow anonymous default exports.
* @author Duncan Beevers
*/var defs = { ArrayExpression: {
option: 'allowArray',
description: 'If `false`, will report default export of an array',
message: 'Assign array to a variable before exporting as module default' },
ArrowFunctionExpression: {
option: 'allowArrowFunction',
description: 'If `false`, will report default export of an arrow function',
message: 'Assign arrow function to a variable before exporting as module default' },
CallExpression: {
option: 'allowCallExpression',
description: 'If `false`, will report default export of a function call',
message: 'Assign call result to a variable before exporting as module default',
'default': true },
ClassDeclaration: {
option: 'allowAnonymousClass',
description: 'If `false`, will report default export of an anonymous class',
message: 'Unexpected default export of anonymous class',
forbid: function () {function forbid(node) {return !node.declaration.id;}return forbid;}() },
FunctionDeclaration: {
option: 'allowAnonymousFunction',
description: 'If `false`, will report default export of an anonymous function',
message: 'Unexpected default export of anonymous function',
forbid: function () {function forbid(node) {return !node.declaration.id;}return forbid;}() },
Literal: {
option: 'allowLiteral',
description: 'If `false`, will report default export of a literal',
message: 'Assign literal to a variable before exporting as module default' },
ObjectExpression: {
option: 'allowObject',
description: 'If `false`, will report default export of an object expression',
message: 'Assign object to a variable before exporting as module default' },
TemplateLiteral: {
option: 'allowLiteral',
description: 'If `false`, will report default export of a literal',
message: 'Assign literal to a variable before exporting as module default' },
NewExpression: {
option: 'allowNew',
description: 'If `false`, will report default export of a class instantiation',
message: 'Assign instance to a variable before exporting as module default' } };
var schemaProperties = (0, _object4['default'])((0, _object2['default'])(defs).map(function (def) {return [def.option, {
description: def.description,
type: 'boolean' }];}));
var defaults = (0, _object4['default'])((0, _object2['default'])(defs).map(function (def) {return [def.option, (0, _has2['default'])(def, 'default') ? def['default'] : false];}));
module.exports = {
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Forbid anonymous values as default exports.',
url: (0, _docsUrl2['default'])('no-anonymous-default-export') },
schema: [
{
type: 'object',
properties: schemaProperties,
additionalProperties: false }] },
create: function () {function create(context) {
var options = Object.assign({}, defaults, context.options[0]);
return {
ExportDefaultDeclaration: function () {function ExportDefaultDeclaration(node) {
var def = defs[node.declaration.type];
// Recognized node type and allowed by configuration,
// and has no forbid check, or forbid check return value is truthy
if (def && !options[def.option] && (!def.forbid || def.forbid(node))) {
context.report({ node: node, message: def.message });
}
}return ExportDefaultDeclaration;}() };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1hbm9ueW1vdXMtZGVmYXVsdC1leHBvcnQuanMiXSwibmFtZXMiOlsiZGVmcyIsIkFycmF5RXhwcmVzc2lvbiIsIm9wdGlvbiIsImRlc2NyaXB0aW9uIiwibWVzc2FnZSIsIkFycm93RnVuY3Rpb25FeHByZXNzaW9uIiwiQ2FsbEV4cHJlc3Npb24iLCJDbGFzc0RlY2xhcmF0aW9uIiwiZm9yYmlkIiwibm9kZSIsImRlY2xhcmF0aW9uIiwiaWQiLCJGdW5jdGlvbkRlY2xhcmF0aW9uIiwiTGl0ZXJhbCIsIk9iamVjdEV4cHJlc3Npb24iLCJUZW1wbGF0ZUxpdGVyYWwiLCJOZXdFeHByZXNzaW9uIiwic2NoZW1hUHJvcGVydGllcyIsIm1hcCIsImRlZiIsInR5cGUiLCJkZWZhdWx0cyIsIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiZG9jcyIsImNhdGVnb3J5IiwidXJsIiwic2NoZW1hIiwicHJvcGVydGllcyIsImFkZGl0aW9uYWxQcm9wZXJ0aWVzIiwiY3JlYXR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