no-duplicates.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. '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 _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
  2. var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}function _toConsumableArray(arr) {if (Array.isArray(arr)) {for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {arr2[i] = arr[i];}return arr2;} else {return Array.from(arr);}}function _toArray(arr) {return Array.isArray(arr) ? arr : Array.from(arr);}
  3. function checkImports(imported, context) {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {
  4. for (var _iterator = imported.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var _ref = _step.value;var _ref2 = _slicedToArray(_ref, 2);var _module = _ref2[0];var nodes = _ref2[1];
  5. if (nodes.length > 1) {
  6. var message = '\'' + String(_module) + '\' imported multiple times.';var _nodes = _toArray(
  7. nodes),first = _nodes[0],rest = _nodes.slice(1);
  8. var sourceCode = context.getSourceCode();
  9. var fix = getFix(first, rest, sourceCode);
  10. context.report({
  11. node: first.source,
  12. message: message,
  13. fix: fix // Attach the autofix (if any) to the first import.
  14. });var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
  15. for (var _iterator2 = rest[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var node = _step2.value;
  16. context.report({
  17. node: node.source,
  18. message: message });
  19. }} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2['return']) {_iterator2['return']();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}}
  20. }
  21. }} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator['return']) {_iterator['return']();}} finally {if (_didIteratorError) {throw _iteratorError;}}}
  22. }
  23. function getFix(first, rest, sourceCode) {
  24. // Sorry ESLint <= 3 users, no autofix for you. Autofixing duplicate imports
  25. // requires multiple `fixer.whatever()` calls in the `fix`: We both need to
  26. // update the first one, and remove the rest. Support for multiple
  27. // `fixer.whatever()` in a single `fix` was added in ESLint 4.1.
  28. // `sourceCode.getCommentsBefore` was added in 4.0, so that's an easy thing to
  29. // check for.
  30. if (typeof sourceCode.getCommentsBefore !== 'function') {
  31. return undefined;
  32. }
  33. // Adjusting the first import might make it multiline, which could break
  34. // `eslint-disable-next-line` comments and similar, so bail if the first
  35. // import has comments. Also, if the first import is `import * as ns from
  36. // './foo'` there's nothing we can do.
  37. if (hasProblematicComments(first, sourceCode) || hasNamespace(first)) {
  38. return undefined;
  39. }
  40. var defaultImportNames = new Set(
  41. [first].concat(_toConsumableArray(rest)).map(getDefaultImportName).filter(Boolean));
  42. // Bail if there are multiple different default import names – it's up to the
  43. // user to choose which one to keep.
  44. if (defaultImportNames.size > 1) {
  45. return undefined;
  46. }
  47. // Leave it to the user to handle comments. Also skip `import * as ns from
  48. // './foo'` imports, since they cannot be merged into another import.
  49. var restWithoutComments = rest.filter(function (node) {return !(
  50. hasProblematicComments(node, sourceCode) ||
  51. hasNamespace(node));});
  52. var specifiers = restWithoutComments.
  53. map(function (node) {
  54. var tokens = sourceCode.getTokens(node);
  55. var openBrace = tokens.find(function (token) {return isPunctuator(token, '{');});
  56. var closeBrace = tokens.find(function (token) {return isPunctuator(token, '}');});
  57. if (openBrace == null || closeBrace == null) {
  58. return undefined;
  59. }
  60. return {
  61. importNode: node,
  62. text: sourceCode.text.slice(openBrace.range[1], closeBrace.range[0]),
  63. hasTrailingComma: isPunctuator(sourceCode.getTokenBefore(closeBrace), ','),
  64. isEmpty: !hasSpecifiers(node) };
  65. }).
  66. filter(Boolean);
  67. var unnecessaryImports = restWithoutComments.filter(function (node) {return (
  68. !hasSpecifiers(node) &&
  69. !hasNamespace(node) &&
  70. !specifiers.some(function (specifier) {return specifier.importNode === node;}));});
  71. var shouldAddDefault = getDefaultImportName(first) == null && defaultImportNames.size === 1;
  72. var shouldAddSpecifiers = specifiers.length > 0;
  73. var shouldRemoveUnnecessary = unnecessaryImports.length > 0;
  74. if (!(shouldAddDefault || shouldAddSpecifiers || shouldRemoveUnnecessary)) {
  75. return undefined;
  76. }
  77. return function (fixer) {
  78. var tokens = sourceCode.getTokens(first);
  79. var openBrace = tokens.find(function (token) {return isPunctuator(token, '{');});
  80. var closeBrace = tokens.find(function (token) {return isPunctuator(token, '}');});
  81. var firstToken = sourceCode.getFirstToken(first);var _defaultImportNames = _slicedToArray(
  82. defaultImportNames, 1),defaultImportName = _defaultImportNames[0];
  83. var firstHasTrailingComma =
  84. closeBrace != null &&
  85. isPunctuator(sourceCode.getTokenBefore(closeBrace), ',');
  86. var firstIsEmpty = !hasSpecifiers(first);var _specifiers$reduce =
  87. specifiers.reduce(
  88. function (_ref3, specifier) {var _ref4 = _slicedToArray(_ref3, 2),result = _ref4[0],needsComma = _ref4[1];
  89. return [
  90. needsComma && !specifier.isEmpty ? String(
  91. result) + ',' + String(specifier.text) : '' + String(
  92. result) + String(specifier.text),
  93. specifier.isEmpty ? needsComma : true];
  94. },
  95. ['', !firstHasTrailingComma && !firstIsEmpty]),_specifiers$reduce2 = _slicedToArray(_specifiers$reduce, 1),specifiersText = _specifiers$reduce2[0];
  96. var fixes = [];
  97. if (shouldAddDefault && openBrace == null && shouldAddSpecifiers) {
  98. // `import './foo'` → `import def, {...} from './foo'`
  99. fixes.push(
  100. fixer.insertTextAfter(firstToken, ' ' + String(defaultImportName) + ', {' + String(specifiersText) + '} from'));
  101. } else if (shouldAddDefault && openBrace == null && !shouldAddSpecifiers) {
  102. // `import './foo'` → `import def from './foo'`
  103. fixes.push(fixer.insertTextAfter(firstToken, ' ' + String(defaultImportName) + ' from'));
  104. } else if (shouldAddDefault && openBrace != null && closeBrace != null) {
  105. // `import {...} from './foo'` → `import def, {...} from './foo'`
  106. fixes.push(fixer.insertTextAfter(firstToken, ' ' + String(defaultImportName) + ','));
  107. if (shouldAddSpecifiers) {
  108. // `import def, {...} from './foo'` → `import def, {..., ...} from './foo'`
  109. fixes.push(fixer.insertTextBefore(closeBrace, specifiersText));
  110. }
  111. } else if (!shouldAddDefault && openBrace == null && shouldAddSpecifiers) {
  112. if (first.specifiers.length === 0) {
  113. // `import './foo'` → `import {...} from './foo'`
  114. fixes.push(fixer.insertTextAfter(firstToken, ' {' + String(specifiersText) + '} from'));
  115. } else {
  116. // `import def from './foo'` → `import def, {...} from './foo'`
  117. fixes.push(fixer.insertTextAfter(first.specifiers[0], ', {' + String(specifiersText) + '}'));
  118. }
  119. } else if (!shouldAddDefault && openBrace != null && closeBrace != null) {
  120. // `import {...} './foo'` → `import {..., ...} from './foo'`
  121. fixes.push(fixer.insertTextBefore(closeBrace, specifiersText));
  122. }
  123. // Remove imports whose specifiers have been moved into the first import.
  124. var _iteratorNormalCompletion3 = true;var _didIteratorError3 = false;var _iteratorError3 = undefined;try {for (var _iterator3 = specifiers[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {var specifier = _step3.value;
  125. var importNode = specifier.importNode;
  126. fixes.push(fixer.remove(importNode));
  127. var charAfterImportRange = [importNode.range[1], importNode.range[1] + 1];
  128. var charAfterImport = sourceCode.text.substring(charAfterImportRange[0], charAfterImportRange[1]);
  129. if (charAfterImport === '\n') {
  130. fixes.push(fixer.removeRange(charAfterImportRange));
  131. }
  132. }
  133. // Remove imports whose default import has been moved to the first import,
  134. // and side-effect-only imports that are unnecessary due to the first
  135. // import.
  136. } catch (err) {_didIteratorError3 = true;_iteratorError3 = err;} finally {try {if (!_iteratorNormalCompletion3 && _iterator3['return']) {_iterator3['return']();}} finally {if (_didIteratorError3) {throw _iteratorError3;}}}var _iteratorNormalCompletion4 = true;var _didIteratorError4 = false;var _iteratorError4 = undefined;try {for (var _iterator4 = unnecessaryImports[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {var node = _step4.value;
  137. fixes.push(fixer.remove(node));
  138. var charAfterImportRange = [node.range[1], node.range[1] + 1];
  139. var charAfterImport = sourceCode.text.substring(charAfterImportRange[0], charAfterImportRange[1]);
  140. if (charAfterImport === '\n') {
  141. fixes.push(fixer.removeRange(charAfterImportRange));
  142. }
  143. }} catch (err) {_didIteratorError4 = true;_iteratorError4 = err;} finally {try {if (!_iteratorNormalCompletion4 && _iterator4['return']) {_iterator4['return']();}} finally {if (_didIteratorError4) {throw _iteratorError4;}}}
  144. return fixes;
  145. };
  146. }
  147. function isPunctuator(node, value) {
  148. return node.type === 'Punctuator' && node.value === value;
  149. }
  150. // Get the name of the default import of `node`, if any.
  151. function getDefaultImportName(node) {
  152. var defaultSpecifier = node.specifiers.
  153. find(function (specifier) {return specifier.type === 'ImportDefaultSpecifier';});
  154. return defaultSpecifier != null ? defaultSpecifier.local.name : undefined;
  155. }
  156. // Checks whether `node` has a namespace import.
  157. function hasNamespace(node) {
  158. var specifiers = node.specifiers.
  159. filter(function (specifier) {return specifier.type === 'ImportNamespaceSpecifier';});
  160. return specifiers.length > 0;
  161. }
  162. // Checks whether `node` has any non-default specifiers.
  163. function hasSpecifiers(node) {
  164. var specifiers = node.specifiers.
  165. filter(function (specifier) {return specifier.type === 'ImportSpecifier';});
  166. return specifiers.length > 0;
  167. }
  168. // It's not obvious what the user wants to do with comments associated with
  169. // duplicate imports, so skip imports with comments when autofixing.
  170. function hasProblematicComments(node, sourceCode) {
  171. return (
  172. hasCommentBefore(node, sourceCode) ||
  173. hasCommentAfter(node, sourceCode) ||
  174. hasCommentInsideNonSpecifiers(node, sourceCode));
  175. }
  176. // Checks whether `node` has a comment (that ends) on the previous line or on
  177. // the same line as `node` (starts).
  178. function hasCommentBefore(node, sourceCode) {
  179. return sourceCode.getCommentsBefore(node).
  180. some(function (comment) {return comment.loc.end.line >= node.loc.start.line - 1;});
  181. }
  182. // Checks whether `node` has a comment (that starts) on the same line as `node`
  183. // (ends).
  184. function hasCommentAfter(node, sourceCode) {
  185. return sourceCode.getCommentsAfter(node).
  186. some(function (comment) {return comment.loc.start.line === node.loc.end.line;});
  187. }
  188. // Checks whether `node` has any comments _inside,_ except inside the `{...}`
  189. // part (if any).
  190. function hasCommentInsideNonSpecifiers(node, sourceCode) {
  191. var tokens = sourceCode.getTokens(node);
  192. var openBraceIndex = tokens.findIndex(function (token) {return isPunctuator(token, '{');});
  193. var closeBraceIndex = tokens.findIndex(function (token) {return isPunctuator(token, '}');});
  194. // Slice away the first token, since we're no looking for comments _before_
  195. // `node` (only inside). If there's a `{...}` part, look for comments before
  196. // the `{`, but not before the `}` (hence the `+1`s).
  197. var someTokens = openBraceIndex >= 0 && closeBraceIndex >= 0 ?
  198. tokens.slice(1, openBraceIndex + 1).concat(tokens.slice(closeBraceIndex + 1)) :
  199. tokens.slice(1);
  200. return someTokens.some(function (token) {return sourceCode.getCommentsBefore(token).length > 0;});
  201. }
  202. module.exports = {
  203. meta: {
  204. type: 'problem',
  205. docs: {
  206. url: (0, _docsUrl2['default'])('no-duplicates') },
  207. fixable: 'code',
  208. schema: [
  209. {
  210. type: 'object',
  211. properties: {
  212. considerQueryString: {
  213. type: 'boolean' } },
  214. additionalProperties: false }] },
  215. create: function () {function create(context) {
  216. // Prepare the resolver from options.
  217. var considerQueryStringOption = context.options[0] &&
  218. context.options[0]['considerQueryString'];
  219. var defaultResolver = function () {function defaultResolver(sourcePath) {return (0, _resolve2['default'])(sourcePath, context) || sourcePath;}return defaultResolver;}();
  220. var resolver = considerQueryStringOption ? function (sourcePath) {
  221. var parts = sourcePath.match(/^([^?]*)\?(.*)$/);
  222. if (!parts) {
  223. return defaultResolver(sourcePath);
  224. }
  225. return defaultResolver(parts[1]) + '?' + parts[2];
  226. } : defaultResolver;
  227. var moduleMaps = new Map();
  228. function getImportMap(n) {
  229. if (!moduleMaps.has(n.parent)) {
  230. moduleMaps.set(n.parent, {
  231. imported: new Map(),
  232. nsImported: new Map(),
  233. defaultTypesImported: new Map(),
  234. namedTypesImported: new Map() });
  235. }
  236. var map = moduleMaps.get(n.parent);
  237. if (n.importKind === 'type') {
  238. return n.specifiers.length > 0 && n.specifiers[0].type === 'ImportDefaultSpecifier' ? map.defaultTypesImported : map.namedTypesImported;
  239. }
  240. return hasNamespace(n) ? map.nsImported : map.imported;
  241. }
  242. return {
  243. ImportDeclaration: function () {function ImportDeclaration(n) {
  244. // resolved path will cover aliased duplicates
  245. var resolvedPath = resolver(n.source.value);
  246. var importMap = getImportMap(n);
  247. if (importMap.has(resolvedPath)) {
  248. importMap.get(resolvedPath).push(n);
  249. } else {
  250. importMap.set(resolvedPath, [n]);
  251. }
  252. }return ImportDeclaration;}(),
  253. 'Program:exit': function () {function ProgramExit() {var _iteratorNormalCompletion5 = true;var _didIteratorError5 = false;var _iteratorError5 = undefined;try {
  254. for (var _iterator5 = moduleMaps.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {var map = _step5.value;
  255. checkImports(map.imported, context);
  256. checkImports(map.nsImported, context);
  257. checkImports(map.defaultTypesImported, context);
  258. checkImports(map.namedTypesImported, context);
  259. }} catch (err) {_didIteratorError5 = true;_iteratorError5 = err;} finally {try {if (!_iteratorNormalCompletion5 && _iterator5['return']) {_iterator5['return']();}} finally {if (_didIteratorError5) {throw _iteratorError5;}}}
  260. }return ProgramExit;}() };
  261. }return create;}() };
  262. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kdXBsaWNhdGVzLmpzIl0sIm5hbWVzIjpbImNoZWNrSW1wb3J0cyIsImltcG9ydGVkIiwiY29udGV4dCIsImVudHJpZXMiLCJtb2R1bGUiLCJub2RlcyIsImxlbmd0aCIsIm1lc3NhZ2UiLCJmaXJzdCIsInJlc3QiLCJzb3VyY2VDb2RlIiwiZ2V0U291cmNlQ29kZSIsImZpeCIsImdldEZpeCIsInJlcG9ydCIsIm5vZGUiLCJzb3VyY2UiLCJnZXRDb21tZW50c0JlZm9yZSIsInVuZGVmaW5lZCIsImhhc1Byb2JsZW1hdGljQ29tbWVudHMiLCJoYXNOYW1lc3BhY2UiLCJkZWZhdWx0SW1wb3J0TmFtZXMiLCJTZXQiLCJtYXAiLCJnZXREZWZhdWx0SW1wb3J0TmFtZSIsImZpbHRlciIsIkJvb2xlYW4iLCJzaXplIiwicmVzdFdpdGhvdXRDb21tZW50cyIsInNwZWNpZmllcnMiLCJ0b2tlbnMiLCJnZXRUb2tlbnMiLCJvcGVuQnJhY2UiLCJmaW5kIiwiaXNQdW5jdHVhdG9yIiwidG9rZW4iLCJjbG9zZUJyYWNlIiwiaW1wb3J0Tm9k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