DEV: Fix router linting errors (#24012)

`ember/no-unnecessary-route-path-option`
`ember/routes-segments-snake-case`
This commit is contained in:
Jarek Radosz 2023-11-29 12:26:31 +01:00 committed by GitHub
parent 6e4648a2c4
commit cbe772f6fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 35 deletions

View File

@ -110,7 +110,7 @@ export default function () {
"adminCustomizeFormTemplates",
{ path: "/form-templates", resetNamespace: true },
function () {
this.route("new", { path: "/new" });
this.route("new");
this.route("edit", { path: "/:id" });
}
);
@ -118,7 +118,6 @@ export default function () {
"adminWatchedWords",
{ path: "/watched_words", resetNamespace: true },
function () {
this.route("index", { path: "/" });
this.route("action", { path: "/action/:action_id" });
}
);
@ -131,7 +130,7 @@ export default function () {
{ path: "/keys", resetNamespace: true },
function () {
this.route("show", { path: "/:api_key_id" });
this.route("new", { path: "/new" });
this.route("new");
}
);
@ -174,7 +173,7 @@ export default function () {
{ path: "/search_logs", resetNamespace: true },
function () {
this.route("index", { path: "/" });
this.route("term", { path: "/term" });
this.route("term");
}
);
}
@ -226,7 +225,7 @@ export default function () {
this.route("admin-revamp", { resetNamespace: true }, function () {
this.route("lobby", { path: "/" }, function () {});
this.route("config", { path: "config" }, function () {
this.route("config", function () {
this.route("area", { path: "/:area" });
});
});

View File

@ -3,10 +3,10 @@ import Site from "discourse/models/site";
export default function () {
// Error page
this.route("exception", { path: "/exception" });
this.route("exception");
this.route("exception-unknown", { path: "/404" });
this.route("about", { path: "/about", resetNamespace: true });
this.route("about", { resetNamespace: true });
this.route("post", { path: "/p/:id" });
@ -16,11 +16,15 @@ export default function () {
{ path: "/t/:slug/:id", resetNamespace: true },
function () {
this.route("fromParams", { path: "/" });
// eslint-disable-next-line ember/routes-segments-snake-case
this.route("fromParamsNear", { path: "/:nearPost" });
}
);
this.route("topicBySlugOrId", { path: "/t/:slugOrId", resetNamespace: true });
this.route("topicBySlugOrId", {
path: "/t/:slug_or_id",
resetNamespace: true,
});
this.route("newCategory", { path: "/new-category" });
this.route("editCategory", { path: "/c/*slug/edit" }, function () {
@ -52,8 +56,7 @@ export default function () {
});
});
this.route("filter", { path: "/filter" });
this.route("filter");
this.route("categories");
// default filter for a category
@ -157,7 +160,7 @@ export default function () {
this.route("unread");
});
this.route("tags", { path: "/tags" }, function () {
this.route("tags", function () {
this.route("show", { path: ":id" });
});
}
@ -191,30 +194,29 @@ export default function () {
}
);
this.route("review", { path: "/review" }, function () {
this.route("review", function () {
this.route("show", { path: "/:reviewable_id" });
this.route("index", { path: "/" });
this.route("topics", { path: "/topics" });
this.route("settings", { path: "/settings" });
this.route("topics");
this.route("settings");
});
this.route("signup", { path: "/signup" });
this.route("login", { path: "/login" });
this.route("signup");
this.route("login");
this.route("email-login", { path: "/session/email-login/:token" });
this.route("second-factor-auth", { path: "/session/2fa" });
this.route("associate-account", { path: "/associate/:token" });
this.route("login-preferences");
this.route("forgot-password", { path: "/password-reset" });
this.route("faq", { path: "/faq" });
this.route("guidelines", { path: "/guidelines" });
this.route("conduct", { path: "/conduct" });
this.route("rules", { path: "/rules" });
this.route("faq");
this.route("guidelines");
this.route("conduct");
this.route("rules");
this.route("tos", { path: "/tos" });
this.route("privacy", { path: "/privacy" });
this.route("tos");
this.route("privacy");
this.route("new-topic", { path: "/new-topic" });
this.route("new-message", { path: "/new-message" });
this.route("new-topic");
this.route("new-message");
this.route("badges", { resetNamespace: true }, function () {
this.route("show", { path: "/:id/:slug" });
@ -271,11 +273,7 @@ export default function () {
}
);
this.route(
"invites",
{ path: "/invites", resetNamespace: true },
function () {
this.route("show", { path: "/:token" });
}
);
this.route("invites", { resetNamespace: true }, function () {
this.route("show", { path: "/:token" });
});
}

View File

@ -6,10 +6,10 @@ export default DiscourseRoute.extend({
router: service(),
model(params) {
if (params.slugOrId.match(ID_CONSTRAINT)) {
return { url: `/t/topic/${params.slugOrId}` };
if (params.slug_or_id.match(ID_CONSTRAINT)) {
return { url: `/t/topic/${params.slug_or_id}` };
} else {
return Topic.idForSlug(params.slugOrId).then((data) => {
return Topic.idForSlug(params.slug_or_id).then((data) => {
return { url: `/t/${data.slug}/${data.topic_id}` };
});
}