File tree Expand file tree Collapse file tree 5 files changed +14
-12
lines changed Expand file tree Collapse file tree 5 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -196,11 +196,12 @@ function parseStyle(value, tagName) {
196196 try {
197197 styleToObject ( value , iterator )
198198 } catch ( error ) {
199- // To do: use `cause`.
200- const exception = /** @type {Error } */ ( error )
201- exception . message =
202- tagName + '[style]' + exception . message . slice ( 'undefined' . length )
203- throw error
199+ const cause = /** @type {Error } */ ( error )
200+ const exception = new Error (
201+ 'Could not parse `style` attribute on `' + tagName + '`' ,
202+ { cause}
203+ )
204+ throw exception
204205 }
205206
206207 return result
Original file line number Diff line number Diff line change 9999 * Casing to use for property names in `style` objects.
100100 */
101101
102+ import { ok as assert } from 'devlop'
102103import { html , svg } from 'property-information'
103104import { position } from 'unist-util-position'
104105import { zwitch } from 'zwitch'
@@ -185,8 +186,8 @@ function invalid(value) {
185186 * Nothing (crashes).
186187 */
187188function unknown ( node ) {
188- // To do: use `devlop`.
189- // @ts -expect-error: JS guarantees there’s a `type`.
189+ assert ( node && typeof node === 'object' )
190+ assert ( 'type' in node )
190191 throw new Error ( 'Cannot handle unknown node `' + node . type + '`' )
191192}
192193
@@ -331,9 +332,8 @@ function createJsxNameFromString(name) {
331332 if ( name . includes ( '.' ) ) {
332333 const names = name . split ( '.' )
333334 let part = names . shift ( )
334- // To do: use `devlop`.
335- /** @type {JsxMemberExpression } */
336- // @ts -expect-error: hush, the first is always defined.
335+ assert ( part , 'Expected `part` to be defined' )
336+ /** @type {JsxIdentifier | JsxMemberExpression } */
337337 let node = { type : 'JSXIdentifier' , name : part }
338338
339339 while ( ( part = names . shift ( ) ) ) {
Original file line number Diff line number Diff line change 4444 "@types/estree-jsx" : " ^1.0.0" ,
4545 "@types/hast" : " ^3.0.0" ,
4646 "comma-separated-tokens" : " ^2.0.0" ,
47+ "devlop" : " ^1.0.0" ,
4748 "estree-util-attach-comments" : " ^3.0.0" ,
4849 "estree-util-is-identifier-name" : " ^3.0.0" ,
4950 "hast-util-whitespace" : " ^3.0.0" ,
Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ test('toEstree', async function (t) {
362362 await t . test ( 'should crash on an incorrect style string' , async function ( ) {
363363 assert . throws ( function ( ) {
364364 toEstree ( h ( 'a' , { style : 'x' } ) )
365- } , / a \[ s t y l e ] : 1 : 2 : p r o p e r t y m i s s i n g ' : ' / )
365+ } , / C o u l d n o t p a r s e ` s t y l e ` a t t r i b u t e o n ` a ` / )
366366 } )
367367
368368 await t . test (
Original file line number Diff line number Diff line change 55 "declaration" : true ,
66 "emitDeclarationOnly" : true ,
77 "exactOptionalPropertyTypes" : true ,
8- "lib" : [" es2020 " ],
8+ "lib" : [" es2022 " ],
99 "module" : " node16" ,
1010 "strict" : true ,
1111 "target" : " es2020"
You can’t perform that action at this time.
0 commit comments