forked from sql-formatter-org/sql-formatter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatOptions.ts
More file actions
81 lines (75 loc) · 2.18 KB
/
FormatOptions.ts
File metadata and controls
81 lines (75 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// import only type to avoid ESLint no-cycle rule producing an error
import { ParamItems } from './formatter/Params.js';
import { ParamTypes } from './lexer/TokenizerOptions.js';
export type IndentStyle = 'standard' | 'tabularLeft' | 'tabularRight';
export type KeywordCase = 'preserve' | 'upper' | 'lower';
export type IdentifierCase = KeywordCase;
export type DataTypeCase = KeywordCase;
export type FunctionCase = KeywordCase;
export type LogicalOperatorNewline = 'before' | 'after';
export interface FormatOptions {
/**
* Number of spaces per indentation level. Defaults to `2`
*/
tabWidth: number;
/**
* Use tabs for indentation instead of spaces. Defaults to `false`
*/
useTabs: boolean;
/**
* Transform case of keywords. Defaults to `"preserve"`
*/
keywordCase: KeywordCase;
/**
* Transform case of identifiers. Defaults to `"preserve"`
*/
identifierCase: IdentifierCase;
/**
* Transform case of data types. Defaults to `"preserve"`
*/
dataTypeCase: DataTypeCase;
/**
* Transform case of function names. Defaults to `"preserve"`
*/
functionCase: FunctionCase;
/**
* Indentation style. Defaults to `"standard"`
*/
indentStyle: IndentStyle;
/**
* Position of logical operators in multiline conditions. Defaults to `"before"`
*/
logicalOperatorNewline: LogicalOperatorNewline;
/**
* Maximum length of expressions before breaking into multiple lines. Defaults to `50`
*/
expressionWidth: number;
/**
* Number of blank lines between queries. Defaults to `1`
*/
linesBetweenQueries: number;
/**
* Remove spaces around operators. Defaults to `false`
*/
denseOperators: boolean;
/**
* Place semicolon on new line. Defaults to `false`
*/
newlineBeforeSemicolon: boolean;
params?: ParamItems | string[];
paramTypes?: ParamTypes;
}
export const defaultFormatOptions: FormatOptions = {
tabWidth: 2,
useTabs: false,
keywordCase: 'preserve',
identifierCase: 'preserve',
dataTypeCase: 'preserve',
functionCase: 'preserve',
indentStyle: 'standard',
logicalOperatorNewline: 'before',
expressionWidth: 50,
linesBetweenQueries: 1,
denseOperators: false,
newlineBeforeSemicolon: false,
};