worsier 2.2.0 → 2.4.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 +9 -8
- package/configuration_schema.json +63 -0
- package/dist/binding.js +2 -1
- package/dist/types.d.ts +8 -0
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# Worsier
|
|
2
2
|
|
|
3
3
|
A focused JavaScript, TypeScript, JSX, and TSX formatter powered by Rust. It formats static imports,
|
|
4
|
-
|
|
5
|
-
text outside the enabled rules.
|
|
4
|
+
TypeScript interface layout, statement and member semicolons, trailing commas, and the boundaries
|
|
5
|
+
around runtime variable declarations while preserving source text outside the enabled rules.
|
|
6
6
|
Node.js 24.0.0 or newer is required.
|
|
7
|
-
Prebuilt Windows x64 binaries are temporarily unavailable while
|
|
8
|
-
[npm package publication is restored](https://github.com/Perdolique/worsier/issues/11).
|
|
9
7
|
|
|
10
8
|
```sh
|
|
11
9
|
pnpm add -D worsier
|
|
@@ -16,6 +14,11 @@ pnpm exec worsier --write .
|
|
|
16
14
|
The CLI uses its opinionated defaults without a configuration file. An optional `worsier.jsonc`
|
|
17
15
|
can override them; run `pnpm exec worsier --init` to create the complete typed configuration.
|
|
18
16
|
|
|
17
|
+
By default, every nonempty TypeScript interface is expanded with one member per line. Set
|
|
18
|
+
`rules.interfaceLayout` to a member threshold from `0` through `4294967295`, or to `"off"` to
|
|
19
|
+
preserve interface layout. Members on the physical line governed by a preceding `// @ts-ignore`
|
|
20
|
+
or `// @ts-expect-error` stay together so formatting does not change TypeScript diagnostics.
|
|
21
|
+
|
|
19
22
|
```js
|
|
20
23
|
import { format } from 'worsier'
|
|
21
24
|
|
|
@@ -30,7 +33,5 @@ programmatic API does not discover configuration files.
|
|
|
30
33
|
[Prettier](https://prettier.io/docs/) is a mature opinionated formatter that prints the complete
|
|
31
34
|
source, while [Oxfmt](https://oxc.rs/docs/guide/usage/formatter.html) is a fast,
|
|
32
35
|
Prettier-compatible formatter with broader language and formatting coverage. Both provide selected
|
|
33
|
-
configuration options, including
|
|
34
|
-
|
|
35
|
-
trailing-comma modes. Worsier instead focuses on independently configurable source-rewrite rules
|
|
36
|
-
and preserves text outside the selected rules.
|
|
36
|
+
configuration options, including semicolon and trailing-comma modes. Worsier instead focuses on
|
|
37
|
+
independently configurable source-rewrite rules and preserves text outside the selected rules.
|
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
"$ref": "#/$defs/RulesConfig",
|
|
27
27
|
"default": {
|
|
28
28
|
"importLayout": true,
|
|
29
|
+
"interfaceLayout": 0,
|
|
30
|
+
"semicolons": {
|
|
31
|
+
"classMembers": "asNeeded",
|
|
32
|
+
"statements": "asNeeded",
|
|
33
|
+
"typeMembers": "asNeeded"
|
|
34
|
+
},
|
|
29
35
|
"statementSpacing": {
|
|
30
36
|
"imports": "separate",
|
|
31
37
|
"variableDeclarations": "separate"
|
|
@@ -40,6 +46,25 @@
|
|
|
40
46
|
},
|
|
41
47
|
"additionalProperties": false,
|
|
42
48
|
"$defs": {
|
|
49
|
+
"InterfaceLayoutMode": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"enum": [
|
|
52
|
+
"off"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"InterfaceLayoutRule": {
|
|
56
|
+
"anyOf": [
|
|
57
|
+
{
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"format": "uint32",
|
|
60
|
+
"maximum": 4294967295,
|
|
61
|
+
"minimum": 0
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"$ref": "#/$defs/InterfaceLayoutMode"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
43
68
|
"RulesConfig": {
|
|
44
69
|
"type": "object",
|
|
45
70
|
"properties": {
|
|
@@ -47,6 +72,18 @@
|
|
|
47
72
|
"type": "boolean",
|
|
48
73
|
"default": true
|
|
49
74
|
},
|
|
75
|
+
"interfaceLayout": {
|
|
76
|
+
"$ref": "#/$defs/InterfaceLayoutRule",
|
|
77
|
+
"default": 0
|
|
78
|
+
},
|
|
79
|
+
"semicolons": {
|
|
80
|
+
"$ref": "#/$defs/SemicolonConfig",
|
|
81
|
+
"default": {
|
|
82
|
+
"classMembers": "asNeeded",
|
|
83
|
+
"statements": "asNeeded",
|
|
84
|
+
"typeMembers": "asNeeded"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
50
87
|
"statementSpacing": {
|
|
51
88
|
"$ref": "#/$defs/StatementSpacingConfig",
|
|
52
89
|
"default": {
|
|
@@ -61,6 +98,32 @@
|
|
|
61
98
|
},
|
|
62
99
|
"additionalProperties": false
|
|
63
100
|
},
|
|
101
|
+
"SemicolonConfig": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"properties": {
|
|
104
|
+
"classMembers": {
|
|
105
|
+
"$ref": "#/$defs/SemicolonMode",
|
|
106
|
+
"default": "asNeeded"
|
|
107
|
+
},
|
|
108
|
+
"statements": {
|
|
109
|
+
"$ref": "#/$defs/SemicolonMode",
|
|
110
|
+
"default": "asNeeded"
|
|
111
|
+
},
|
|
112
|
+
"typeMembers": {
|
|
113
|
+
"$ref": "#/$defs/SemicolonMode",
|
|
114
|
+
"default": "asNeeded"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"additionalProperties": false
|
|
118
|
+
},
|
|
119
|
+
"SemicolonMode": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"enum": [
|
|
122
|
+
"always",
|
|
123
|
+
"asNeeded",
|
|
124
|
+
"off"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
64
127
|
"StatementSpacingConfig": {
|
|
65
128
|
"type": "object",
|
|
66
129
|
"properties": {
|
package/dist/binding.js
CHANGED
|
@@ -7,7 +7,8 @@ const platformPackages = {
|
|
|
7
7
|
'linux-arm64-musl': 'worsier-linux-arm64-musl',
|
|
8
8
|
'linux-x64-gnu': 'worsier-linux-x64-gnu',
|
|
9
9
|
'linux-x64-musl': 'worsier-linux-x64-musl',
|
|
10
|
-
'win32-arm64-msvc': 'worsier-win32-arm64-msvc'
|
|
10
|
+
'win32-arm64-msvc': 'worsier-win32-arm64-msvc',
|
|
11
|
+
'win32-x64-msvc': 'worsier-win32-x64-msvc'
|
|
11
12
|
};
|
|
12
13
|
let binding;
|
|
13
14
|
function libc() {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type InterfaceLayoutMode = 'off';
|
|
1
2
|
export interface FormatConfig {
|
|
2
3
|
$schema?: string | null;
|
|
3
4
|
ignorePatterns?: string[];
|
|
@@ -7,9 +8,16 @@ export interface FormatConfig {
|
|
|
7
8
|
}
|
|
8
9
|
export interface RulesConfig {
|
|
9
10
|
importLayout?: boolean;
|
|
11
|
+
interfaceLayout?: number | InterfaceLayoutMode;
|
|
12
|
+
semicolons?: SemicolonConfig;
|
|
10
13
|
statementSpacing?: StatementSpacingConfig;
|
|
11
14
|
trailingCommas?: 'always' | 'never' | 'off';
|
|
12
15
|
}
|
|
16
|
+
export interface SemicolonConfig {
|
|
17
|
+
classMembers?: 'always' | 'asNeeded' | 'off';
|
|
18
|
+
statements?: 'always' | 'asNeeded' | 'off';
|
|
19
|
+
typeMembers?: 'always' | 'asNeeded' | 'off';
|
|
20
|
+
}
|
|
13
21
|
export interface StatementSpacingConfig {
|
|
14
22
|
imports?: 'separate' | 'compact' | 'off';
|
|
15
23
|
variableDeclarations?: 'separate' | 'compact' | 'off';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worsier",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "A focused JavaScript and TypeScript import, trailing-comma, and statement-boundary formatter powered by Rust",
|
|
3
|
+
"version": "2.4.1",
|
|
4
|
+
"description": "A focused JavaScript and TypeScript import, interface-layout, semicolon, trailing-comma, and statement-boundary formatter powered by Rust",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -43,18 +43,20 @@
|
|
|
43
43
|
"aarch64-unknown-linux-gnu",
|
|
44
44
|
"aarch64-unknown-linux-musl",
|
|
45
45
|
"x86_64-apple-darwin",
|
|
46
|
+
"x86_64-pc-windows-msvc",
|
|
46
47
|
"x86_64-unknown-linux-gnu",
|
|
47
48
|
"x86_64-unknown-linux-musl"
|
|
48
49
|
]
|
|
49
50
|
},
|
|
50
51
|
"optionalDependencies": {
|
|
51
|
-
"worsier-darwin-arm64": "2.
|
|
52
|
-
"worsier-win32-arm64-msvc": "2.
|
|
53
|
-
"worsier-linux-arm64-gnu": "2.
|
|
54
|
-
"worsier-linux-arm64-musl": "2.
|
|
55
|
-
"worsier-darwin-x64": "2.
|
|
56
|
-
"worsier-
|
|
57
|
-
"worsier-linux-x64-
|
|
52
|
+
"worsier-darwin-arm64": "2.4.1",
|
|
53
|
+
"worsier-win32-arm64-msvc": "2.4.1",
|
|
54
|
+
"worsier-linux-arm64-gnu": "2.4.1",
|
|
55
|
+
"worsier-linux-arm64-musl": "2.4.1",
|
|
56
|
+
"worsier-darwin-x64": "2.4.1",
|
|
57
|
+
"worsier-win32-x64-msvc": "2.4.1",
|
|
58
|
+
"worsier-linux-x64-gnu": "2.4.1",
|
|
59
|
+
"worsier-linux-x64-musl": "2.4.1"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
62
|
"@types/node": "26.2.0",
|