-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use link to tagged version for rule docs
- Loading branch information
1 parent
655c33d
commit b2a5024
Showing
2 changed files
with
7 additions
and
4 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,5 +1,7 @@ | ||
import pkg from '../package' | ||
|
||
const repoUrl = 'https://github.com/benmosher/eslint-plugin-import' | ||
|
||
export default function docsUrl(ruleName, commitHash = 'master') { | ||
return `${repoUrl}/blob/${commitHash}/docs/rules/${ruleName}.md` | ||
export default function docsUrl(ruleName, commitish = `v${pkg.version}`) { | ||
return `${repoUrl}/blob/${commitish}/docs/rules/${ruleName}.md` | ||
} |
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,14 @@ | ||
import { expect } from 'chai' | ||
|
||
import pkg from '../../../package' | ||
import docsUrl from '../../../src/docsUrl' | ||
|
||
describe('docsUrl', function () { | ||
it('returns the rule documentation URL when given a rule name', function () { | ||
expect(docsUrl('foo')).to.equal('https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/foo.md') | ||
expect(docsUrl('foo')).to.equal(`https://github.com/benmosher/eslint-plugin-import/blob/v${pkg.version}/docs/rules/foo.md`) | ||
}) | ||
|
||
it('supports an optional commit hash parameter', function () { | ||
it('supports an optional commit-ish parameter', function () { | ||
expect(docsUrl('foo', 'bar')).to.equal('https://github.com/benmosher/eslint-plugin-import/blob/bar/docs/rules/foo.md') | ||
}) | ||
}) |