mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 10:33:54 +00:00
starlight_help: Do not use type assertions in astro components.
Partially fixes #35435. For KeyboardTip.astro and ZulipTip.astro, we were using type assertions and thus needed to suppress eslint warnings that were being thrown.
This commit is contained in:
committed by
Tim Abbott
parent
5501954637
commit
f20dc8f6cf
@@ -310,14 +310,9 @@ export default tseslint.config(
|
||||
},
|
||||
...astroConfigs.recommended,
|
||||
{
|
||||
files: [
|
||||
"starlight_help/src/components/ZulipNote.astro",
|
||||
"starlight_help/src/components/ZulipTip.astro",
|
||||
"starlight_help/src/components/KeyboardTip.astro",
|
||||
],
|
||||
files: ["starlight_help/src/components/ZulipNote.astro"],
|
||||
rules: {
|
||||
"import/unambiguous": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "off",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -21,22 +21,13 @@ keyboard_icon_first_child.properties.class = "zulip-unplugin-icon";
|
||||
// the next line as `Keyboard tip:`. We have to edit slot HTML tree
|
||||
// directly instead to solve this. Same case applies for the keyboard
|
||||
// icon we are inserting. We just inject the icon as raw svg.
|
||||
const prefix_element_list = [
|
||||
keyboard_icon_first_child,
|
||||
{
|
||||
const prefix_text_element: Element = {
|
||||
type: "element",
|
||||
tagName: "strong",
|
||||
properties: {},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
// Whitespace before the text to ensure space between
|
||||
// this text and the preceding icon.
|
||||
value: " Keyboard tip: ",
|
||||
},
|
||||
],
|
||||
} as Element,
|
||||
];
|
||||
children: [{type: "text", value: " Keyboard tip: "}],
|
||||
};
|
||||
const prefix_element_list = [keyboard_icon_first_child, prefix_text_element];
|
||||
|
||||
const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
|
||||
const first_element = tree.children[0];
|
||||
|
||||
@@ -22,9 +22,7 @@ lightbulb_icon_first_child.properties.class =
|
||||
// `Tip:`. We have to edit slot HTML tree directly instead to solve this.
|
||||
// Same case applies for the ligthbulb icon we are inserting. We just
|
||||
// inject the icon as raw svg.
|
||||
let prefix_element_list = [
|
||||
lightbulb_icon_first_child,
|
||||
{
|
||||
const prefix_text_element: Element = {
|
||||
type: "element",
|
||||
tagName: "strong",
|
||||
properties: {},
|
||||
@@ -36,8 +34,8 @@ let prefix_element_list = [
|
||||
value: " Tip: ",
|
||||
},
|
||||
],
|
||||
} as Element,
|
||||
];
|
||||
};
|
||||
let prefix_element_list = [lightbulb_icon_first_child, prefix_text_element];
|
||||
|
||||
const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
|
||||
const first_element = tree.children[0];
|
||||
@@ -47,14 +45,13 @@ assert.ok(first_element?.type === "element");
|
||||
// where the tip contains an unordered list. Just placing the element as is without
|
||||
// a paragraph does not look good in that case.
|
||||
if (first_element.tagName !== "p") {
|
||||
prefix_element_list = [
|
||||
{
|
||||
const paragraph_wrapping_element: Element = {
|
||||
type: "element",
|
||||
tagName: "p",
|
||||
properties: {},
|
||||
children: [...prefix_element_list],
|
||||
} as Element,
|
||||
];
|
||||
};
|
||||
prefix_element_list = [paragraph_wrapping_element];
|
||||
}
|
||||
|
||||
first_element.children = [...prefix_element_list, ...first_element.children];
|
||||
|
||||
Reference in New Issue
Block a user