markdown/no-reversed-media-syntax

Disallow reversed link and image syntax

fixable

The syntax is [text](url). The other way around, (text)[url], isn't a link, and all of it shows up as text.

--fix swaps the brackets.

Configure#

Off by default. It needs an ESLint config that says which files are in the language:

eslint.config.js
import markdown from "@eslint/markdown";

export default [
  {
    files: ["**/*.md"],
    plugins: { markdown },
    language: "markdown/commonmark",
    rules: { "markdown/no-reversed-media-syntax": "error" },
  },
];

It also works with markdown/gfm.

Examples#

example.md2 problems
Read (the guide)[https://example.com/guide].

!(The logo)[./logo.png]
example.mdNo problems
Read [the guide](https://example.com/guide).

![The logo](./logo.png)

Call `f(a)[0]`.