From 6ee3687da6b334118cda627401153c3c13e20e70 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 6 May 2023 15:29:14 +0800 Subject: [PATCH] Fix `expiring-todo-comments` (#2077) --- package.json | 3 ++- rules/expiring-todo-comments.js | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index f73e358753..50933c5ef0 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "c8": "^7.13.0", "chalk": "^5.2.0", "enquirer": "^2.3.6", - "eslint": "^8.38.0", + "eslint": "^8.40.0", "eslint-ava-rule-tester": "^4.0.0", "eslint-doc-generator": "^1.4.3", "eslint-plugin-eslint-plugin": "^5.0.8", @@ -118,6 +118,7 @@ "test/integration/{fixtures,fixtures-local}/**" ], "rules": { + "unicorn/expiring-todo-comments": "off", "unicorn/no-null": "error", "unicorn/prefer-array-flat": [ "error", diff --git a/rules/expiring-todo-comments.js b/rules/expiring-todo-comments.js index 72b44e4360..657eb63adc 100644 --- a/rules/expiring-todo-comments.js +++ b/rules/expiring-todo-comments.js @@ -286,14 +286,11 @@ const create = context => { // Since we have priority, we leave only the comments that we didn't use. const fakeContext = { ...context, - getSourceCode() { - return { - ...sourceCode, - getAllComments() { - return options.allowWarningComments ? [] : unusedComments; - }, - }; + sourceCode: { + ...sourceCode, + getAllComments: () => options.allowWarningComments ? [] : unusedComments, }, + getSourceCode: () => fakeContext.sourceCode, }; const rules = baseRule.create(fakeContext);