get-docs-url.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @author Suhas Karanth
  3. * @copyright 2018 Toru Nagashima. All rights reserved.
  4. * See LICENSE file in root directory for full license.
  5. */
  6. "use strict"
  7. //------------------------------------------------------------------------------
  8. // Requirements
  9. //------------------------------------------------------------------------------
  10. const pkg = require("../../package")
  11. //------------------------------------------------------------------------------
  12. // Helpers
  13. //------------------------------------------------------------------------------
  14. const REPO_URL = "https://github.com/mysticatea/eslint-plugin-node"
  15. //------------------------------------------------------------------------------
  16. // Public Interface
  17. //------------------------------------------------------------------------------
  18. /**
  19. * Generates the URL to documentation for the given rule name. It uses the
  20. * package version to build the link to a tagged version of the
  21. * documentation file.
  22. *
  23. * @param {string} ruleName - Name of the eslint rule
  24. * @returns {string} URL to the documentation for the given rule
  25. */
  26. module.exports = function getDocsUrl(ruleName) {
  27. return `${REPO_URL}/blob/v${pkg.version}/docs/rules/${ruleName}.md`
  28. }