diff --git a/lib/rules/assert-args.js b/lib/rules/assert-args.js index eebfc950..b49faa9b 100644 --- a/lib/rules/assert-args.js +++ b/lib/rules/assert-args.js @@ -37,7 +37,8 @@ module.exports = { create: function (context) { /** @type {Array<{assertContextVar: string | null}>} */ const testStack = [], - sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + sourceCode = context.sourceCode ?? context.getSourceCode(); /** * @param {import('estree').Node} argNode diff --git a/lib/rules/literal-compare-order.js b/lib/rules/literal-compare-order.js index 9ff764b8..15884917 100644 --- a/lib/rules/literal-compare-order.js +++ b/lib/rules/literal-compare-order.js @@ -38,7 +38,8 @@ module.exports = { create: function (context) { /** @type {Array<{assertContextVar: string | null}>} */ const testStack = [], - sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + sourceCode = context.sourceCode ?? context.getSourceCode(); function getAssertContext() { assert.ok(testStack.length); diff --git a/lib/rules/no-arrow-tests.js b/lib/rules/no-arrow-tests.js index 6e7fa5e0..af3d665d 100644 --- a/lib/rules/no-arrow-tests.js +++ b/lib/rules/no-arrow-tests.js @@ -40,7 +40,8 @@ module.exports = { //-------------------------------------------------------------------------- // Fixer adapted from https://github.com/lo1tuma/eslint-plugin-mocha (MIT) - const sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = context.sourceCode ?? context.getSourceCode(); /** * @param {number} start diff --git a/lib/rules/no-assert-equal-boolean.js b/lib/rules/no-assert-equal-boolean.js index fe1278b4..1e8e856f 100644 --- a/lib/rules/no-assert-equal-boolean.js +++ b/lib/rules/no-assert-equal-boolean.js @@ -117,7 +117,9 @@ module.exports = { ? "true" : "false"; - const sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = + context.sourceCode ?? context.getSourceCode(); if (node.type !== "CallExpression") { return null; } diff --git a/lib/rules/no-commented-tests.js b/lib/rules/no-commented-tests.js index 9b395aa1..5d39ed62 100644 --- a/lib/rules/no-commented-tests.js +++ b/lib/rules/no-commented-tests.js @@ -25,7 +25,8 @@ module.exports = { }, create: function (context) { - const sourceCode = context.getSourceCode(), + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = context.sourceCode ?? context.getSourceCode(), newlineRegExp = /\r\n|\r|\n/g, warningRegExp = /\b(QUnit\.test|QUnit\.asyncTest|QUnit\.skip|test|asyncTest)\s*\(\s*["'`]/g; diff --git a/lib/rules/no-compare-relation-boolean.js b/lib/rules/no-compare-relation-boolean.js index 575b8f59..7e5faf30 100644 --- a/lib/rules/no-compare-relation-boolean.js +++ b/lib/rules/no-compare-relation-boolean.js @@ -102,7 +102,9 @@ module.exports = { node: callExprNode, messageId: "redundantComparison", fix(fixer) { - const sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = + context.sourceCode ?? context.getSourceCode(); /* istanbul ignore next */ if (callExprNode.type !== "CallExpression") { return null; diff --git a/lib/rules/no-hooks-from-ancestor-modules.js b/lib/rules/no-hooks-from-ancestor-modules.js index dec3d175..face228a 100644 --- a/lib/rules/no-hooks-from-ancestor-modules.js +++ b/lib/rules/no-hooks-from-ancestor-modules.js @@ -125,7 +125,10 @@ module.exports = { const description = arg.type === "Literal" && typeof arg.value === "string" ? arg.value - : context.getSourceCode().getText(arg); + : /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + ( + context.sourceCode ?? context.getSourceCode() + ).getText(arg); /** @type {{callExpression: import('eslint').Rule.Node, description: string, hookIdentifierName?: string | null}} */ const moduleStackInfo = { diff --git a/lib/rules/no-negated-ok.js b/lib/rules/no-negated-ok.js index 2073ce1b..abaf7b82 100644 --- a/lib/rules/no-negated-ok.js +++ b/lib/rules/no-negated-ok.js @@ -46,7 +46,8 @@ module.exports = { ...POSITIVE_ASSERTIONS, ...NEGATIVE_ASSERTIONS, ]), - sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + sourceCode = context.sourceCode ?? context.getSourceCode(); function getAssertVar() { let result = null; diff --git a/lib/rules/no-ok-equality.js b/lib/rules/no-ok-equality.js index fe63d762..2f1bfdb0 100644 --- a/lib/rules/no-ok-equality.js +++ b/lib/rules/no-ok-equality.js @@ -50,7 +50,8 @@ module.exports = { allowGlobal: true, }, options = context.options[0] || DEFAULT_OPTIONS, - sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + sourceCode = context.sourceCode ?? context.getSourceCode(); const POSITIVE_ASSERTIONS = new Set(["ok", "true"]); const NEGATIVE_ASSERTIONS = new Set(["notOk", "false"]); diff --git a/lib/rules/no-test-expect-argument.js b/lib/rules/no-test-expect-argument.js index 801f94ae..b38a1af1 100644 --- a/lib/rules/no-test-expect-argument.js +++ b/lib/rules/no-test-expect-argument.js @@ -30,7 +30,8 @@ module.exports = { }, create: function (context) { - const sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = context.sourceCode ?? context.getSourceCode(); return { CallExpression: function (node) { diff --git a/lib/rules/no-throws-string.js b/lib/rules/no-throws-string.js index 52db9e28..2f55f990 100644 --- a/lib/rules/no-throws-string.js +++ b/lib/rules/no-throws-string.js @@ -70,7 +70,8 @@ module.exports = { create: function (context) { /** @type {Array<{assertVar: string | null}>} */ const testStack = [], - sourceCode = context.getSourceCode(); + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + sourceCode = context.sourceCode ?? context.getSourceCode(); /** * @param {import('eslint').Rule.Node} callExprNode diff --git a/lib/rules/require-object-in-propequal.js b/lib/rules/require-object-in-propequal.js index 46786469..f476e472 100644 --- a/lib/rules/require-object-in-propequal.js +++ b/lib/rules/require-object-in-propequal.js @@ -34,7 +34,8 @@ module.exports = { create: function (context) { // Declare a test stack in case of nested test cases (not currently supported by QUnit). - const sourceCode = context.getSourceCode(), + /* istanbul ignore next: deprecated code paths only followed by old eslint versions */ + const sourceCode = context.sourceCode ?? context.getSourceCode(), /** @type {Array<{assertVar: string | null}>} */ testStack = [];