@timbic/prettier-config 1.0.11 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -53
- package/dist/index.d.ts +205 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,53 +1,79 @@
|
|
|
1
|
-
# @timbic/prettier-config
|
|
2
|
-
|
|
3
|
-
Extensible prettier configuration for the smart developers.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm add -D prettier @timbic/prettier-config
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
import withTimbic from "@timbic/prettier-config";
|
|
13
|
-
|
|
14
|
-
export default withTimbic();
|
|
15
|
-
|
|
16
|
-
// or
|
|
17
|
-
|
|
18
|
-
export default withTimbic({
|
|
19
|
-
// your options
|
|
20
|
-
});
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Your options will override the defaults and extend the config.
|
|
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
|
-
```
|
|
1
|
+
# @timbic/prettier-config
|
|
2
|
+
|
|
3
|
+
Extensible prettier configuration for the smart developers.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D prettier @timbic/prettier-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import withTimbic from "@timbic/prettier-config";
|
|
13
|
+
|
|
14
|
+
export default withTimbic();
|
|
15
|
+
|
|
16
|
+
// or
|
|
17
|
+
|
|
18
|
+
export default withTimbic({
|
|
19
|
+
// your options
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Your options will override the defaults and extend the config.
|
|
24
|
+
|
|
25
|
+
## Types
|
|
26
|
+
|
|
27
|
+
Now this package has its own types! That means that when using withTimbic() you will get enhanced type annotations by Quick Info on each
|
|
28
|
+
rule, as well as the right default set by withTimbic(), e.g.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// before
|
|
32
|
+
export default withTimbic({
|
|
33
|
+
tabWidth: 3,
|
|
34
|
+
// Specify the number of spaces per indentation-level.
|
|
35
|
+
// @default
|
|
36
|
+
//
|
|
37
|
+
// 2 (incorrect, this is not a withTimbic() default, this is prettier default)
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// after
|
|
41
|
+
export default withTimbic({
|
|
42
|
+
tabWidth: 3,
|
|
43
|
+
// Specify the number of spaces per indentation-level.
|
|
44
|
+
// @default
|
|
45
|
+
//
|
|
46
|
+
// 4 (correct, see our default options below)
|
|
47
|
+
// @see — https://prettier.io/docs/options#tab-width
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Default options
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
{
|
|
55
|
+
arrowParens: "always",
|
|
56
|
+
bracketSameLine: false,
|
|
57
|
+
bracketSpacing: true,
|
|
58
|
+
checkIgnorePragma: false,
|
|
59
|
+
embeddedLanguageFormatting: "auto",
|
|
60
|
+
endOfLine: "lf",
|
|
61
|
+
htmlWhitespaceSensitivity: "css",
|
|
62
|
+
insertPragma: false,
|
|
63
|
+
jsxSingleQuote: false,
|
|
64
|
+
objectWrap: "preserve",
|
|
65
|
+
printWidth: 140,
|
|
66
|
+
proseWrap: "always",
|
|
67
|
+
quoteProps: "consistent",
|
|
68
|
+
rangeEnd: Infinity,
|
|
69
|
+
rangeStart: 0,
|
|
70
|
+
requirePragma: false,
|
|
71
|
+
semi: true,
|
|
72
|
+
singleAttributePerLine: true,
|
|
73
|
+
singleQuote: false,
|
|
74
|
+
tabWidth: 4,
|
|
75
|
+
trailingComma: "all",
|
|
76
|
+
useTabs: true,
|
|
77
|
+
vueIndentScriptAndStyle: false,
|
|
78
|
+
}
|
|
79
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,231 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/
|
|
3
|
-
|
|
1
|
+
import { BuiltInParserName, LiteralUnion, Plugin } from "prettier";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* For use in `.prettierrc.js`, `.prettierrc.ts`, `.prettierrc.cjs`, `.prettierrc.cts`, `prettierrc.mjs`, `prettierrc.mts`, `prettier.config.js`, `prettier.config.ts`, `prettier.config.cjs`, `prettier.config.cts`, `prettier.config.mjs`, `prettier.config.mts`
|
|
5
|
+
*/
|
|
6
|
+
interface Config extends Partial<Options> {
|
|
4
7
|
overrides?: Array<{
|
|
5
8
|
files: string | string[];
|
|
6
9
|
excludeFiles?: string | string[];
|
|
7
|
-
options?:
|
|
10
|
+
options?: Options;
|
|
8
11
|
}>;
|
|
12
|
+
}
|
|
13
|
+
interface Options {
|
|
14
|
+
/**
|
|
15
|
+
* Specify the line length that the printer will wrap on.
|
|
16
|
+
* @default 140
|
|
17
|
+
*
|
|
18
|
+
* @see https://prettier.io/docs/options#print-width
|
|
19
|
+
*/
|
|
20
|
+
printWidth: number;
|
|
21
|
+
/**
|
|
22
|
+
* Specify the number of spaces per indentation-level.
|
|
23
|
+
* @default 4
|
|
24
|
+
*
|
|
25
|
+
* @see https://prettier.io/docs/options#tab-width
|
|
26
|
+
*/
|
|
27
|
+
tabWidth: number;
|
|
28
|
+
/**
|
|
29
|
+
* Indent lines with tabs instead of spaces.
|
|
30
|
+
* @default true
|
|
31
|
+
*
|
|
32
|
+
* @see https://prettier.io/docs/options#tabs
|
|
33
|
+
*/
|
|
34
|
+
useTabs: boolean;
|
|
35
|
+
parentParser?: string;
|
|
36
|
+
__embeddedInHtml?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Print semicolons at the ends of statements.
|
|
39
|
+
* @default true
|
|
40
|
+
*
|
|
41
|
+
* @see https://prettier.io/docs/options#semicolons
|
|
42
|
+
*/
|
|
9
43
|
semi: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Use single quotes instead of double quotes.
|
|
46
|
+
* @default false
|
|
47
|
+
*
|
|
48
|
+
* @see https://prettier.io/docs/options#quotes
|
|
49
|
+
*/
|
|
10
50
|
singleQuote: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Use single quotes in JSX.
|
|
53
|
+
* @default false
|
|
54
|
+
*
|
|
55
|
+
* @see https://prettier.io/docs/options#quotes
|
|
56
|
+
*/
|
|
11
57
|
jsxSingleQuote: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Print trailing commas wherever possible.
|
|
60
|
+
* @default "all"
|
|
61
|
+
*
|
|
62
|
+
* @see https://prettier.io/docs/options#trailing-commas
|
|
63
|
+
*/
|
|
12
64
|
trailingComma: "none" | "es5" | "all";
|
|
65
|
+
/**
|
|
66
|
+
* Print spaces between brackets in object literals.
|
|
67
|
+
* @default true
|
|
68
|
+
*
|
|
69
|
+
* @see https://prettier.io/docs/options#bracket-spacing
|
|
70
|
+
*/
|
|
13
71
|
bracketSpacing: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* How to wrap object literals.
|
|
74
|
+
* @default "preserve"
|
|
75
|
+
*
|
|
76
|
+
* @see https://prettier.io/docs/options#object-wrap
|
|
77
|
+
*/
|
|
14
78
|
objectWrap: "preserve" | "collapse";
|
|
79
|
+
/**
|
|
80
|
+
* Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
|
|
81
|
+
* alone on the next line (does not apply to self closing elements).
|
|
82
|
+
* @default false
|
|
83
|
+
*
|
|
84
|
+
* @see https://prettier.io/docs/options#bracket-same-line
|
|
85
|
+
*/
|
|
15
86
|
bracketSameLine: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Format only a segment of a file.
|
|
89
|
+
* @default 0
|
|
90
|
+
*
|
|
91
|
+
* @see https://prettier.io/docs/options#range-start
|
|
92
|
+
*/
|
|
16
93
|
rangeStart: number;
|
|
94
|
+
/**
|
|
95
|
+
* Format only a segment of a file.
|
|
96
|
+
* @default Infinity
|
|
97
|
+
*
|
|
98
|
+
* @see https://prettier.io/docs/options#range-end
|
|
99
|
+
*/
|
|
17
100
|
rangeEnd: number;
|
|
18
|
-
|
|
19
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Specify which parser to use.
|
|
103
|
+
*
|
|
104
|
+
* @see https://prettier.io/docs/options#parser
|
|
105
|
+
*/
|
|
106
|
+
parser: LiteralUnion<BuiltInParserName>;
|
|
107
|
+
/**
|
|
108
|
+
* Specify the input filepath. This will be used to do parser inference.
|
|
109
|
+
*
|
|
110
|
+
* @see https://prettier.io/docs/options#file-path
|
|
111
|
+
*/
|
|
112
|
+
filepath: string;
|
|
113
|
+
/**
|
|
114
|
+
* Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the
|
|
115
|
+
* file. This is very useful when gradually transitioning large, unformatted codebases to prettier.
|
|
116
|
+
* @default false
|
|
117
|
+
*
|
|
118
|
+
* @see https://prettier.io/docs/options#require-pragma
|
|
119
|
+
*/
|
|
20
120
|
requirePragma: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with
|
|
123
|
+
* prettier. This works well when used in tandem with the --require-pragma option. If there is already a docblock at
|
|
124
|
+
* the top of the file then this option will add a newline to it with the @format marker.
|
|
125
|
+
* @default false
|
|
126
|
+
*
|
|
127
|
+
* @see https://prettier.io/docs/options#insert-pragma
|
|
128
|
+
*/
|
|
21
129
|
insertPragma: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Prettier can allow individual files to opt out of formatting if they contain a special comment, called a pragma, at
|
|
132
|
+
* the top of the file.
|
|
133
|
+
* @default false
|
|
134
|
+
*
|
|
135
|
+
* @see https://prettier.io/docs/options#check-ignore-pragma
|
|
136
|
+
*/
|
|
22
137
|
checkIgnorePragma: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer. In some
|
|
140
|
+
* cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
|
|
141
|
+
* @default "always"
|
|
142
|
+
*
|
|
143
|
+
* @see https://prettier.io/docs/options#prose-wrap
|
|
144
|
+
*/
|
|
23
145
|
proseWrap: "always" | "never" | "preserve";
|
|
146
|
+
/**
|
|
147
|
+
* Include parentheses around a sole arrow function parameter.
|
|
148
|
+
* @default "always"
|
|
149
|
+
*
|
|
150
|
+
* @see https://prettier.io/docs/options#arrow-parens
|
|
151
|
+
*/
|
|
24
152
|
arrowParens: "avoid" | "always";
|
|
25
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Provide ability to support new languages to prettier.
|
|
155
|
+
*
|
|
156
|
+
* @see https://prettier.io/docs/plugins
|
|
157
|
+
*/
|
|
158
|
+
plugins: Array<string | URL | Plugin>;
|
|
159
|
+
/**
|
|
160
|
+
* How to handle whitespaces in HTML.
|
|
161
|
+
* @default "css"
|
|
162
|
+
*
|
|
163
|
+
* @see https://prettier.io/docs/options#html-whitespace-sensitivity
|
|
164
|
+
*/
|
|
26
165
|
htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
|
|
166
|
+
/**
|
|
167
|
+
* Which end of line characters to apply.
|
|
168
|
+
* @default "lf"
|
|
169
|
+
*
|
|
170
|
+
* @see https://prettier.io/docs/options#end-of-line
|
|
171
|
+
*/
|
|
27
172
|
endOfLine: "auto" | "lf" | "crlf" | "cr";
|
|
173
|
+
/**
|
|
174
|
+
* Change when properties in objects are quoted.
|
|
175
|
+
*
|
|
176
|
+
* @see https://prettier.io/docs/options#quote-props
|
|
177
|
+
* @default "consistent"
|
|
178
|
+
*/
|
|
28
179
|
quoteProps: "as-needed" | "consistent" | "preserve";
|
|
180
|
+
/**
|
|
181
|
+
* Whether or not to indent the code inside <script> and <style> tags in Vue files.
|
|
182
|
+
* @default false
|
|
183
|
+
*
|
|
184
|
+
* @see https://prettier.io/docs/options#vue-indent-script-and-style
|
|
185
|
+
*/
|
|
29
186
|
vueIndentScriptAndStyle: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Control whether Prettier formats quoted code embedded in the file.
|
|
189
|
+
* @default "auto"
|
|
190
|
+
*
|
|
191
|
+
* @see https://prettier.io/docs/options#embedded-language-formatting
|
|
192
|
+
*/
|
|
30
193
|
embeddedLanguageFormatting: "auto" | "off";
|
|
194
|
+
/**
|
|
195
|
+
* Enforce single attribute per line in HTML, Vue and JSX.
|
|
196
|
+
* @default true
|
|
197
|
+
*
|
|
198
|
+
* @see https://prettier.io/docs/options#single-attribute-per-line
|
|
199
|
+
*/
|
|
31
200
|
singleAttributePerLine: boolean;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Where to print operators when binary expressions wrap lines.
|
|
203
|
+
* @default "end"
|
|
204
|
+
*
|
|
205
|
+
* @see https://prettier.io/docs/options#experimental-operator-position
|
|
206
|
+
*/
|
|
207
|
+
experimentalOperatorPosition: "start" | "end";
|
|
208
|
+
/**
|
|
209
|
+
* Use curious ternaries, with the question mark after the condition, instead of on the same line as the consequent.
|
|
210
|
+
* @default false
|
|
211
|
+
*
|
|
212
|
+
* @see https://prettier.io/docs/options#experimental-ternaries
|
|
213
|
+
*/
|
|
214
|
+
experimentalTernaries: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
|
|
217
|
+
* @default false
|
|
218
|
+
*
|
|
219
|
+
* @deprecated use bracketSameLine instead
|
|
220
|
+
*/
|
|
221
|
+
jsxBracketSameLine: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Arbitrary additional values on an options object are always allowed.
|
|
224
|
+
*/
|
|
225
|
+
[_: string]: unknown;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/index.d.ts
|
|
229
|
+
declare function withTimbic(options?: Config): Config;
|
|
41
230
|
//#endregion
|
|
42
231
|
export { withTimbic as default };
|