@tsrx/prettier-plugin 0.3.83 → 0.3.85

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsrx/prettier-plugin",
3
- "version": "0.3.83",
3
+ "version": "0.3.85",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -27,7 +27,7 @@
27
27
  "prettier": "^3.8.3"
28
28
  },
29
29
  "dependencies": {
30
- "@tsrx/core": "0.1.31"
30
+ "@tsrx/core": "0.1.33"
31
31
  },
32
32
  "files": [
33
33
  "src/"
package/src/index.js CHANGED
@@ -6354,7 +6354,18 @@ function printJSXCodeBlock(node, path, options, print) {
6354
6354
  * @returns {Doc | Doc[]}
6355
6355
  */
6356
6356
  function printJSXAttribute(attr, path, options, print) {
6357
- const name = /** @type {ESTreeJSX.JSXIdentifier} */ (attr.name).name;
6357
+ // `attr.name` is either a JSXIdentifier (regular `class`, `id`, ...) or a
6358
+ // JSXNamespacedName (`xlink:href`, `xmlns:xlink`, ...). The previous cast
6359
+ // to JSXIdentifier yielded a raw AST node as `name` for namespaced attrs,
6360
+ // which then leaked into the doc tree and crashed prettier's traversal
6361
+ // with `Unexpected doc.type 'JSXIdentifier'` (see svg-attributes.tsrx +
6362
+ // tsrx-features.tsrx fixtures). Mirror printJSXElementName's logic.
6363
+ const name =
6364
+ attr.name.type === 'JSXNamespacedName'
6365
+ ? /** @type {ESTreeJSX.JSXNamespacedName} */ (attr.name).namespace.name +
6366
+ ':' +
6367
+ /** @type {ESTreeJSX.JSXNamespacedName} */ (attr.name).name.name
6368
+ : /** @type {ESTreeJSX.JSXIdentifier} */ (attr.name).name;
6358
6369
 
6359
6370
  if (attr.shorthand) {
6360
6371
  return ['{', name, '}'];