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
sindresorhus committed Jan 21, 2018
1 parent aa3daae commit cf0939b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 92 deletions.
178 changes: 89 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
{
"name": "eslint-plugin-ava",
"version": "4.4.0",
"description": "ESLint rules for AVA",
"license": "MIT",
"repository": "avajs/eslint-plugin-ava",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "Vadim Demedes",
"email": "[email protected]",
"url": "github.com/vdemedes"
},
{
"name": "James Talmage",
"email": "[email protected]",
"url": "github.com/jamestalmage"
},
{
"name": "Mark Wubben",
"email": "[email protected]",
"url": "novemberborn.net"
},
{
"name": "Takuto Wada",
"email": "[email protected]",
"url": "github.com/twada"
},
{
"name": "Jeroen Engels",
"email": "[email protected]",
"url": "github.com/jfmengels"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js",
"create-ava-rule.js",
"util.js",
"rules"
],
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"ava",
"test",
"runner",
"assert",
"asserts",
"assertion",
"mocha"
],
"dependencies": {
"arrify": "^1.0.1",
"deep-strict-equal": "^0.2.0",
"enhance-visitors": "^1.0.0",
"espree": "^3.1.3",
"espurify": "^1.5.0",
"import-modules": "^1.1.0",
"multimatch": "^2.1.0",
"pkg-up": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"babel-eslint": "^8.0.2",
"coveralls": "^3.0.0",
"eslint": "^4.5.0",
"eslint-ava-rule-tester": "^2.0.0",
"js-combinatorics": "^0.5.0",
"nyc": "^11.1.0",
"pify": "^3.0.0",
"xo": "*"
},
"peerDependencies": {
"eslint": ">=3.6"
},
"ava": {
"failWithoutAssertions": true
}
"name": "eslint-plugin-ava",
"version": "4.4.0",
"description": "ESLint rules for AVA",
"license": "MIT",
"repository": "avajs/eslint-plugin-ava",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "Vadim Demedes",
"email": "[email protected]",
"url": "github.com/vdemedes"
},
{
"name": "James Talmage",
"email": "[email protected]",
"url": "github.com/jamestalmage"
},
{
"name": "Mark Wubben",
"email": "[email protected]",
"url": "novemberborn.net"
},
{
"name": "Takuto Wada",
"email": "[email protected]",
"url": "github.com/twada"
},
{
"name": "Jeroen Engels",
"email": "[email protected]",
"url": "github.com/jfmengels"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js",
"create-ava-rule.js",
"util.js",
"rules"
],
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"ava",
"test",
"runner",
"assert",
"asserts",
"assertion",
"mocha"
],
"dependencies": {
"arrify": "^1.0.1",
"deep-strict-equal": "^0.2.0",
"enhance-visitors": "^1.0.0",
"espree": "^3.1.3",
"espurify": "^1.5.0",
"import-modules": "^1.1.0",
"multimatch": "^2.1.0",
"pkg-up": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"babel-eslint": "^8.0.2",
"coveralls": "^3.0.0",
"eslint": "^4.5.0",
"eslint-ava-rule-tester": "^2.0.0",
"js-combinatorics": "^0.5.0",
"nyc": "^11.1.0",
"pify": "^3.0.0",
"xo": "*"
},
"peerDependencies": {
"eslint": ">=3.6"
},
"ava": {
"failWithoutAssertions": true
}
}
5 changes: 3 additions & 2 deletions test/util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import test from 'ava';
import util from '../util';
import pkg from '../package';

test('returns the URL of the a named rule\'s documentation', t => {
const url = 'https://github.com/avajs/eslint-plugin-ava/blob/master/docs/rules/foo.md';
const url = `https://github.com/avajs/eslint-plugin-ava/blob/v${pkg.version}/docs/rules/foo.md`;
t.is(util.getDocsUrl('foo'), url);
});

Expand All @@ -12,6 +13,6 @@ test('returns the URL of the a named rule\'s documentation at a commit hash', t
});

test('determines the rule name from the file', t => {
const url = 'https://github.com/avajs/eslint-plugin-ava/blob/master/docs/rules/util.md';
const url = `https://github.com/avajs/eslint-plugin-ava/blob/v${pkg.version}/docs/rules/util.md`;
t.is(util.getDocsUrl(), url);
});
3 changes: 2 additions & 1 deletion util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const fs = require('fs');
const path = require('path');
const pkg = require('./package');

const functionExpressions = [
'FunctionExpression',
Expand Down Expand Up @@ -105,7 +106,7 @@ const repoUrl = 'https://github.com/avajs/eslint-plugin-ava';
*/
const getDocsUrl = (ruleName, commitHash) => {
ruleName = ruleName || path.basename(module.parent.filename, '.js');
commitHash = commitHash || 'master';
commitHash = commitHash || `v${pkg.version}`;
return `${repoUrl}/blob/${commitHash}/docs/rules/${ruleName}.md`;
};
exports.getDocsUrl = getDocsUrl;
Expand Down

0 comments on commit cf0939b

Please sign in to comment.