css-syntax-error.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import * as postcss from './postcss';
  2. export default class CssSyntaxError implements postcss.CssSyntaxError, SyntaxError {
  3. /**
  4. * Contains full error text in the GNU error format.
  5. */
  6. message: string;
  7. /**
  8. * Contains the source line of the error. PostCSS will use the input
  9. * source map to detect the original error location. If you wrote a
  10. * Sass file, compiled it to CSS and then parsed it with PostCSS,
  11. * PostCSS will show the original position in the Sass file. If you need
  12. * position in PostCSS input (e.g., to debug previous compiler), use
  13. * error.generated.line.
  14. */
  15. line: number;
  16. /**
  17. * Contains the source column of the error. PostCSS will use the input
  18. * source map to detect the original error location. If you wrote a
  19. * Sass file, compiled it to CSS and then parsed it with PostCSS,
  20. * PostCSS will show the original position in the Sass file. If you
  21. * need position in PostCSS input (e.g., to debug previous compiler),
  22. * use error.generated.column.
  23. */
  24. column: number;
  25. /**
  26. * Contains the source code of the broken file. PostCSS will use the
  27. * input source map to detect the original error location. If you wrote
  28. * a Sass file, compiled it to CSS and then parsed it with PostCSS,
  29. * PostCSS will show the original position in the Sass file. If you
  30. * need position in PostCSS input (e.g., to debug previous compiler),
  31. * use error.generated.source.
  32. */
  33. source: string;
  34. /**
  35. * If parser's from option is set, contains the absolute path to the
  36. * broken file. PostCSS will use the input source map to detect the
  37. * original error location. If you wrote a Sass file, compiled it
  38. * to CSS and then parsed it with PostCSS, PostCSS will show the
  39. * original position in the Sass file. If you need the position in
  40. * PostCSS input (e.g., to debug previous compiler), use
  41. * error.generated.file.
  42. */
  43. file: string;
  44. /**
  45. * Contains the PostCSS plugin name if the error didn't come from the
  46. * CSS parser.
  47. */
  48. plugin: string;
  49. name: string;
  50. /**
  51. * Contains only the error description.
  52. */
  53. reason: string;
  54. private columnNumber;
  55. private description;
  56. private lineNumber;
  57. private fileName;
  58. input: postcss.InputOrigin;
  59. /**
  60. * The CSS parser throws this error for broken CSS.
  61. */
  62. constructor(
  63. /**
  64. * Contains full error text in the GNU error format.
  65. */
  66. message: string,
  67. /**
  68. * Contains the source line of the error. PostCSS will use the input
  69. * source map to detect the original error location. If you wrote a
  70. * Sass file, compiled it to CSS and then parsed it with PostCSS,
  71. * PostCSS will show the original position in the Sass file. If you need
  72. * position in PostCSS input (e.g., to debug previous compiler), use
  73. * error.generated.line.
  74. */
  75. line?: number,
  76. /**
  77. * Contains the source column of the error. PostCSS will use the input
  78. * source map to detect the original error location. If you wrote a
  79. * Sass file, compiled it to CSS and then parsed it with PostCSS,
  80. * PostCSS will show the original position in the Sass file. If you
  81. * need position in PostCSS input (e.g., to debug previous compiler),
  82. * use error.generated.column.
  83. */
  84. column?: number,
  85. /**
  86. * Contains the source code of the broken file. PostCSS will use the
  87. * input source map to detect the original error location. If you wrote
  88. * a Sass file, compiled it to CSS and then parsed it with PostCSS,
  89. * PostCSS will show the original position in the Sass file. If you
  90. * need position in PostCSS input (e.g., to debug previous compiler),
  91. * use error.generated.source.
  92. */
  93. source?: string,
  94. /**
  95. * If parser's from option is set, contains the absolute path to the
  96. * broken file. PostCSS will use the input source map to detect the
  97. * original error location. If you wrote a Sass file, compiled it
  98. * to CSS and then parsed it with PostCSS, PostCSS will show the
  99. * original position in the Sass file. If you need the position in
  100. * PostCSS input (e.g., to debug previous compiler), use
  101. * error.generated.file.
  102. */
  103. file?: string,
  104. /**
  105. * Contains the PostCSS plugin name if the error didn't come from the
  106. * CSS parser.
  107. */
  108. plugin?: string);
  109. private setMessage();
  110. /**
  111. * @param color Whether arrow should be colored red by terminal color codes.
  112. * By default, PostCSS will use process.stdout.isTTY and
  113. * process.env.NODE_DISABLE_COLORS.
  114. * @returns A few lines of CSS source that caused the error. If CSS has
  115. * input source map without sourceContent this method will return an empty
  116. * string.
  117. */
  118. showSourceCode(color?: boolean): string;
  119. /**
  120. *
  121. * @returns Error position, message and source code of broken part.
  122. */
  123. toString(): string;
  124. generated: postcss.InputOrigin;
  125. }