Repository: eslint/eslint
File: lib/rule-tester/rule-tester.js (JavaScript)

Code before:
    if (!emitDeprecatedContextMethodWarning[`warned-${ruleName}-${methodName}`]) {
        emitDeprecatedContextMethodWarning[`warned-${ruleName}-${methodName}`] = true;
        process.emitWarning(
            `"${ruleName}" rule is using \`context.${methodName}()\`, which is deprecated and will be removed in ESLint v9. Please use \`sourceCode.${DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]}()\` instead.`,
            "DeprecationWarning"
        );
    }
}

/**
 * Emit a deprecation warning if rule uses CodePath#currentSegments.
 * @param {string} ruleName Name of the rule.
 * @returns {void}
 */
function emitCodePathCurrentSegmentsWarning(ruleName) {
    if (!emitCodePathCurrentSegmentsWarning[`warned-${ruleName}`]) {
        emitCodePathCurrentSegmentsWarning[`warned-${ruleName}`] = true;
        process.emitWarning(
            `"${ruleName}" rule uses CodePath#currentSegments and will stop working in ESLint v9. Please read the documentation for how to update your code: https://eslint.org/docs/latest/extend/code-path-analysis#usage-examples`,
            "DeprecationWarning"
        );
    }
}

/**
 * Emit a deprecation warning if `context.parserServices` is used..
 * @param {string} ruleName Name of the rule.
 * @returns {void}
 */
function emitParserServicesWarning(ruleName) {
    if (!emitParserServicesWarning.warned) {
        emitParserServicesWarning.warned = true;
        process.emitWarning(
            `"${ruleName}" rule is using \`context.parserServices\`, which is deprecated and will be removed in ESLint v9. Please use \`sourceCode.parserServices\` instead.`,
            "DeprecationWarning"
        );
    }
}


//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

// default separators for testing
const DESCRIBE = Symbol("describe");
const IT = Symbol("it");
const IT_ONLY = Symbol("itOnly");

/**
 * This is `it` default handler if `it` don't exist.

Review comment (suggestion):
```suggestion
 * Emit a deprecation warning if `context.parserServices` is used.
```

Code after:
    if (!emitDeprecatedContextMethodWarning[`warned-${ruleName}-${methodName}`]) {
        emitDeprecatedContextMethodWarning[`warned-${ruleName}-${methodName}`] = true;
        process.emitWarning(
            `"${ruleName}" rule is using \`context.${methodName}()\`, which is deprecated and will be removed in ESLint v9. Please use \`sourceCode.${DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]}()\` instead.`,
            "DeprecationWarning"
        );
    }
}

/**
 * Emit a deprecation warning if rule uses CodePath#currentSegments.
 * @param {string} ruleName Name of the rule.
 * @returns {void}
 */
function emitCodePathCurrentSegmentsWarning(ruleName) {
    if (!emitCodePathCurrentSegmentsWarning[`warned-${ruleName}`]) {
        emitCodePathCurrentSegmentsWarning[`warned-${ruleName}`] = true;
        process.emitWarning(
            `"${ruleName}" rule uses CodePath#currentSegments and will stop working in ESLint v9. Please read the documentation for how to update your code: https://eslint.org/docs/latest/extend/code-path-analysis#usage-examples`,
            "DeprecationWarning"
        );
    }
}

/**
 * Emit a deprecation warning if `context.parserServices` is used.
 * @param {string} ruleName Name of the rule.
 * @returns {void}
 */
function emitParserServicesWarning(ruleName) {
    if (!emitParserServicesWarning[`warned-${ruleName}`]) {
        emitParserServicesWarning[`warned-${ruleName}`] = true;
        process.emitWarning(
            `"${ruleName}" rule is using \`context.parserServices\`, which is deprecated and will be removed in ESLint v9. Please use \`sourceCode.parserServices\` instead.`,
            "DeprecationWarning"
        );
    }
}


//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

// default separators for testing
const DESCRIBE = Symbol("describe");
const IT = Symbol("it");
const IT_ONLY = Symbol("itOnly");

/**
 * This is `it` default handler if `it` don't exist.