Hi there! We're having trouble getting a custom rule to run at all in our repo.
We want to enforce that trailing slashes are always used, which is the opposite behaviour from the built-in telescope rule path-no-trailing-slash. We wrote up a custom rule that mostly copies the code from the original rule but inverts the check.
import { defineRule } from "telescope-server";
export default defineRule({
meta: {
id: "must-have-trailing-slash",
number: 9999,
type: "suggestion",
description: "Paths should end with trailing slashes",
defaultSeverity: "warning"
},
check(ctx) {
return {
PathItem(pathItem) {
const path = pathItem.path();
if (!path) return;
if (path === "/") return;
if (!path.endsWith("/")) { // The inverted line
ctx.reportHere(pathItem, {
message: `Path '${path}' should end with a trailing slash`,
severity: "warning",
});
}
},
};
},
});
In our config.yaml:
# `.telescope/config.yaml`
openapi:
rulesOverrides:
path-no-trailing-slash: off
rules:
- rule: must-have-trailing-slash.ts
The rule override is working great, but the custom rule isn't triggering at all. I was wondering if we've done something incorrectly?
Cheers.
Hi there! We're having trouble getting a custom rule to run at all in our repo.
We want to enforce that trailing slashes are always used, which is the opposite behaviour from the built-in telescope rule
path-no-trailing-slash. We wrote up a custom rule that mostly copies the code from the original rule but inverts the check.In our config.yaml:
The rule override is working great, but the custom rule isn't triggering at all. I was wondering if we've done something incorrectly?
Cheers.