Skip to content

Latest commit

 

History

History
80 lines (52 loc) · 2.69 KB

File metadata and controls

80 lines (52 loc) · 2.69 KB
pageClass rule-details
sidebarDepth 0
title markdown-preferences/prefer-link-reference-definitions
description enforce using link reference definitions instead of inline links
since v0.6.0

markdown-preferences/prefer-link-reference-definitions

enforce using link reference definitions instead of inline links

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule enforces the use of link reference definitions instead of inline links when the same URL is used multiple times (2 or more by default). This improves readability and maintainability of Markdown documents by keeping the link URLs organized at the bottom of sections.

The rule automatically converts inline links to reference links and adds the reference definitions at the end of the current section (before the next heading).

<!-- eslint markdown-preferences/prefer-link-reference-definitions: 'error' -->

<!-- ✓ GOOD -->

- [ESLint] is a JavaScript linter.
- [ESLint][eslint] helps maintain code quality.

[eslint]: https://eslint.org

<!-- ✗ BAD -->

- [ESLint](https://eslint.org) is a JavaScript linter.
- [ESLint](https://eslint.org) helps maintain code quality.

🔧 Options

You can configure the minimum number of links required to trigger this rule.

{
  "markdown-preferences/prefer-link-reference-definitions": [
    "error",
    {
      "minLinks": 2
    }
  ]
}
  • minLinks: The minimum number of links with the same URL to trigger the rule. Default is 2.

minLinks

The minimum number of links with the same URL to trigger the rule. Default is 2.

  • Must be a positive integer (minimum: 1)
  • When set to 1, all inline links will be converted to reference definitions
  • When set to 2 or higher, only URLs that appear multiple times will be converted

📚 Further Reading

👫 Related Rules

🚀 Version

This rule was introduced in eslint-plugin-markdown-preferences v0.6.0

🔍 Implementation