Changesets · Branches · Tags · Compare
| Changeset | 370bd05956f888a2821302d9e8d8d20fc60b1a9c8fa05401b42645610fb28fec |
|---|---|
| Author | Tomasz Stefaniak <tomasz.p.stefaniak@gmail.com> · 2025-09-12 14:17 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-12 14:17 -07:00 |
| Parents | 235058a67062, 4471e8ac2ed3 |
2 files changed
modified packages/config-yaml/src/markdown/markdownToRule.test.ts +60 −0
| @@ -261,6 +261,66 @@ | ||
| 261 | 261 | const result = markdownToRule(content, mockId); |
| 262 | 262 | expect(result.alwaysApply).toBe(false); |
| 263 | 263 | }); |
| 264 | + | |
| 265 | + it("should include invokable from frontmatter when true", () => { | |
| 266 | + const content = `--- | |
| 267 | +globs: "**/test/**/*.kt" | |
| 268 | +name: Test Rule | |
| 269 | +invokable: true | |
| 270 | +--- | |
| 271 | + | |
| 272 | +# Test Rule | |
| 273 | + | |
| 274 | +This is an invokable rule.`; | |
| 275 | + | |
| 276 | + const result = markdownToRule(content, mockId); | |
| 277 | + expect(result.invokable).toBe(true); | |
| 278 | + }); | |
| 279 | + | |
| 280 | + it("should include invokable from frontmatter when false", () => { | |
| 281 | + const content = `--- | |
| 282 | +globs: "**/test/**/*.kt" | |
| 283 | +name: Test Rule | |
| 284 | +invokable: false | |
| 285 | +--- | |
| 286 | + | |
| 287 | +# Test Rule | |
| 288 | + | |
| 289 | +This is a non-invokable rule.`; | |
| 290 | + | |
| 291 | + const result = markdownToRule(content, mockId); | |
| 292 | + expect(result.invokable).toBe(false); | |
| 293 | + }); | |
| 294 | + | |
| 295 | + it("should handle invokable with alwaysApply together", () => { | |
| 296 | + const content = `--- | |
| 297 | +alwaysApply: true | |
| 298 | +invokable: true | |
| 299 | +name: Test Rule | |
| 300 | +--- | |
| 301 | + | |
| 302 | +# Test Rule | |
| 303 | + | |
| 304 | +This is a rule with both alwaysApply and invokable.`; | |
| 305 | + | |
| 306 | + const result = markdownToRule(content, mockId); | |
| 307 | + expect(result.alwaysApply).toBe(true); | |
| 308 | + expect(result.invokable).toBe(true); | |
| 309 | + }); | |
| 310 | + | |
| 311 | + it("should not include invokable when not in frontmatter", () => { | |
| 312 | + const content = `--- | |
| 313 | +globs: "**/test/**/*.kt" | |
| 314 | +name: Test Rule | |
| 315 | +--- | |
| 316 | + | |
| 317 | +# Test Rule | |
| 318 | + | |
| 319 | +This is a rule without invokable property.`; | |
| 320 | + | |
| 321 | + const result = markdownToRule(content, mockId); | |
| 322 | + expect(result.invokable).toBeUndefined(); | |
| 323 | + }); | |
| 264 | 324 | }); |
| 265 | 325 | |
| 266 | 326 | describe("getRuleName", () => { |
modified packages/config-yaml/src/markdown/markdownToRule.ts +2 −0
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | name?: RuleObject["name"]; |
| 13 | 13 | description?: RuleObject["description"]; |
| 14 | 14 | alwaysApply?: RuleObject["alwaysApply"]; |
| 15 | + invokable?: RuleObject["invokable"]; | |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | /** |
| @@ -115,6 +116,7 @@ | ||
| 115 | 116 | regex: frontmatter.regex, |
| 116 | 117 | description: frontmatter.description, |
| 117 | 118 | alwaysApply: frontmatter.alwaysApply, |
| 119 | + invokable: frontmatter.invokable, | |
| 118 | 120 | sourceFile: id.uriType === "file" ? id.fileUri : undefined, |
| 119 | 121 | }; |
| 120 | 122 | } |