InternetProgramming/Lab3/node_modules/eslint-plugin-import/lib/rules/no-named-as-default.js
2023-12-15 14:42:22 +04:00

45 lines
5.2 KiB
JavaScript

'use strict';var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
var _importDeclaration = require('../importDeclaration');var _importDeclaration2 = _interopRequireDefault(_importDeclaration);
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
module.exports = {
meta: {
type: 'problem',
docs: {
category: 'Helpful warnings',
description: 'Forbid use of exported name as identifier of default export.',
url: (0, _docsUrl2['default'])('no-named-as-default') },
schema: [] },
create: function () {function create(context) {
function checkDefault(nameKey, defaultSpecifier) {
// #566: default is a valid specifier
if (defaultSpecifier[nameKey].name === 'default') {return;}
var declaration = (0, _importDeclaration2['default'])(context);
var imports = _ExportMap2['default'].get(declaration.source.value, context);
if (imports == null) {return;}
if (imports.errors.length) {
imports.reportErrors(context, declaration);
return;
}
if (imports.has('default') && imports.has(defaultSpecifier[nameKey].name)) {
context.report(
defaultSpecifier, 'Using exported name \'' + String(
defaultSpecifier[nameKey].name) + '\' as identifier for default export.');
}
}
return {
ImportDefaultSpecifier: checkDefault.bind(null, 'local'),
ExportDefaultSpecifier: checkDefault.bind(null, 'exported') };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1hcy1kZWZhdWx0LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJjYXRlZ29yeSIsImRlc2NyaXB0aW9uIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsImNoZWNrRGVmYXVsdCIsIm5hbWVLZXkiLCJkZWZhdWx0U3BlY2lmaWVyIiwibmFtZSIsImRlY2x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