bestax-migrate 2.3.3 → 2.3.4
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.
|
@@ -48,8 +48,6 @@ export declare function declaresAs(target: string): boolean;
|
|
|
48
48
|
/** The rows the type test holds to the library. */
|
|
49
49
|
export declare const HREF_TABLE: Record<string, string>;
|
|
50
50
|
export declare const AS_ANY_TARGETS: readonly string[];
|
|
51
|
-
/** The rows the type test holds to the library. */
|
|
52
|
-
export declare const TARGET_LINK_ATTR_TABLE: Record<string, readonly string[]>;
|
|
53
51
|
/**
|
|
54
52
|
* The intrinsic elements React types an `href` onto.
|
|
55
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polymorphic.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/polymorphic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AA0BxB,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"polymorphic.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/polymorphic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AA0BxB,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAkB,CAAC;AAkK3E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,GAAG,SAAS,EAC5B,eAAa,KACZ,MAmBF,CAAC;AAMF,oDAAoD;AACpD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD;AAQD,mDAAmD;AACnD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAW,CAAC;AAC1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAuB,CAAC;AAoDpE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAkC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAwH5C,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AASD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,0DAA0D;AAC1D,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAoC,CAAC;AAE7E,6CAA6C;AAC7C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAC1C,CAAC;AAqLrB;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM;AACd;;;;;;;;;GASG;AACH,gBAAgB,UAAQ,GACvB,IAAI,CAsEN"}
|
|
@@ -78,8 +78,7 @@ const AS_ANY = new Set(['Button', 'Menu.Item', 'Navbar.Item', 'Navbar.Link']);
|
|
|
78
78
|
* typechecking cannot answer the question on its own. `Level.Item` declares
|
|
79
79
|
* `href` on its props at every `as`, so `<Level.Item href="/x">` compiles --
|
|
80
80
|
* but it renders a <div> and forwards `href` only when the tag is an `<a>`
|
|
81
|
-
* (`
|
|
82
|
-
* runtime. A table built from the types alone calls that supported; it is the
|
|
81
|
+
* (`LevelItem`'s anchor branch), so the attribute is dropped at runtime. A table built from the types alone calls that supported; it is the
|
|
83
82
|
* same dead attribute this pass exists to remove.
|
|
84
83
|
*/
|
|
85
84
|
const HREF_OK = {
|
|
@@ -252,7 +251,7 @@ export const AS_ANY_TARGETS = [...AS_ANY].sort();
|
|
|
252
251
|
*
|
|
253
252
|
* They are excluded because the components disagree about what they forward,
|
|
254
253
|
* so no shared set is right. `Menu.Item` strips `href` unless the tag is an
|
|
255
|
-
* `<a>` or a custom component (`
|
|
254
|
+
* `<a>` or a custom component (`MenuItem`'s `isLinkLike` guard),
|
|
256
255
|
* while `Button` routes everything but `'button'` through its anchor path and
|
|
257
256
|
* would forward it. Keeping `href` beside `as="area"` therefore typechecks on
|
|
258
257
|
* both and does nothing on one of them, which is the silently-dead attribute
|
|
@@ -291,26 +290,6 @@ const LINK_ATTR_ELEMENTS = {
|
|
|
291
290
|
// `rel` is deliberately absent: React declares it on `HTMLAttributes`, so it
|
|
292
291
|
// is valid on every intrinsic and there is nothing to remove. The same point
|
|
293
292
|
// `bulma-ui/src/__typetests__/polymorphic.tsx` makes about it.
|
|
294
|
-
/**
|
|
295
|
-
* The link attributes a target accepts, where its props do not follow `as`.
|
|
296
|
-
*
|
|
297
|
-
* Most components here either follow `as` (the element decides, above) or
|
|
298
|
-
* extend `AnchorHTMLAttributes` outright (`Pagination.*`, `Panel.Block`, so
|
|
299
|
-
* everything is fine). `Level.Item` is the exception that enumerates: it
|
|
300
|
-
* declares `href`, `target` and `rel` and nothing else, so `download`,
|
|
301
|
-
* `hrefLang`, `ping` and `referrerPolicy` are type errors there even at
|
|
302
|
-
* `as="a"`.
|
|
303
|
-
*
|
|
304
|
-
* A target absent from `HREF_OK` needs no row: a component that takes no
|
|
305
|
-
* `href` at any `as` takes none of its siblings either -- verified for
|
|
306
|
-
* `Card.FooterItem`, `Tabs.Item` and `Delete`, which is why this is derived
|
|
307
|
-
* from that table rather than being a second list to keep.
|
|
308
|
-
*/
|
|
309
|
-
const TARGET_LINK_ATTRS = {
|
|
310
|
-
'Level.Item': ['target'],
|
|
311
|
-
};
|
|
312
|
-
/** The rows the type test holds to the library. */
|
|
313
|
-
export const TARGET_LINK_ATTR_TABLE = TARGET_LINK_ATTRS;
|
|
314
293
|
/**
|
|
315
294
|
* The intrinsic elements React types an `href` onto.
|
|
316
295
|
*
|
|
@@ -565,22 +544,21 @@ function dropInertHref(ctx, path, element, target, literal, elementKnown) {
|
|
|
565
544
|
*/
|
|
566
545
|
function dropInertLinkAttrs(ctx, path, element, target, rendered) {
|
|
567
546
|
const carriesLinks = HREF_OK[target] !== undefined;
|
|
568
|
-
const declared = TARGET_LINK_ATTRS[target];
|
|
569
547
|
for (const name of LINK_ATTRS) {
|
|
570
|
-
//
|
|
571
|
-
//
|
|
572
|
-
//
|
|
573
|
-
//
|
|
574
|
-
//
|
|
575
|
-
//
|
|
576
|
-
//
|
|
577
|
-
//
|
|
578
|
-
//
|
|
548
|
+
// Two ways to refuse it, and which one decides the TODO's wording. The
|
|
549
|
+
// component refuses outright if it is no link at any `as`. Otherwise the
|
|
550
|
+
// ELEMENT decides — `Level.Item` declares `target` and forwards it only for
|
|
551
|
+
// an `<a>`, so `<Level.Item as="p" target="_blank">` would keep the same
|
|
552
|
+
// inert attribute this pass removes everywhere else, and the message has to
|
|
553
|
+
// say the `<p>` refused it rather than that the component did.
|
|
554
|
+
//
|
|
555
|
+
// There used to be a third way: a per-target table for a component that
|
|
556
|
+
// enumerated a SUBSET of the link attributes and was therefore narrower
|
|
557
|
+
// than its own element. Nothing is, since #672, so the table went with the
|
|
558
|
+
// branch that read it.
|
|
579
559
|
let rejectedBy = null;
|
|
580
560
|
if (!carriesLinks)
|
|
581
561
|
rejectedBy = 'component';
|
|
582
|
-
else if (declared && !declared.includes(name))
|
|
583
|
-
rejectedBy = 'component';
|
|
584
562
|
// A dynamic `as` leaves the element unknown, and guessing either way is
|
|
585
563
|
// worse than leaving it for the author.
|
|
586
564
|
else if (rendered !== undefined && !elementTakesLinkAttr(name, rendered))
|
|
@@ -594,9 +572,7 @@ function dropInertLinkAttrs(ctx, path, element, target, rendered) {
|
|
|
594
572
|
removeAttr(element, attr);
|
|
595
573
|
const because = rejectedBy === 'element'
|
|
596
574
|
? `\`${name}\` needs an element that takes it, and \`${target}\` renders a <${rendered}> here`
|
|
597
|
-
:
|
|
598
|
-
? `bestax \`${target}\` is not a link at any \`as\`, so it takes no \`${name}\` either`
|
|
599
|
-
: `bestax \`${target}\` declares its own props rather than taking the element's, and \`${name}\` is not among them`;
|
|
575
|
+
: `bestax \`${target}\` is not a link at any \`as\`, so it takes no \`${name}\` either`;
|
|
600
576
|
addTodo(ctx, path, `prop:${name}`, `${because} -- ${was ? `it read \`${was}\`; ` : ''}${remedyFor(target, rendered)}`);
|
|
601
577
|
ctx.dirty = true;
|
|
602
578
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "Codemods for migrating existing React apps from other Bulma libraries to @allxsmith/bestax-bulma",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"chalk": "^6.0.0",
|
|
39
39
|
"commander": "^15.0.0",
|
|
40
40
|
"jscodeshift": "^17.3.0",
|
|
41
|
-
"@allxsmith/bestax-bulma": "^5.15.
|
|
41
|
+
"@allxsmith/bestax-bulma": "^5.15.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@jest/globals": "^30.0.0",
|