Skip to content

Commit 3d93c09

Browse files
Copilotalexr00
andcommitted
Address code review feedback: add js-yaml dependency and improve type safety
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 981e126 commit 3d93c09

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4433,6 +4433,7 @@
44334433
"debounce": "^1.2.1",
44344434
"events": "3.2.0",
44354435
"fast-deep-equal": "^3.1.3",
4436+
"js-yaml": "^4.1.1",
44364437
"jsonc-parser": "^3.3.1",
44374438
"jszip": "^3.10.1",
44384439
"lru-cache": "6.0.0",

src/issues/issueFeatureRegistrar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,8 @@ ${options?.body ?? ''}\n
12551255
// Try to parse as YAML first (YAML templates have a different structure)
12561256
try {
12571257
const parsed = yaml.load(template);
1258-
if (parsed && typeof parsed === 'object' && (parsed as YamlIssueTemplate).name) {
1258+
// Check if it looks like a YAML issue template (has name and body fields)
1259+
if (parsed && typeof parsed === 'object' && (parsed as YamlIssueTemplate).name && (parsed as YamlIssueTemplate).body) {
12591260
// This is a YAML template
12601261
return this.parseYamlTemplate(parsed as YamlIssueTemplate);
12611262
}
@@ -1306,7 +1307,7 @@ ${options?.body ?? ''}\n
13061307
body += `${field.attributes.description}\n\n`;
13071308
}
13081309
if (field.attributes.options && Array.isArray(field.attributes.options)) {
1309-
body += field.attributes.options.map((opt: string) => `- ${opt}`).join('\n') + '\n\n';
1310+
body += field.attributes.options.map((opt: string | { label?: string }) => typeof opt === 'string' ? `- ${opt}` : `- ${opt.label || ''}`).join('\n') + '\n\n';
13101311
}
13111312
} else if (field.type === 'checkboxes' && field.attributes?.label) {
13121313
body += `## ${field.attributes.label}\n\n`;

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,6 +4765,13 @@ js-yaml@4.1.0, js-yaml@^4.1.0:
47654765
dependencies:
47664766
argparse "^2.0.1"
47674767

4768+
js-yaml@^4.1.1:
4769+
version "4.1.1"
4770+
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b"
4771+
integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==
4772+
dependencies:
4773+
argparse "^2.0.1"
4774+
47684775
jsdom-global@3.0.2:
47694776
version "3.0.2"
47704777
resolved "https://registry.yarnpkg.com/jsdom-global/-/jsdom-global-3.0.2.tgz#6bd299c13b0c4626b2da2c0393cd4385d606acb9"

0 commit comments

Comments
 (0)