Skip to content

Commit

Permalink
Merge pull request #1005 from sudo-suhas/docs-link-tagged
Browse files Browse the repository at this point in the history
[Docs] Use link to tagged version for rule docs
  • Loading branch information
ljharb authored Jan 22, 2018
2 parents 655c33d + fa24082 commit b08bd3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/docsUrl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pkg from '../package.json'

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`
}
5 changes: 3 additions & 2 deletions tests/src/core/docsUrl.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { expect } from 'chai'

import pkg from '../../../package.json'
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')
})
})

0 comments on commit b08bd3e

Please sign in to comment.