@wasm-fmt/web_fmt 0.1.17 → 0.2.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 +53 -30
- package/biome_options.d.ts +41 -0
- package/graphql_options.d.ts +157 -0
- package/json_options.d.ts +6 -0
- package/layout_config.d.ts +16 -0
- package/malva_options.d.ts +101 -0
- package/markup_options.d.ts +134 -0
- package/options.d.ts +26 -0
- package/package.json +29 -6
- package/web_fmt.d.ts +56 -94
- package/web_fmt.js +7 -697
- package/web_fmt_bg.js +610 -0
- package/web_fmt_bg.wasm +0 -0
- package/web_fmt_bg.wasm.d.ts +2 -2
- package/web_fmt_esm.js +27 -0
- package/web_fmt_node.js +17 -6
- package/web_fmt_vite.js +35 -5
- package/web_fmt_web.d.ts +44 -0
- package/web_fmt_web.js +93 -0
- package/jsr.jsonc +0 -34
- package/wasm-fmt-web_fmt-0.1.17.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://github.com/wasm-fmt/web_fmt/actions/workflows/test.yml)
|
|
2
|
+
|
|
1
3
|
# Install
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/@wasm-fmt/web_fmt)
|
|
@@ -22,12 +24,10 @@ npx jsr add @fmt/web-fmt
|
|
|
22
24
|
|
|
23
25
|
# Usage
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## Node.js / Deno / Bun / Bundler
|
|
26
28
|
|
|
27
29
|
```javascript
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
await init();
|
|
30
|
+
import { format } from "@wasm-fmt/web_fmt";
|
|
31
31
|
|
|
32
32
|
// JavaScript/TypeScript
|
|
33
33
|
format(`function foo() {console.log("Hi")}`, "index.js");
|
|
@@ -45,47 +45,70 @@ format(`{"name":"John"}`, "data.json");
|
|
|
45
45
|
format(`query{user{name}}`, "query.graphql");
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Web
|
|
49
|
+
|
|
50
|
+
For web environments, you need to initialize WASM module manually:
|
|
49
51
|
|
|
50
52
|
```javascript
|
|
51
|
-
|
|
52
|
-
// Common layout options
|
|
53
|
-
indentStyle: "space", // "tab" | "space"
|
|
54
|
-
indentWidth: 4, // number
|
|
55
|
-
lineWidth: 100, // number
|
|
56
|
-
lineEnding: "lf", // "lf" | "crlf"
|
|
57
|
-
|
|
58
|
-
// Format-specific options
|
|
59
|
-
script: { quoteStyle: "single", semiColons: "asNeeded" },
|
|
60
|
-
style: { declarationOrder: "alphabetical" },
|
|
61
|
-
markup: { selfClosingSpace: false },
|
|
62
|
-
json: { trailingComma: true },
|
|
63
|
-
};
|
|
53
|
+
import init, { format } from "@wasm-fmt/web_fmt/web";
|
|
64
54
|
|
|
65
|
-
|
|
55
|
+
await init();
|
|
56
|
+
|
|
57
|
+
// Format your code
|
|
58
|
+
const formatted = format(`function foo() {console.log("Hi")}`, "index.js");
|
|
59
|
+
console.log(formatted);
|
|
66
60
|
```
|
|
67
61
|
|
|
68
|
-
|
|
62
|
+
### Vite
|
|
69
63
|
|
|
70
|
-
|
|
64
|
+
```JavaScript
|
|
65
|
+
import init, { format } from "@wasm-fmt/web_fmt/vite";
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"optimizeDeps": {
|
|
75
|
-
"exclude": ["@wasm-fmt/web_fmt"]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
67
|
+
await init();
|
|
68
|
+
// ...
|
|
78
69
|
```
|
|
79
70
|
|
|
80
|
-
|
|
71
|
+
## Entry Points
|
|
72
|
+
|
|
73
|
+
- `.` - Auto-detects environment (Node.js uses node, Webpack uses bundler, default is ESM)
|
|
74
|
+
- `./node` - Node.js environment (no init required)
|
|
75
|
+
- `./esm` - ESM environments like Deno (no init required)
|
|
76
|
+
- `./bundler` - Bundlers like Webpack (no init required)
|
|
77
|
+
- `./web` - Web browsers (requires manual init)
|
|
78
|
+
- `./vite` - Vite bundler (requires manual init)
|
|
79
|
+
|
|
80
|
+
## With Configuration
|
|
81
81
|
|
|
82
82
|
```javascript
|
|
83
|
-
|
|
83
|
+
const config = {
|
|
84
|
+
// Common layout options
|
|
85
|
+
indentStyle: "space", // "tab" | "space"
|
|
86
|
+
indentWidth: 4, // number
|
|
87
|
+
lineWidth: 100, // number
|
|
88
|
+
lineEnding: "lf", // "lf" | "crlf"
|
|
89
|
+
|
|
90
|
+
// Format-specific options
|
|
91
|
+
script: { quoteStyle: "single", semiColons: "asNeeded" },
|
|
92
|
+
style: { declarationOrder: "alphabetical" },
|
|
93
|
+
markup: { selfClosingSpace: false },
|
|
94
|
+
json: { trailingComma: true },
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
format(code, filename, config);
|
|
84
98
|
```
|
|
85
99
|
|
|
86
|
-
|
|
100
|
+
# Configuration
|
|
87
101
|
|
|
88
102
|
- [Biome](https://biomejs.dev/reference/configuration/#formatter) (Script)
|
|
89
103
|
- [Malva](https://github.com/g-plane/malva/blob/main/docs/config.md) (Style)
|
|
90
104
|
- [markup_fmt](https://github.com/g-plane/markup_fmt) (Markup)
|
|
91
105
|
- [pretty-graphql](https://pretty-graphql.netlify.app/) (GraphQL)
|
|
106
|
+
|
|
107
|
+
# Credits
|
|
108
|
+
|
|
109
|
+
Thanks to:
|
|
110
|
+
|
|
111
|
+
- The [Biome](https://github.com/biomejs/biome) project
|
|
112
|
+
- The [malva](https://github.com/g-plane/malva) project
|
|
113
|
+
- The [markup_fmt](https://github.com/g-plane/markup_fmt) project
|
|
114
|
+
- The [pretty_graphql](https://github.com/g-plane/pretty_graphql) project
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { LayoutConfig } from "./layout_config.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for Biome formatter.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://biomejs.dev/reference/configuration/#formatter}
|
|
7
|
+
*/
|
|
8
|
+
export interface Config extends LayoutConfig {
|
|
9
|
+
/** The style for quotes. Defaults to "double". */
|
|
10
|
+
quoteStyle?: "double" | "single";
|
|
11
|
+
|
|
12
|
+
/** The style for JSX quotes. Defaults to "double". */
|
|
13
|
+
jsxQuoteStyle?: "double" | "single";
|
|
14
|
+
|
|
15
|
+
/** When properties in objects are quoted. Defaults to "as-needed". */
|
|
16
|
+
quoteProperties?: "preserve" | "as-needed";
|
|
17
|
+
|
|
18
|
+
/** Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to "all". */
|
|
19
|
+
trailingComma?: "es5" | "all" | "none";
|
|
20
|
+
|
|
21
|
+
/** Whether the formatter prints semicolons for all statements, class members, and type members or only when necessary because of ASI. Defaults to "always". */
|
|
22
|
+
semicolons?: "always" | "as-needed";
|
|
23
|
+
|
|
24
|
+
/** Whether to add non-necessary parentheses to arrow functions. Defaults to "always". */
|
|
25
|
+
arrowParentheses?: "always" | "as-needed";
|
|
26
|
+
|
|
27
|
+
/** Whether to insert spaces around brackets in object literals. Defaults to true. */
|
|
28
|
+
bracketSpacing?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Whether to hug the closing bracket of multiline HTML/JSX tags to the end of the last line, rather than being alone on the following line. Defaults to false. */
|
|
31
|
+
bracketSameLine?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Attribute position style. By default "auto". */
|
|
34
|
+
attributePosition?: "auto" | "multiline";
|
|
35
|
+
|
|
36
|
+
/** Whether to expand object and array literals to multiple lines. Defaults to "auto". */
|
|
37
|
+
expand?: "always" | "never" | "auto";
|
|
38
|
+
|
|
39
|
+
/** When formatting binary expressions, whether to break the line before or after the operator. Defaults to "after". */
|
|
40
|
+
operatorLinebreak?: "before" | "after";
|
|
41
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { LayoutConfig } from "./layout_config.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for GraphQL formatter.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://pretty-graphql.netlify.app/}
|
|
7
|
+
*/
|
|
8
|
+
export interface Config extends LayoutConfig {
|
|
9
|
+
/** Print width for formatting. Defaults to 80. */
|
|
10
|
+
printWidth?: number;
|
|
11
|
+
|
|
12
|
+
/** Use tabs for indentation. Defaults to false. */
|
|
13
|
+
useTabs?: boolean;
|
|
14
|
+
|
|
15
|
+
/** Number of spaces per indentation level. Defaults to 2. */
|
|
16
|
+
indentWidth?: number;
|
|
17
|
+
|
|
18
|
+
/** Line break style. Defaults to "lf". */
|
|
19
|
+
lineBreak?: "lf" | "crlf";
|
|
20
|
+
|
|
21
|
+
/** Comma style. Defaults to "onlySingleLine". */
|
|
22
|
+
comma?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
23
|
+
|
|
24
|
+
/** Comma style for arguments. Defaults to "inherit". */
|
|
25
|
+
"arguments.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
26
|
+
|
|
27
|
+
/** Comma style for arguments definition. Defaults to "inherit". */
|
|
28
|
+
"argumentsDefinition.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
29
|
+
|
|
30
|
+
/** Comma style for directives. Defaults to "never". */
|
|
31
|
+
"directives.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
32
|
+
|
|
33
|
+
/** Comma style for enum values definition. Defaults to "never". */
|
|
34
|
+
"enumValuesDefinition.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
35
|
+
|
|
36
|
+
/** Comma style for fields definition. Defaults to "never". */
|
|
37
|
+
"fieldsDefinition.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
38
|
+
|
|
39
|
+
/** Comma style for input fields definition. Defaults to "never". */
|
|
40
|
+
"inputFieldsDefinition.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
41
|
+
|
|
42
|
+
/** Comma style for list values. Defaults to "inherit". */
|
|
43
|
+
"listValue.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
44
|
+
|
|
45
|
+
/** Comma style for object values. Defaults to "inherit". */
|
|
46
|
+
"objectValue.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
47
|
+
|
|
48
|
+
/** Comma style for schema definition. Defaults to "never". */
|
|
49
|
+
"schemaDefinition.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
50
|
+
|
|
51
|
+
/** Comma style for schema extension. Defaults to "never". */
|
|
52
|
+
"schemaExtension.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
53
|
+
|
|
54
|
+
/** Comma style for selection sets. Defaults to "never". */
|
|
55
|
+
"selectionSet.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
56
|
+
|
|
57
|
+
/** Comma style for variable definitions. Defaults to "inherit". */
|
|
58
|
+
"variableDefinitions.comma"?: "always" | "never" | "noTrailing" | "onlySingleLine" | "inherit";
|
|
59
|
+
|
|
60
|
+
/** Single line style. Defaults to "smart". */
|
|
61
|
+
singleLine?: "prefer" | "smart" | "never" | "inherit";
|
|
62
|
+
|
|
63
|
+
/** Single line style for arguments. Defaults to "inherit". */
|
|
64
|
+
"arguments.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
65
|
+
|
|
66
|
+
/** Single line style for arguments definition. Defaults to "inherit". */
|
|
67
|
+
"argumentsDefinition.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
68
|
+
|
|
69
|
+
/** Single line style for directive locations. Defaults to "inherit". */
|
|
70
|
+
"directiveLocations.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
71
|
+
|
|
72
|
+
/** Single line style for directives. Defaults to "inherit". */
|
|
73
|
+
"directives.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
74
|
+
|
|
75
|
+
/** Single line style for enum values definition. Defaults to "never". */
|
|
76
|
+
"enumValuesDefinition.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
77
|
+
|
|
78
|
+
/** Single line style for fields definition. Defaults to "never". */
|
|
79
|
+
"fieldsDefinition.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
80
|
+
|
|
81
|
+
/** Single line style for implements interfaces. Defaults to "inherit". */
|
|
82
|
+
"implementsInterfaces.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
83
|
+
|
|
84
|
+
/** Single line style for input fields definition. Defaults to "never". */
|
|
85
|
+
"inputFieldsDefinition.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
86
|
+
|
|
87
|
+
/** Single line style for list values. Defaults to "inherit". */
|
|
88
|
+
"listValue.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
89
|
+
|
|
90
|
+
/** Single line style for object values. Defaults to "inherit". */
|
|
91
|
+
"objectValue.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
92
|
+
|
|
93
|
+
/** Single line style for schema definition. Defaults to "never". */
|
|
94
|
+
"schemaDefinition.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
95
|
+
|
|
96
|
+
/** Single line style for schema extension. Defaults to "never". */
|
|
97
|
+
"schemaExtension.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
98
|
+
|
|
99
|
+
/** Single line style for selection sets. Defaults to "never". */
|
|
100
|
+
"selectionSet.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
101
|
+
|
|
102
|
+
/** Single line style for union member types. Defaults to "inherit". */
|
|
103
|
+
"unionMemberTypes.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
104
|
+
|
|
105
|
+
/** Single line style for variable definitions. Defaults to "inherit". */
|
|
106
|
+
"variableDefinitions.singleLine"?: "prefer" | "smart" | "never" | "inherit";
|
|
107
|
+
|
|
108
|
+
/** Whether to add spaces around parentheses. Defaults to false. */
|
|
109
|
+
parenSpacing?: boolean;
|
|
110
|
+
|
|
111
|
+
/** Whether to add spaces around parentheses in arguments. */
|
|
112
|
+
"arguments.parenSpacing"?: boolean;
|
|
113
|
+
|
|
114
|
+
/** Whether to add spaces around parentheses in arguments definition. */
|
|
115
|
+
"argumentsDefinition.parenSpacing"?: boolean;
|
|
116
|
+
|
|
117
|
+
/** Whether to add spaces around parentheses in variable definitions. */
|
|
118
|
+
"variableDefinitions.parenSpacing"?: boolean;
|
|
119
|
+
|
|
120
|
+
/** Whether to add spaces around brackets. Defaults to false. */
|
|
121
|
+
bracketSpacing?: boolean;
|
|
122
|
+
|
|
123
|
+
/** Whether to add spaces around braces. Defaults to true. */
|
|
124
|
+
braceSpacing?: boolean;
|
|
125
|
+
|
|
126
|
+
/** Whether to add spaces around braces in enum values definition. */
|
|
127
|
+
"enumValuesDefinition.braceSpacing"?: boolean;
|
|
128
|
+
|
|
129
|
+
/** Whether to add spaces around braces in fields definition. */
|
|
130
|
+
"fieldsDefinition.braceSpacing"?: boolean;
|
|
131
|
+
|
|
132
|
+
/** Whether to add spaces around braces in input fields definition. */
|
|
133
|
+
"inputFieldsDefinition.braceSpacing"?: boolean;
|
|
134
|
+
|
|
135
|
+
/** Whether to add spaces around braces in object values. */
|
|
136
|
+
"objectValue.braceSpacing"?: boolean;
|
|
137
|
+
|
|
138
|
+
/** Whether to add spaces around braces in schema definition. */
|
|
139
|
+
"schemaDefinition.braceSpacing"?: boolean;
|
|
140
|
+
|
|
141
|
+
/** Whether to add spaces around braces in schema extension. */
|
|
142
|
+
"schemaExtension.braceSpacing"?: boolean;
|
|
143
|
+
|
|
144
|
+
/** Whether to add spaces around braces in selection sets. */
|
|
145
|
+
"selectionSet.braceSpacing"?: boolean;
|
|
146
|
+
|
|
147
|
+
/** Whether to format comments. Defaults to false. */
|
|
148
|
+
formatComments?: boolean;
|
|
149
|
+
|
|
150
|
+
/** Directive to ignore comments. Defaults to "pretty-graphql-ignore". */
|
|
151
|
+
ignoreCommentDirective?: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
*@see {@link https://pretty-graphql.netlify.app/}
|
|
155
|
+
*/
|
|
156
|
+
[key: string]: any;
|
|
157
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout configuration options shared across all formatters.
|
|
3
|
+
*/
|
|
4
|
+
export interface LayoutConfig {
|
|
5
|
+
/** Indentation style. Defaults to "space". */
|
|
6
|
+
indentStyle?: "tab" | "space";
|
|
7
|
+
|
|
8
|
+
/** Number of spaces per indentation level. Defaults to 2. */
|
|
9
|
+
indentWidth?: number;
|
|
10
|
+
|
|
11
|
+
/** Maximum line width before wrapping. Defaults to 80. */
|
|
12
|
+
lineWidth?: number;
|
|
13
|
+
|
|
14
|
+
/** Line ending style. Defaults to "lf". */
|
|
15
|
+
lineEnding?: "lf" | "crlf";
|
|
16
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { LayoutConfig } from "./layout_config.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for CSS/SCSS/SASS/LESS formatter (malva).
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://github.com/g-plane/malva/blob/main/docs/config.md}
|
|
7
|
+
*/
|
|
8
|
+
export interface Config extends LayoutConfig {
|
|
9
|
+
/** Case style for hex colors. Defaults to "lower". */
|
|
10
|
+
hexCase?: "ignore" | "lower" | "upper";
|
|
11
|
+
|
|
12
|
+
/** Length style for hex colors. */
|
|
13
|
+
hexColorLength?: "short" | "long";
|
|
14
|
+
|
|
15
|
+
/** Quote style for strings. Defaults to "preferDouble". */
|
|
16
|
+
quotes?: "alwaysDouble" | "alwaysSingle" | "preferDouble" | "preferSingle";
|
|
17
|
+
|
|
18
|
+
/** Quote style for attribute selectors. Defaults to inherit from quotes. */
|
|
19
|
+
"attrSelector.quotes"?: "alwaysDouble" | "alwaysSingle" | "preferDouble" | "preferSingle";
|
|
20
|
+
|
|
21
|
+
/** Operator line break position. Defaults to "after". */
|
|
22
|
+
operatorLinebreak?: "before" | "after";
|
|
23
|
+
|
|
24
|
+
/** Block selector line break style. Defaults to "consistent". */
|
|
25
|
+
blockSelectorLinebreak?: "always" | "consistent" | "wrap";
|
|
26
|
+
|
|
27
|
+
/** Whether to omit leading zero in numbers. Defaults to false. */
|
|
28
|
+
omitNumberLeadingZero?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Whether to add trailing commas. Defaults to false. */
|
|
31
|
+
trailingComma?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Whether to format comments. Defaults to false. */
|
|
34
|
+
formatComments?: boolean;
|
|
35
|
+
|
|
36
|
+
/** Whether to align comments. Defaults to true. */
|
|
37
|
+
alignComments?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Whether to add line breaks in pseudo parentheses. Defaults to false. */
|
|
40
|
+
linebreakInPseudoParens?: boolean;
|
|
41
|
+
|
|
42
|
+
/** Declaration order style. */
|
|
43
|
+
declarationOrder?: "alphabetical" | "smacss" | "concentric";
|
|
44
|
+
|
|
45
|
+
/** How to group declarations when ordering. Defaults to "nonDeclaration". */
|
|
46
|
+
declarationOrderGroupBy?: "nonDeclaration" | "nonDeclarationAndEmptyLine";
|
|
47
|
+
|
|
48
|
+
/** Threshold for single line blocks. */
|
|
49
|
+
singleLineBlockThreshold?: number;
|
|
50
|
+
|
|
51
|
+
/** Notation for keyframe selectors. */
|
|
52
|
+
keyframeSelectorNotation?: "keyword" | "percentage";
|
|
53
|
+
|
|
54
|
+
/** Quote style for attribute values. Defaults to "always". */
|
|
55
|
+
attrValueQuotes?: "always" | "ignore";
|
|
56
|
+
|
|
57
|
+
/** Whether to prefer single line. Defaults to false. */
|
|
58
|
+
preferSingleLine?: boolean;
|
|
59
|
+
|
|
60
|
+
/** Whether to prefer single line for selectors. Defaults to inherit from preferSingleLine. */
|
|
61
|
+
"selectors.preferSingleLine"?: boolean;
|
|
62
|
+
|
|
63
|
+
/** Whether to prefer single line for function arguments. Defaults to inherit from preferSingleLine. */
|
|
64
|
+
"functionArgs.preferSingleLine"?: boolean;
|
|
65
|
+
|
|
66
|
+
/** Whether to prefer single line for SASS content at-rule. Defaults to inherit from preferSingleLine. */
|
|
67
|
+
"sassContentAtRule.preferSingleLine"?: boolean;
|
|
68
|
+
|
|
69
|
+
/** Whether to prefer single line for SASS include at-rule. Defaults to inherit from preferSingleLine. */
|
|
70
|
+
"sassIncludeAtRule.preferSingleLine"?: boolean;
|
|
71
|
+
|
|
72
|
+
/** Whether to prefer single line for SASS maps. Defaults to inherit from preferSingleLine. */
|
|
73
|
+
"sassMap.preferSingleLine"?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Whether to prefer single line for SASS module config. Defaults to inherit from preferSingleLine. */
|
|
76
|
+
"sassModuleConfig.preferSingleLine"?: boolean;
|
|
77
|
+
|
|
78
|
+
/** Whether to prefer single line for SASS params. Defaults to inherit from preferSingleLine. */
|
|
79
|
+
"sassParams.preferSingleLine"?: boolean;
|
|
80
|
+
|
|
81
|
+
/** Whether to prefer single line for LESS import options. Defaults to inherit from preferSingleLine. */
|
|
82
|
+
"lessImportOptions.preferSingleLine"?: boolean;
|
|
83
|
+
|
|
84
|
+
/** Whether to prefer single line for LESS mixin args. Defaults to inherit from preferSingleLine. */
|
|
85
|
+
"lessMixinArgs.preferSingleLine"?: boolean;
|
|
86
|
+
|
|
87
|
+
/** Whether to prefer single line for LESS mixin params. Defaults to inherit from preferSingleLine. */
|
|
88
|
+
"lessMixinParams.preferSingleLine"?: boolean;
|
|
89
|
+
|
|
90
|
+
/** Whether to format single-line top-level declarations on one line. Defaults to false. */
|
|
91
|
+
singleLineTopLevelDeclarations?: boolean;
|
|
92
|
+
|
|
93
|
+
/** Directive for selector override comments. Defaults to "malva-selector-override". */
|
|
94
|
+
selectorOverrideCommentDirective?: string;
|
|
95
|
+
|
|
96
|
+
/** Directive to ignore formatting for a section. Defaults to "malva-ignore". */
|
|
97
|
+
ignoreCommentDirective?: string;
|
|
98
|
+
|
|
99
|
+
/** Directive to ignore formatting for entire file. Defaults to "malva-ignore-file". */
|
|
100
|
+
ignoreFileCommentDirective?: string;
|
|
101
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { LayoutConfig } from "./layout_config.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for Markup formatter (HTML/Vue/Svelte/Astro).
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://github.com/g-plane/markup_fmt/blob/main/docs/config.md}
|
|
7
|
+
*/
|
|
8
|
+
export interface Config extends LayoutConfig {
|
|
9
|
+
/** Whether to use single quotes for attribute values. Defaults to "double". */
|
|
10
|
+
quotes?: "double" | "single";
|
|
11
|
+
|
|
12
|
+
/** Whether to format comments. Defaults to false. */
|
|
13
|
+
formatComments?: boolean;
|
|
14
|
+
|
|
15
|
+
/** Whether to indent script content. Defaults to false. */
|
|
16
|
+
scriptIndent?: boolean;
|
|
17
|
+
|
|
18
|
+
/** Whether to indent script content in HTML. Defaults to inherit from scriptIndent. */
|
|
19
|
+
"html.scriptIndent"?: boolean;
|
|
20
|
+
|
|
21
|
+
/** Whether to indent script content in Vue. Defaults to inherit from scriptIndent. */
|
|
22
|
+
"vue.scriptIndent"?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Whether to indent script content in Svelte. Defaults to inherit from scriptIndent. */
|
|
25
|
+
"svelte.scriptIndent"?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Whether to indent script content in Astro. Defaults to inherit from scriptIndent. */
|
|
28
|
+
"astro.scriptIndent"?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Whether to indent style content. Defaults to false. */
|
|
31
|
+
styleIndent?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Whether to indent style content in HTML. Defaults to inherit from styleIndent. */
|
|
34
|
+
"html.styleIndent"?: boolean;
|
|
35
|
+
|
|
36
|
+
/** Whether to indent style content in Vue. Defaults to inherit from styleIndent. */
|
|
37
|
+
"vue.styleIndent"?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Whether to indent style content in Svelte. Defaults to inherit from styleIndent. */
|
|
40
|
+
"svelte.styleIndent"?: boolean;
|
|
41
|
+
|
|
42
|
+
/** Whether to indent style content in Astro. Defaults to inherit from styleIndent. */
|
|
43
|
+
"astro.styleIndent"?: boolean;
|
|
44
|
+
|
|
45
|
+
/** Whether to place closing bracket on the same line. Defaults to false. */
|
|
46
|
+
closingBracketSameLine?: boolean;
|
|
47
|
+
|
|
48
|
+
/** Line break behavior for empty closing tags. Defaults to "fit". */
|
|
49
|
+
closingTagLineBreakForEmpty?: "always" | "fit" | "never";
|
|
50
|
+
|
|
51
|
+
/** Maximum number of attributes per line. Defaults to null (no limit). */
|
|
52
|
+
maxAttrsPerLine?: number;
|
|
53
|
+
|
|
54
|
+
/** Whether to prefer placing all attributes on a single line. Defaults to false. */
|
|
55
|
+
preferAttrsSingleLine?: boolean;
|
|
56
|
+
|
|
57
|
+
/** Whether to place a single attribute on the same line as the tag. Defaults to true. */
|
|
58
|
+
singleAttrSameLine?: boolean;
|
|
59
|
+
|
|
60
|
+
/** Whether normal HTML elements should be self-closing. */
|
|
61
|
+
"html.normal.selfClosing"?: boolean;
|
|
62
|
+
|
|
63
|
+
/** Whether void HTML elements should be self-closing. */
|
|
64
|
+
"html.void.selfClosing"?: boolean;
|
|
65
|
+
|
|
66
|
+
/** Whether components should be self-closing. */
|
|
67
|
+
"component.selfClosing"?: boolean;
|
|
68
|
+
|
|
69
|
+
/** Whether SVG elements should be self-closing. */
|
|
70
|
+
"svg.selfClosing"?: boolean;
|
|
71
|
+
|
|
72
|
+
/** Whether MathML elements should be self-closing. */
|
|
73
|
+
"mathml.selfClosing"?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Whitespace sensitivity mode. Defaults to "css". */
|
|
76
|
+
whitespaceSensitivity?: "css" | "strict" | "ignore";
|
|
77
|
+
|
|
78
|
+
/** Whitespace sensitivity mode for components. Defaults to inherit from whitespaceSensitivity. */
|
|
79
|
+
"component.whitespaceSensitivity"?: "css" | "strict" | "ignore";
|
|
80
|
+
|
|
81
|
+
/** Case style for DOCTYPE keyword. Defaults to "upper". */
|
|
82
|
+
doctypeKeywordCase?: "ignore" | "upper" | "lower";
|
|
83
|
+
|
|
84
|
+
/** Style for v-bind directive in Vue. */
|
|
85
|
+
vBindStyle?: "short" | "long";
|
|
86
|
+
|
|
87
|
+
/** Style for v-on directive in Vue. */
|
|
88
|
+
vOnStyle?: "short" | "long";
|
|
89
|
+
|
|
90
|
+
/** Delimiter style for v-for directive in Vue. */
|
|
91
|
+
vForDelimiterStyle?: "in" | "of";
|
|
92
|
+
|
|
93
|
+
/** Style for v-slot directive in Vue. */
|
|
94
|
+
vSlotStyle?: "short" | "long" | "vSlot";
|
|
95
|
+
|
|
96
|
+
/** Style for v-slot in components. Defaults to inherit from vSlotStyle. */
|
|
97
|
+
"component.vSlotStyle"?: "short" | "long" | "vSlot";
|
|
98
|
+
|
|
99
|
+
/** Style for default v-slot. Defaults to inherit from vSlotStyle. */
|
|
100
|
+
"default.vSlotStyle"?: "short" | "long" | "vSlot";
|
|
101
|
+
|
|
102
|
+
/** Style for named v-slot. Defaults to inherit from vSlotStyle. */
|
|
103
|
+
"named.vSlotStyle"?: "short" | "long" | "vSlot";
|
|
104
|
+
|
|
105
|
+
/** Whether to use shorthand for v-bind with same name in Vue. */
|
|
106
|
+
vBindSameNameShortHand?: boolean;
|
|
107
|
+
|
|
108
|
+
/** Component naming case style in Vue. Defaults to "ignore". */
|
|
109
|
+
vueComponentCase?: "ignore" | "pascalCase" | "kebabCase";
|
|
110
|
+
|
|
111
|
+
/** Whether to use strict attribute checking in Svelte. Defaults to false. */
|
|
112
|
+
strictSvelteAttr?: boolean;
|
|
113
|
+
|
|
114
|
+
/** Whether to use attribute shorthand in Svelte. */
|
|
115
|
+
svelteAttrShorthand?: boolean;
|
|
116
|
+
|
|
117
|
+
/** Whether to use directive shorthand in Svelte. */
|
|
118
|
+
svelteDirectiveShorthand?: boolean;
|
|
119
|
+
|
|
120
|
+
/** Whether to use attribute shorthand in Astro. */
|
|
121
|
+
astroAttrShorthand?: boolean;
|
|
122
|
+
|
|
123
|
+
/** Whether to place Angular control flow on same line. Defaults to true. */
|
|
124
|
+
angularNextControlFlowSameLine?: boolean;
|
|
125
|
+
|
|
126
|
+
/** Script formatter to use. */
|
|
127
|
+
scriptFormatter?: "dprint" | "biome";
|
|
128
|
+
|
|
129
|
+
/** Directive to ignore formatting for a section. Defaults to "markup-fmt-ignore". */
|
|
130
|
+
ignoreCommentDirective?: string;
|
|
131
|
+
|
|
132
|
+
/** Directive to ignore formatting for entire file. Defaults to "markup-fmt-ignore-file". */
|
|
133
|
+
ignoreFileCommentDirective?: string;
|
|
134
|
+
}
|
package/options.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LayoutConfig } from "./layout_config.d.ts";
|
|
2
|
+
import type { Config as MarkupConfig } from "./markup_options.d.ts";
|
|
3
|
+
import type { Config as ScriptConfig } from "./biome_options.d.ts";
|
|
4
|
+
import type { Config as StyleConfig } from "./malva_options.d.ts";
|
|
5
|
+
import type { Config as JsonConfig } from "./json_options.d.ts";
|
|
6
|
+
import type { Config as GraphqlConfig } from "./graphql_options.d.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Main configuration interface for Web formatter.
|
|
10
|
+
*/
|
|
11
|
+
export interface Config extends LayoutConfig {
|
|
12
|
+
/** Markup (HTML/Vue/Svelte/Astro) formatter configuration. */
|
|
13
|
+
markup?: MarkupConfig;
|
|
14
|
+
|
|
15
|
+
/** Script (JavaScript/TypeScript) formatter configuration. */
|
|
16
|
+
script?: ScriptConfig;
|
|
17
|
+
|
|
18
|
+
/** Style (CSS/SCSS/SASS/LESS) formatter configuration. */
|
|
19
|
+
style?: StyleConfig;
|
|
20
|
+
|
|
21
|
+
/** JSON formatter configuration (uses LayoutConfig only). */
|
|
22
|
+
json?: JsonConfig;
|
|
23
|
+
|
|
24
|
+
/** GraphQL formatter configuration. */
|
|
25
|
+
graphql?: GraphqlConfig;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
"collaborators": [
|
|
5
5
|
"magic-akari <akari.ccino@gmail.com>"
|
|
6
6
|
],
|
|
7
|
-
"description": "
|
|
8
|
-
"version": "0.1
|
|
7
|
+
"description": "A formatter for web development powered by WASM",
|
|
8
|
+
"version": "0.2.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/wasm-fmt/web_fmt"
|
|
12
|
+
"url": "git+https://github.com/wasm-fmt/web_fmt.git"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/wasm-fmt/web_fmt",
|
|
14
|
+
"homepage": "https://github.com/wasm-fmt/web_fmt/tree/main/crates/web_fmt",
|
|
15
15
|
"types": "web_fmt.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"web_fmt*",
|
|
18
|
+
"*.d.ts"
|
|
19
|
+
],
|
|
16
20
|
"sideEffects": [
|
|
17
|
-
"./
|
|
21
|
+
"./web_fmt.js",
|
|
22
|
+
"./web_fmt_node.js",
|
|
23
|
+
"./web_fmt_esm.js"
|
|
18
24
|
],
|
|
19
25
|
"keywords": [
|
|
20
26
|
"wasm",
|
|
@@ -29,14 +35,31 @@
|
|
|
29
35
|
"exports": {
|
|
30
36
|
".": {
|
|
31
37
|
"types": "./web_fmt.d.ts",
|
|
38
|
+
"webpack": "./web_fmt.js",
|
|
39
|
+
"deno": "./web_fmt.js",
|
|
40
|
+
"bun": "./web_fmt_node.js",
|
|
41
|
+
"module-sync": "./web_fmt_node.js",
|
|
32
42
|
"node": "./web_fmt_node.js",
|
|
43
|
+
"default": "./web_fmt_esm.js"
|
|
44
|
+
},
|
|
45
|
+
"./esm": {
|
|
46
|
+
"types": "./web_fmt.d.ts",
|
|
47
|
+
"default": "./web_fmt_esm.js"
|
|
48
|
+
},
|
|
49
|
+
"./node": {
|
|
50
|
+
"types": "./web_fmt.d.ts",
|
|
51
|
+
"default": "./web_fmt_node.js"
|
|
52
|
+
},
|
|
53
|
+
"./bundler": {
|
|
54
|
+
"types": "./web_fmt.d.ts",
|
|
33
55
|
"default": "./web_fmt.js"
|
|
34
56
|
},
|
|
35
57
|
"./vite": {
|
|
36
58
|
"types": "./web_fmt.d.ts",
|
|
37
59
|
"default": "./web_fmt_vite.js"
|
|
38
60
|
},
|
|
61
|
+
"./wasm": "./web_fmt_bg.wasm",
|
|
39
62
|
"./package.json": "./package.json",
|
|
40
63
|
"./*": "./*"
|
|
41
64
|
}
|
|
42
|
-
}
|
|
65
|
+
}
|