-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rule-metadata): fixed issue with generation of manual url with co…
…debase use of version Preventative measure to ensure URLs are managed better in case version entries change. This was primarily noticed due to the webpack build of the url generated with 0.0.0-semantically-versioned entry was now in the url during testing, weird case but not caught. This change intends to make it more realistic but it will still be v0.0.0 otherwise default to master.
- Loading branch information
1 parent
ae9997e
commit 3b71e8c
Showing
2 changed files
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { parse as parsePath } from "path"; | ||
import { ESLintUtils } from "@typescript-eslint/experimental-utils"; | ||
import { repository, version } from "../package.json"; | ||
import semverCoerce from "semver/functions/coerce"; | ||
import thisPkg from "../package.json"; | ||
|
||
const REPO_URL = repository.url | ||
const pkgVersion = semverCoerce(thisPkg.version)?.version; | ||
const REPO_URL = thisPkg.repository.url | ||
.replace(/git:\/\//, "https://") | ||
.replace(/\.git$/, ""); | ||
|
||
export const createRule = ESLintUtils.RuleCreator((name) => { | ||
const ruleName = parsePath(name).name; | ||
return `${REPO_URL}/blob/v${version}/docs/rules/${ruleName}.md`; | ||
const tag = !pkgVersion ? "master" : `v${pkgVersion}`; | ||
return `${REPO_URL}/blob/${tag}/docs/rules/${ruleName}.md`; | ||
}); | ||
export default createRule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters