@tsrx/prettier-plugin 0.7.8 → 0.7.10
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/package.json +2 -2
- package/src/parse.js +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/prettier-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "TSRX plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prettier-3-6": "npm:prettier@3.6.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tsrx/core": "0.
|
|
30
|
+
"@tsrx/core": "0.7.0"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/"
|
package/src/parse.js
CHANGED
|
@@ -132,6 +132,18 @@ function isAbstractInBlock(error, text) {
|
|
|
132
132
|
const regex_static_block_modifiers =
|
|
133
133
|
/^(?:(?:abstract|accessor|declare|override|private|protected|public|readonly)(?:\s|\/\*[\s\S]*?\*\/|\/\/.*)+)+static(?:\s|\/\*[\s\S]*?\*\/|\/\/.*)*\{/u;
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Whether `error` is for an `async` constructor (`async constructor() {}`,
|
|
137
|
+
* TS1089), which Prettier's `typescript` parser rejects, where it formats a
|
|
138
|
+
* `static` constructor (`static constructor() {}`, TS1089 too).
|
|
139
|
+
* @param {ParseError} error
|
|
140
|
+
* @returns {boolean}
|
|
141
|
+
*/
|
|
142
|
+
function isAsyncConstructor(error) {
|
|
143
|
+
const { code, message } = TS_ERRORS.MODIFIER_ON_CONSTRUCTOR('async');
|
|
144
|
+
return error.code === code && error.message === message;
|
|
145
|
+
}
|
|
146
|
+
|
|
135
147
|
/**
|
|
136
148
|
* Whether `error` is for decorators on a class `static` block (`@dec static
|
|
137
149
|
* {}`, TS1206), which Prettier's `typescript` parser leaves out, as the plugin
|
|
@@ -157,7 +169,8 @@ function isRejected(error, text) {
|
|
|
157
169
|
(BROKEN_MARKUP_CODES.has(error.code) ||
|
|
158
170
|
(REJECTED_CODES.has(error.code) && !isStaticBlockDecorator(error)) ||
|
|
159
171
|
isModifierBeforeExport(error, text) ||
|
|
160
|
-
isAbstractInBlock(error, text)
|
|
172
|
+
isAbstractInBlock(error, text) ||
|
|
173
|
+
isAsyncConstructor(error))
|
|
161
174
|
);
|
|
162
175
|
}
|
|
163
176
|
|