lines.d.ts 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. export declare class Line {
  2. }
  3. export declare class CodeLine extends Line {
  4. contents: string;
  5. constructor(contents: string);
  6. }
  7. export declare class MessageSubstitutionLine extends Line {
  8. key: string;
  9. message: string;
  10. constructor(key: string, message: string);
  11. }
  12. export declare class ErrorLine extends Line {
  13. startCol: number;
  14. constructor(startCol: number);
  15. }
  16. export declare class MultilineErrorLine extends ErrorLine {
  17. constructor(startCol: number);
  18. }
  19. export declare class EndErrorLine extends ErrorLine {
  20. endCol: number;
  21. message: string;
  22. constructor(startCol: number, endCol: number, message: string);
  23. }
  24. export declare const ZERO_LENGTH_ERROR = "~nil";
  25. /**
  26. * Maps a line of text from a .lint file to an appropriate Line object
  27. */
  28. export declare function parseLine(text: string): Line;
  29. /**
  30. * Maps a Line object to a matching line of text that could be in a .lint file.
  31. * This is almost the inverse of parseLine.
  32. * If you ran `printLine(parseLine(someText), code)`, the whitespace in the result may be different than in someText
  33. * @param line - A Line object to convert to text
  34. * @param code - If line represents error markup, this is the line of code preceding the markup.
  35. * Otherwise, this parameter is not required.
  36. */
  37. export declare function printLine(line: Line, code?: string): string | undefined;