Skip to content

feat!: add meta.languages to Markdown rules#664

Open
lumirlumir wants to merge 10 commits into
mainfrom
feat/add-meta-languages
Open

feat!: add meta.languages to Markdown rules#664
lumirlumir wants to merge 10 commits into
mainfrom
feat/add-meta-languages

Conversation

@lumirlumir

@lumirlumir lumirlumir commented May 28, 2026

Copy link
Copy Markdown
Member

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR resolves the issue mentioned in #339 and follows the same strategy used in eslint/json#238 and eslint/css#447.

Unlike the JSON and CSS implementations, Markdown has two rules that only work in GFM mode:

  1. no-bare-urls
  2. table-column-count

These rules should be marked as GFM-only, since they are no-ops in CommonMark mode.

What changes did you make? (Give an overview)

Added meta.languages and meta.docs.dialects, along with test cases.

Related Issues

Fixes: #339
Refs: eslint/json#238, eslint/css#447

Is there anything you'd like reviewers to focus on?

N/A

@eslintbot eslintbot added this to Triage May 28, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage May 28, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage May 28, 2026
@github-actions

This comment was marked as outdated.

Comment thread src/index.js
name: "markdown/recommended",
files: ["**/*.md"],
language: "markdown/commonmark",
language: "markdown/gfm",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the table-column-count rule only works in GFM mode, using the recommended config with commonmark causes the following error:

Oops! Something went wrong! :(

ESLint: 10.6.0

The following rules do not support the language "markdown/commonmark":
	- "markdown/table-column-count"

To fix this error, either:
- Remove the rule from your configuration, or set its severity to "off".
- Use the "files" option to apply the rule only to files of the supported language, for example:
  {
    files: ["**/*.js"],
    rules: { "markdown/table-column-count": "error" }
  }

See https://eslint.org/docs/latest/use/configure/rules for more information.

I think there are two possible approaches to resolve this:

The first is to set the recommended config's language to gfm.

The second is to remove the table-column-count rule from the recommended config and keep commonmark mode.

I'm personally inclined to use gfm since GFM syntax is widely used in Markdown documentation, but I'd like to bring this up in case others have a different perspective.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since rules currently can't tell which language they're running under (the rule context exposes languageOptions but not language) this doesn’t seem solvable in the rule itself.

Given that, I wonder if the better option might be to keep markdown/commonmark as the default language, since it's the more general subset, and remove rules that aren't compatible with CommonMark from the recommended config. Interested to hear what others think. @eslint/eslint-team

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the default recommended config should stay with commonmark mode.
As such I think we should introduce recommended-gfm which sets the language to markdown/gfm and includes table-column-count.
For recommended we can remove table-column-count as it would never report anyway as there are no table elements in commonmark.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the table selector used in table-column-count only exist in GFM? If so, perhaps we could declare that the rule supports both "markdown/commonmark" and "markdown/gfm", but it would only report problems in GFM.

@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Jul 9, 2026
@lumirlumir
lumirlumir requested a review from Copilot July 9, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces rule metadata that annotates which Markdown language/dialect(s) each rule applies to, aligning this plugin with similar metadata strategies used in other ESLint language plugins and enabling better rule applicability signaling.

Changes:

  • Add meta.languages to rule definitions and meta.docs.dialects to rule docs metadata (marking GFM-only rules accordingly).
  • Add plugin.meta.namespace and extend tests to cover the new meta field and custom plugin namespaces.
  • Update the default recommended flat config language to GFM and bump ESLint devDependency versions used in this repo.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/types/types.test.ts Extends type-level assertions to require markdown.meta.namespace.
tests/plugin.test.js Updates runtime meta expectations and adds language/config coverage, including custom-namespace registration.
src/index.js Adds plugin meta.namespace and switches configs.recommended to use language: "markdown/gfm".
src/rules/table-column-count.js Marks the rule as GFM-only via meta.languages and meta.docs.dialects.
src/rules/no-bare-urls.js Marks the rule as GFM-only via meta.languages and meta.docs.dialects.
src/rules/require-alt-text.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-unused-definitions.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-space-in-emphasis.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-reversed-media-syntax.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-reference-like-urls.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-multiple-h1.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-missing-link-fragments.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-missing-label-refs.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-missing-atx-heading-space.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-invalid-label-refs.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-html.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-empty-links.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-empty-images.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-empty-definitions.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-duplicate-headings.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/no-duplicate-definitions.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/heading-increment.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/fenced-code-meta.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
src/rules/fenced-code-language.js Declares CommonMark+GFM applicability via meta.languages and meta.docs.dialects.
package.json Bumps the repo’s ESLint devDependency to ^10.6.0.
examples/typescript/package.json Keeps the TypeScript example aligned with the updated ESLint devDependency version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.js
@lumirlumir
lumirlumir marked this pull request as ready for review July 9, 2026 11:04
@lumirlumir
lumirlumir requested a review from a team July 9, 2026 11:05
@fasttime fasttime moved this from Needs Triage to Feedback Needed in Triage Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Feedback Needed

Development

Successfully merging this pull request may close these issues.

Rule Change: Support language and dialects to meta

5 participants