From 7a6861a529b6e75ce98efe14d4b1b377c886e91e 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) # Conflicts: # package.json --- 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 261069bdb3..067d2c3cda 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "c8": "^7.12.0", "chalk": "^5.1.2", "enquirer": "^2.3.6", - "eslint": "^8.28.0", + "eslint": "^8.40.0", "eslint-ava-rule-tester": "^4.0.0", "eslint-doc-generator": "^1.0.0", "eslint-plugin-eslint-plugin": "^5.0.6", @@ -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);