PromoCursed/node_modules/eslint-plugin-import/lib/rules/no-empty-named-blocks.js
2024-08-20 23:25:37 +04:00

105 lines
15 KiB
JavaScript

'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
function getEmptyBlockRange(tokens, index) {
var token = tokens[index];
var nextToken = tokens[index + 1];
var prevToken = tokens[index - 1];
var start = token.range[0];
var end = nextToken.range[1];
// Remove block tokens and the previous comma
if (prevToken.value === ',' || prevToken.value === 'type' || prevToken.value === 'typeof') {
start = prevToken.range[0];
}
return [start, end];
}
module.exports = {
meta: {
type: 'suggestion',
docs: {
category: 'Helpful warnings',
description: 'Forbid empty named import blocks.',
url: (0, _docsUrl2['default'])('no-empty-named-blocks') },
fixable: 'code',
schema: [],
hasSuggestions: true },
create: function () {function create(context) {
var importsWithoutNameds = [];
return {
ImportDeclaration: function () {function ImportDeclaration(node) {
if (!node.specifiers.some(function (x) {return x.type === 'ImportSpecifier';})) {
importsWithoutNameds.push(node);
}
}return ImportDeclaration;}(),
'Program:exit': function () {function ProgramExit(program) {
var importsTokens = importsWithoutNameds.map(function (node) {return [node, program.tokens.filter(function (x) {return x.range[0] >= node.range[0] && x.range[1] <= node.range[1];})];});
importsTokens.forEach(function (_ref) {var _ref2 = _slicedToArray(_ref, 2),node = _ref2[0],tokens = _ref2[1];
tokens.forEach(function (token) {
var idx = program.tokens.indexOf(token);
var nextToken = program.tokens[idx + 1];
if (nextToken && token.value === '{' && nextToken.value === '}') {
var hasOtherIdentifiers = tokens.some(function (token) {return token.type === 'Identifier' &&
token.value !== 'from' &&
token.value !== 'type' &&
token.value !== 'typeof';});
// If it has no other identifiers it's the only thing in the import, so we can either remove the import
// completely or transform it in a side-effects only import
if (!hasOtherIdentifiers) {
context.report({
node: node,
message: 'Unexpected empty named import block',
suggest: [
{
desc: 'Remove unused import',
fix: function () {function fix(fixer) {
// Remove the whole import
return fixer.remove(node);
}return fix;}() },
{
desc: 'Remove empty import block',
fix: function () {function fix(fixer) {
// Remove the empty block and the 'from' token, leaving the import only for its side
// effects, e.g. `import 'mod'`
var sourceCode = context.getSourceCode();
var fromToken = program.tokens.find(function (t) {return t.value === 'from';});
var importToken = program.tokens.find(function (t) {return t.value === 'import';});
var hasSpaceAfterFrom = sourceCode.isSpaceBetween(fromToken, sourceCode.getTokenAfter(fromToken));
var hasSpaceAfterImport = sourceCode.isSpaceBetween(importToken, sourceCode.getTokenAfter(fromToken));var _getEmptyBlockRange =
getEmptyBlockRange(program.tokens, idx),_getEmptyBlockRange2 = _slicedToArray(_getEmptyBlockRange, 1),start = _getEmptyBlockRange2[0];var _fromToken$range = _slicedToArray(
fromToken.range, 2),end = _fromToken$range[1];
var range = [start, hasSpaceAfterFrom ? end + 1 : end];
return fixer.replaceTextRange(range, hasSpaceAfterImport ? '' : ' ');
}return fix;}() }] });
} else {
context.report({
node: node,
message: 'Unexpected empty named import block',
fix: function () {function fix(fixer) {
return fixer.removeRange(getEmptyBlockRange(program.tokens, idx));
}return fix;}() });
}
}
});
});
}return ProgramExit;}() };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1lbXB0eS1uYW1lZC1ibG9ja3MuanMiXSwibmFtZXMiOlsiZ2V0RW1wdHlCbG9ja1Jhbm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Z2VbMF0gJiYgeC5yYW5nZVsxXSA8PSBub2RlLnJhbmdlWzFdKV0pO1xuXG4gICAgICAgIGltcG9ydHNUb2tlbnMuZm9yRWFjaCgoW25vZGUsIHRva2Vuc10pID0+IHtcbiAgICAgICAgICB0b2tlbnMuZm9yRWFjaCgodG9rZW4pID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGlkeCA9IHByb2dyYW0udG9rZW5zLmluZGV4T2YodG9rZW4pO1xuICAgICAgICAgICAgY29uc3QgbmV4dFRva2VuID0gcHJvZ3JhbS50b2tlbnNbaWR4ICsgMV07XG5cbiAgICAgICAgICAgIGlmIChuZXh0VG9rZW4gJiYgdG9rZW4udmFsdWUgPT09ICd7JyAmJiBuZXh0VG9rZW4udmFsdWUgPT09ICd9Jykge1xuICAgICAgICAgICAgICBjb25zdCBoYXNPdGhlcklkZW50aWZpZXJzID0gdG9rZW5zLnNvbWUoKHRva2VuKSA9PiB0b2tlbi50eXBlID09PSAnSWRlbnRpZmllcidcbiAgICAgICAgICAgICAgICAgICYmIHRva2VuLnZhbHVlICE9PSAnZnJvbSdcbiAgICAgICAgICAgICAgICAgICYmIHRva2VuLnZhbHVlICE9PSAndHlwZSdcbiAgICAgICAgICAgICAgICAgICYmIHRva2VuLnZhbHVlICE9PSAndHlwZW9mJyxcbiAgICAgICAgICAgICAgKTtcblxuICAgICAgICAgICAgICAvLyBJZiBpdCBoYXMgbm8gb3RoZXIgaWRlbnRpZmllcnMgaXQncyB0aGUgb25seSB0aGluZyBpbiB0aGUgaW1wb3J0LCBzbyB3ZSBjYW4gZWl0aGVyIHJlbW92ZSB0aGUgaW1wb3J0XG4gICAgICAgICAgICAgIC8vIGNvbXBsZXRlbHkgb3IgdHJhbnNmb3JtIGl0IGluIGEgc2lkZS1lZmZlY3RzIG9ubHkgaW1wb3J0XG4gICAgICAgICAgICAgIGlmICghaGFzT3RoZXJJZGVudGlmaWVycykge1xuICAgICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KHtcbiAgICAgICAgICAgICAgICAgIG5vZGUsXG4gICAgICAgICAgICAgICAgICBtZXNzYWdlOiAnVW5leHBlY3RlZCBlbXB0eSBuYW1lZCBpbXBvcnQgYmxvY2snLFxuICAgICAgICAgICAgICAgICAgc3VnZ2VzdDogW1xuICAgICAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgICAgZGVzYzogJ1JlbW92ZSB1bnVzZWQgaW1wb3J0JyxcbiAgICAgICAgICAgICAgICAgICAgICBmaXgoZml4ZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlbW92ZSB0aGUgd2hvbGUgaW1wb3J0XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZml4ZXIucmVtb3ZlKG5vZGUpO1xuICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiAnUmVtb3ZlIGVtcHR5IGltcG9ydCBibG9jaycsXG4gICAgICAgICAgICAgICAgICAgICAgZml4KGZpeGVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgdGhlIGVtcHR5IGJsb2NrIGFuZCB0aGUgJ2Zyb20nIHRva2VuLCBsZWF2aW5nIHRoZSBpbXBvcnQgb25seSBmb3IgaXRzIHNpZGVcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGVmZmVjdHMsIGUuZy4gYGltcG9ydCAnbW9kJ2BcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZUNvZGUgPSBjb250ZXh0LmdldFNvdXJjZUNvZGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZyb21Ub2tlbiA9IHByb2dyYW0udG9rZW5zLmZpbmQoKHQpID0+IHQudmFsdWUgPT09ICdmcm9tJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbXBvcnRUb2tlbiA9IHByb2dyYW0udG9rZW5zLmZpbmQoKHQpID0+IHQudmFsdWUgPT09ICdpbXBvcnQnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc1NwYWNlQWZ0ZXJGcm9tID0gc291cmNlQ29kZS5pc1NwYWNlQmV0d2Vlbihmcm9tVG9rZW4sIHNvdXJjZUNvZGUuZ2V0VG9rZW5BZnRlcihmcm9tVG9rZW4pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc1NwYWNlQWZ0ZXJJbXBvcnQgPSBzb3VyY2VDb2RlLmlzU3BhY2VCZXR3ZWVuKGltcG9ydFRva2VuLCBzb3VyY2VDb2RlLmdldFRva2VuQWZ0ZXIoZnJvbVRva2VuKSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtzdGFydF0gPSBnZXRFbXB0eUJsb2NrUmFuZ2UocHJvZ3JhbS50b2tlbnMsIGlkeCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbLCBlbmRdID0gZnJvbVRva2VuLnJhbmdlO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2UgPSBbc3RhcnQsIGhhc1NwYWNlQWZ0ZXJGcm9tID8gZW5kICsgMSA6IGVuZF07XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXhlci5yZXBsYWNlVGV4dFJhbmdlKHJhbmdlLCBoYXNTcGFjZUFmdGVySW1wb3J0ID8gJycgOiAnICcpO1xuICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICBdLFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KHtcbiAgICAgICAgICAgICAgICAgIG5vZGUsXG4gICAgICAgICAgICAgICAgICBtZXNzYWdlOiAnVW5leHBlY3RlZCBlbXB0eSBuYW1lZCBpbXBvcnQgYmxvY2snLFxuICAgICAgICAgICAgICAgICAgZml4KGZpeGVyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXhlci5yZW1vdmVSYW5nZShnZXRFbXB0eUJsb2NrUmFuZ2UocHJvZ3JhbS50b2tlbnMsIGlkeCkpO1xuICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICAgIH0sXG4gICAgfTtcbiAgfSxcbn07XG4iXX0=