Skip to content

⬅️ Back to Table of Contents

📄 InvalidTestCase

📊 Analysis Summary

Metric Count
📦 Imports 5
📐 Interfaces 3

📚 Table of Contents

🛠️ File Location:

📂 packages/rule-tester/src/types/InvalidTestCase.ts

📦 Imports

Name Source
AST_NODE_TYPES @typescript-eslint/utils
AST_TOKEN_TYPES @typescript-eslint/utils
ReportDescriptorMessageData @typescript-eslint/utils/ts-eslint
DependencyConstraint ./DependencyConstraint
ValidTestCase ./ValidTestCase

Interfaces

SuggestionOutput<MessageIds extends string>

Interface Code
export interface SuggestionOutput<MessageIds extends string> {
  /**
   * The data used to fill the message template.
   */
  readonly data?: ReportDescriptorMessageData;
  /**
   * Reported message ID.
   */
  readonly messageId: MessageIds;
  /**
   * NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes.
   * Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion.
   */
  readonly output: string;

  // we disallow this because it's much better to use messageIds for reusable errors that are easily testable
  // readonly desc?: string;
}

Properties

Name Type Optional Description
data ReportDescriptorMessageData not shown
messageId MessageIds not shown
output string not shown

TestCaseError<MessageIds extends string>

Interface Code
export interface TestCaseError<MessageIds extends string> {
  /**
   * The 1-based column number of the reported start location.
   */
  readonly column?: number;
  /**
   * The data used to fill the message template.
   */
  readonly data?: ReportDescriptorMessageData;
  /**
   * The 1-based column number of the reported end location.
   */
  readonly endColumn?: number;
  /**
   * The 1-based line number of the reported end location.
   */
  readonly endLine?: number;
  /**
   * The 1-based line number of the reported start location.
   */
  readonly line?: number;
  /**
   * Reported message ID.
   */
  readonly messageId: MessageIds;
  /**
   * Reported suggestions.
   */
  readonly suggestions?: readonly SuggestionOutput<MessageIds>[] | null;
  /**
   * @deprecated `type` is deprecated and will be removed in the next major version.
   */
  readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;

  // we disallow this because it's much better to use messageIds for reusable errors that are easily testable
  // readonly message?: string | RegExp;
}

Properties

Name Type Optional Description
column number not shown
data ReportDescriptorMessageData not shown
endColumn number not shown
endLine number not shown
line number not shown
messageId MessageIds not shown
suggestions readonly SuggestionOutput<MessageIds>[] \| null not shown
type AST_NODE_TYPES \| AST_TOKEN_TYPES not shown

InvalidTestCase<MessageIds extends string, Options extends readonly unknown[]>

Interface Code
export interface InvalidTestCase<
  MessageIds extends string,
  Options extends readonly unknown[],
> extends ValidTestCase<Options> {
  /**
   * Constraints that must pass in the current environment for the test to run
   */
  readonly dependencyConstraints?: DependencyConstraint;
  /**
   * Expected errors.
   */
  readonly errors: readonly TestCaseError<MessageIds>[];
  /**
   * The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested.
   */
  readonly output?: string | string[] | null;
}

Properties

Name Type Optional Description
dependencyConstraints DependencyConstraint not shown
errors readonly TestCaseError<MessageIds>[] not shown
output string \| string[] \| null not shown

Generated by Syntax Scribe