Skip to content

Commit 5c67f17

Browse files
committed
[Refactor] avoid using deprecated eslint api sourceCode.getComments
1 parent a86ba06 commit 5c67f17

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/rules/dynamic-import-chunkname.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ module.exports = {
4242

4343
const sourceCode = context.getSourceCode()
4444
const arg = node.arguments[0]
45-
const leadingComments = sourceCode.getComments(arg).leading
45+
const leadingComments = sourceCode.getCommentsBefore
46+
? sourceCode.getCommentsBefore(arg) // This method is available in ESLint >= 4.
47+
: sourceCode.getComments(arg).leading // This method is deprecated in ESLint 7.
4648

4749
if (!leadingComments || leadingComments.length === 0) {
4850
context.report({

0 commit comments

Comments
 (0)