Skip to content

fix: handle symbol in validateLanguageOptions - #722

Open
lumirlumir wants to merge 1 commit into
mainfrom
fix/handle-symbol-inmarkdownlanguage
Open

fix: handle symbol in validateLanguageOptions#722
lumirlumir wants to merge 1 commit into
mainfrom
fix/handle-symbol-inmarkdownlanguage

Conversation

@lumirlumir

@lumirlumir lumirlumir commented Aug 27, 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?

Which language are you using?

CommonMark and GFM.

What did you do?

When I use MarkdownLanguage#validateLanguageOptions with a symbol value, it produces an incorrect error message.

What did you expect to happen?

I expected the error message to be:

Invalid language option value `Symbol(frontmatter)` for frontmatter. Expected one of `false`, `"yaml"`, `"toml"`, or `"json"`.

What actually happened?

However, I got:

'Cannot convert a Symbol value to a string'

Link to Minimal Reproducible Example

Create a test.js file in the root of the markdown project.

import { MarkdownLanguage } from "./src/language/markdown-language.js";

const language = new MarkdownLanguage();

for (const languageOptions of [
	{ frontmatter: Symbol("frontmatter") },
	{ math: Symbol("math") },
]) {
	try {
		language.validateLanguageOptions(languageOptions);
	} catch (error) {
		console.error(error.message);
	}
}

What changes did you make? (Give an overview)

This is a simple bug fix. I’ve coerced the message variable with String so that it can also handle an incorrectly passed symbol value.

This is a subtle edge case, but I noticed it while working on #706.

Related Issues

N/A

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

I’ve verified that the JSON and CSS language plugins don’t have this type of issue.

@eslintbot eslintbot added this to Triage Aug 27, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Aug 27, 2026
@lumirlumir
lumirlumir marked this pull request as ready for review August 27, 2026 14:26
@DMartens DMartens moved this from Needs Triage to Evaluating in Triage Aug 27, 2026
@DMartens

Copy link
Copy Markdown
Contributor

The JS, CSS and JSON language do not have the problem as they do not print the value.
I think the explicit String cast only makes a difference for Symbol and as such I think the change is fine.
Leaving open for a potential second review.

@DMartens DMartens moved this from Evaluating to Merge Candidates in Triage Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Merge Candidates

Development

Successfully merging this pull request may close these issues.

3 participants