Skip to content

Change Request: Add support for YAML and TOML inline config comments #396

@lumirlumir

Description

@lumirlumir

Environment

ESLint version: HEAD
@eslint/markdown version: HEAD
Node version: 20.18.0
npm version: 10.9.2
Operating System: Windows 11

What problem do you want to solve?

Hello,

In this issue, I would like to suggest YAML and TOML style inline config comments.


What are YAML and TOML style inline config comments?

Currently, @eslint/markdown supports below configuration comments:

<!-- eslint markdown/fenced-code-language: "error" -->

However, we don't support them for YAML and TOML front matters. For example:

---
# eslint markdown/fenced-code-language: "error"
hello: 'eslint'
---
+++
# eslint markdown/fenced-code-language: "error"
hello = 'eslint'
+++

Then, why do we have to support YAML and TOML style inline config comments?

Currently no-multiple-h1 rule validates YAML and TOML nodes; however, inline config comments like the following don’t work:

Image

<!-- eslint markdown/no-multiple-h1: "error" -->

---
title: My Title
---

# Heading 1

You can check the ast in here.

Since YAML and TOML should be placed at the top of a Markdown document, if an HTML inline config comment appears first, YAML and TOML cannot be parsed correctly.

So, if someone creates a rule to handle YAML or TOML nodes, the HTML-style inline config will never be applied to the front matter. This would prevent users from using inline config comments with front matter.

What do you think is the correct solution?

Update markdown-source-code.js to properly apply inline config comments.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

If this rule looks good to implement, I'll finish the work by June 8.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions