Skip to content

Commit f12491a

Browse files
authored
refactor: avoid importing eslint internal util
refactor: avoid importing eslint internal util
2 parents bd0684a + 4608e4c commit f12491a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/eslint/getJSDocComment.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
* Obtained from {@link https://github.com/eslint/eslint/blob/master/lib/util/source-code.js#L313}
33
* @license MIT
44
*/
5-
import astUtils from 'eslint/lib/util/ast-utils';
5+
6+
/**
7+
* Checks if the given token is a comment token or not.
8+
*
9+
* @param {Token} token - The token to check.
10+
* @returns {boolean} `true` if the token is a comment token.
11+
*/
12+
const isCommentToken = (token) => {
13+
return token.type === 'Line' || token.type === 'Block' || token.type === 'Shebang';
14+
};
615

716
/**
817
* Check to see if its a ES6 export declaration.
@@ -40,7 +49,7 @@ const getJSDocComment = function (sourceCode, node) {
4049

4150
if (
4251
tokenBefore &&
43-
astUtils.isCommentToken(tokenBefore) &&
52+
isCommentToken(tokenBefore) &&
4453
tokenBefore.type === 'Block' &&
4554
tokenBefore.value.charAt(0) === '*' &&
4655
astNode.loc.start.line - tokenBefore.loc.end.line <= 1

0 commit comments

Comments
 (0)