Repeated string literal (ARCH3207)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key typescript.quality.repeated-string-literal · Severity info · Category quality
Flags a string literal of five or more characters used four or more times in one class, or in a module outside its classes. A value repeated by hand is changed in three places out of four one day. Types, module specifiers, object keys and values (configuration: Intl options, state machines, table rows), JSX attribute values, typeof tags, translation keys, case labels, decorator arguments, log calls, a const’s own value and test code are not counted.
Incorrect
Section titled “Incorrect”if (status === "awaiting-payment") notify();return status === "awaiting-payment" ? "awaiting-payment" : next;filters.push("awaiting-payment");Correct
Section titled “Correct”export const AWAITING_PAYMENT = "awaiting-payment";
if (status === AWAITING_PAYMENT) notify();filters.push(AWAITING_PAYMENT);