Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use link to tagged version for rule docs #1005

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
})
})