From 9c03a78f10765ae18886b9ffb16e41b4e3ea213a Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Mon, 1 Nov 2021 18:18:00 +0800 Subject: [PATCH] Update `eslint-plugin-eslint-plugin` (#1563) --- package.json | 5 ++--- rules/no-unused-properties.js | 2 +- rules/no-useless-undefined.js | 2 +- rules/prefer-optional-catch-binding.js | 7 ++++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 311f329014..edb70eb38f 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "enquirer": "2.3.6", "eslint": "^8.0.0", "eslint-ava-rule-tester": "^4.0.0", - "eslint-plugin-eslint-plugin": "^4.0.1", + "eslint-plugin-eslint-plugin": "^4.0.2", "eslint-remote-tester": "^2.0.1", "eslint-remote-tester-repositories": "^0.0.3", "execa": "^5.1.1", @@ -134,8 +134,7 @@ ], "eslint-plugin/require-meta-docs-url": "off", "eslint-plugin/require-meta-has-suggestions": "off", - "eslint-plugin/require-meta-schema": "off", - "eslint-plugin/no-deprecated-context-methods": "off" + "eslint-plugin/require-meta-schema": "off" } } ] diff --git a/rules/no-unused-properties.js b/rules/no-unused-properties.js index 732fcb0190..a069d6e8d4 100644 --- a/rules/no-unused-properties.js +++ b/rules/no-unused-properties.js @@ -90,7 +90,7 @@ const create = context => { return property.key.value; } - return context.getSource(property.key); + return context.getSourceCode().getText(property.key); }; const checkProperty = (property, references, path) => { diff --git a/rules/no-useless-undefined.js b/rules/no-useless-undefined.js index 53ff382300..1a3b60e053 100644 --- a/rules/no-useless-undefined.js +++ b/rules/no-useless-undefined.js @@ -172,7 +172,7 @@ const create = context => { start = previousArgument.range[1]; } else { // If all arguments removed, and there is trailing comma, we need remove it. - const tokenAfter = context.getTokenAfter(lastUndefined); + const tokenAfter = sourceCode.getTokenAfter(lastUndefined); if (isCommaToken(tokenAfter)) { end = tokenAfter.range[1]; } diff --git a/rules/prefer-optional-catch-binding.js b/rules/prefer-optional-catch-binding.js index 19a8055b2b..b741ba21e0 100644 --- a/rules/prefer-optional-catch-binding.js +++ b/rules/prefer-optional-catch-binding.js @@ -30,14 +30,15 @@ const create = context => ({ messageId: type === 'Identifier' ? MESSAGE_ID_WITH_NAME : MESSAGE_ID_WITHOUT_NAME, data: {name}, * fix(fixer) { - const tokenBefore = context.getTokenBefore(node); + const sourceCode = context.getSourceCode(); + const tokenBefore = sourceCode.getTokenBefore(node); assertToken(tokenBefore, { test: isOpeningParenToken, expected: '(', ruleId: 'prefer-optional-catch-binding', }); - const tokenAfter = context.getTokenAfter(node); + const tokenAfter = sourceCode.getTokenAfter(node); assertToken(tokenAfter, { test: isClosingParenToken, expected: ')', @@ -50,7 +51,7 @@ const create = context => ({ const [, endOfClosingParenthesis] = tokenAfter.range; const [startOfCatchClauseBody] = parent.body.range; - const text = context.getSourceCode().text.slice(endOfClosingParenthesis, startOfCatchClauseBody); + const text = sourceCode.text.slice(endOfClosingParenthesis, startOfCatchClauseBody); const leadingSpacesLength = text.length - text.trimStart().length; if (leadingSpacesLength !== 0) { yield fixer.removeRange([endOfClosingParenthesis, endOfClosingParenthesis + leadingSpacesLength]);