UNPKG

2.84 kBTypeScriptView Raw
1import { SassFormatterConfig } from './config';
2interface FormatContext {
3 isFirstLine: boolean;
4 isLastLine: boolean;
5 isInBlockComment: boolean;
6 wasLastHeaderIncludeMixin: boolean;
7 wasLastHeaderNestedProp: boolean;
8 blockCommentDistance: number;
9 /**
10 * The Formatter ignores whitespace until the next selector.
11 */
12 allowSpace: boolean;
13 /**
14 * The Formatter Skips one line.
15 */
16 ignoreLine: boolean;
17 /**
18 * true if the last line was a selector.
19 */
20 wasLastLineSelector: boolean;
21 convert: {
22 lastSelector: string;
23 wasLastLineCss: boolean;
24 };
25 keyframes: {
26 /**true if in @keyframes body. */
27 isIn: boolean;
28 /** the indentation level of the keyframes declaration. */
29 indentation: number;
30 };
31 if: {
32 /**true if in @if body. */
33 isIn: boolean;
34 /** the indentation level of the @if declaration. */
35 indentation: number;
36 };
37 /**
38 * Indentation level of the last selector
39 */
40 lastSelectorIndentation: number;
41 /**
42 * if `.class` is at line 0 and has an indentation level of 0,
43 * then this property should be set to the current `tabSize`.
44 *
45 * so that the properties get the correct indentation level.
46 */
47 indentation: number;
48 /**
49 * used if there is there are multiple selectors, example line 0 has
50 * `.class1,` and line 1 has `#someId` this stores the distance of the first selector (`.class1` in this example)
51 * so that the indentation of the following selectors gets set to the indentation of the first selector.
52 */
53 firstCommaHeader: {
54 /**
55 * distance of the first selector.
56 */
57 distance: number;
58 /**
59 * true previous selector ends with a comma
60 */ exists: boolean;
61 };
62}
63/**
64 * This is the context for each line.
65 */
66export interface StateLocalContext {
67 isReset: boolean;
68 isAnd: boolean;
69 isProp: boolean;
70 indentation: {
71 offset: number;
72 distance: number;
73 };
74 isAtExtend: boolean;
75 isClassOrIdSelector: boolean;
76 isHtmlTag: boolean;
77 isIf: boolean;
78 isElse: boolean;
79 isAtKeyframes: boolean;
80 isAtKeyframesPoint: boolean;
81 isAdjacentSelector: boolean;
82 isInterpolatedProp: boolean;
83 isInclude: boolean;
84 isVariable: boolean;
85 isImport: boolean;
86 isNestPropHead: boolean;
87}
88export declare class FormattingState {
89 lines: string[];
90 /** Current line index. */
91 currentLine: number;
92 LINE_ENDING: '\n' | '\r\n';
93 /** Formatting Result */
94 RESULT: string;
95 /** Context For Each Line. */
96 LOCAL_CONTEXT: StateLocalContext;
97 CONTEXT: FormatContext;
98 CONFIG: SassFormatterConfig;
99 setLocalContext(context: StateLocalContext): void;
100}
101export {};