Skip to content

Commit

Permalink
Use link to tagged version for rule docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-suhas committed Jan 22, 2018
1 parent 655c33d commit fa24082
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 fa24082

Please sign in to comment.