Skip to content

⬅️ Back to Table of Contents

📄 deprecation-warnings

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 1
📊 Variables & Constants 2

📚 Table of Contents

🛠️ File Location:

📂 packages/rule-tester/src/utils/deprecation-warnings.ts

📦 Imports

Name Source
path node:path

Variables & Constants

Name Type Kind Value Exported
deprecationWarningMessages { readonly ESLINT_LEGACY_ECMAFEATURES... const { ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is dep...
sourceFileErrorCache Set<string> const new Set<string>()

Functions

emitDeprecationWarning(source: string, errorCode: keyof typeof deprecationWarningMessages): void

Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted for each unique file path, but repeated invocations with the same file path have no effect. No warnings are emitted if the --no-deprecation or --no-warnings Node runtime flags are active.

Parameters:

  • source any: The name of the configuration source to report the warning for.
  • errorCode any: The warning message to show.
Raw JSDoc
/**
 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
 * for each unique file path, but repeated invocations with the same file path have no effect.
 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
 * @param source The name of the configuration source to report the warning for.
 * @param errorCode The warning message to show.
 */

Calls:

  • JSON.stringify
  • sourceFileErrorCache.has
  • sourceFileErrorCache.add
  • path.relative
  • process.cwd
  • process.emitWarning
Code
export function emitDeprecationWarning(
  source: string,
  errorCode: keyof typeof deprecationWarningMessages,
): void {
  const cacheKey = JSON.stringify({ errorCode, source });

  if (sourceFileErrorCache.has(cacheKey)) {
    return;
  }

  sourceFileErrorCache.add(cacheKey);

  const rel = path.relative(process.cwd(), source);
  const message = deprecationWarningMessages[errorCode];

  process.emitWarning(
    `${message} (found in "${rel}")`,
    'DeprecationWarning',
    errorCode,
  );
}

Generated by Syntax Scribe