Skip to content

Commit 7ccb155

Browse files
committed
Refactor
1 parent 894f1d4 commit 7ccb155

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/rules/no-implicit-propagation.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { ESLintUtils, AST_NODE_TYPES } = require('@typescript-eslint/utils');
33
const utils = require('@typescript-eslint/type-utils');
44
const {
55
getLast,
6+
getNodeID,
67
createRule,
78
isInHandledContext,
89
typesToUnionString,
@@ -147,8 +148,8 @@ module.exports = createRule({
147148

148149
/** @param {import('@typescript-eslint/utils').TSESTree.Expression} node */
149150
const visitExpression = (node) => {
150-
if (visitedNodes.has(node.range[0])) return;
151-
visitedNodes.add(node.range[0]);
151+
if (visitedNodes.has(getNodeID(node))) return;
152+
visitedNodes.add(getNodeID(node));
152153

153154
if (isInHandledContext(node)) return;
154155

src/rules/no-undocumented-throws.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const ts = require('typescript');
55
const {
66
getFirst,
77
getLast,
8+
getNodeID,
89
createRule,
910
findParent,
1011
hasJSDocThrowsTag,
@@ -60,14 +61,6 @@ module.exports = createRule({
6061

6162
const visitedNodes = new Set();
6263

63-
/**
64-
* @param {import('@typescript-eslint/utils').TSESTree.Node} node
65-
* @returns {string}
66-
*/
67-
const getNodeID = (node) => {
68-
return `${node.type}:${node.loc.start.line}:${node.loc.start.column}`;
69-
};
70-
7164
/**
7265
* Group throw statements in functions
7366
* @type {Map<string, import('@typescript-eslint/utils').TSESTree.ThrowStatement[]>}

src/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ const hasThrowsTag = comment =>
5252
comment.includes('@throws') ||
5353
comment.includes('@exception');
5454

55+
/**
56+
* @param {import('@typescript-eslint/utils').TSESTree.Node} node
57+
* @returns {string}
58+
*/
59+
const getNodeID = (node) => {
60+
return `${node.loc.start.line}:${node.loc.start.column}`;
61+
};
62+
5563
/**
5664
* Check if node has JSDoc comment with @throws or @exception tag.
5765
*
@@ -410,6 +418,7 @@ const createInsertJSDocBeforeFixer = (sourceCode, node, typeString) => {
410418
module.exports = {
411419
getFirst,
412420
getLast,
421+
getNodeID,
413422
createRule,
414423
hasThrowsTag,
415424
hasJSDocThrowsTag,

0 commit comments

Comments
 (0)