Skip to content

feat: add official @eslint/yaml language plugin#144

Open
andreahlert wants to merge 5 commits intoeslint:mainfrom
andreahlert:rfc-official-yaml-plugin
Open

feat: add official @eslint/yaml language plugin#144
andreahlert wants to merge 5 commits intoeslint:mainfrom
andreahlert:rfc-official-yaml-plugin

Conversation

@andreahlert
Copy link

Summary

This PR adds an RFC for creating an official ESLint language plugin for YAML, published as @eslint/yaml, under the ESLint organization.

Follow-up to Discussion #20482, where @nzakas welcomed an RFC to kickstart this effort.

Checklist

  • New design in designs/2026-official-yaml-language-plugin/
  • README.md follows the template
  • All sections filled in

Links

@eslint-github-bot
Copy link

Hi @andreahlert!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@andreahlert andreahlert changed the title Add RFC: Official @eslint/yaml language plugin docs: add RFC for official @eslint/yaml language plugin Feb 23, 2026
@andreahlert andreahlert force-pushed the rfc-official-yaml-plugin branch from 69906ec to ea2a797 Compare February 23, 2026 07:26
Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

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

This looks like a good start! I've left a couple of comments.

},
languages: {
yaml: new YAMLLanguage({ mode: "yaml" }), // YAML 1.2 (default)
yaml11: new YAMLLanguage({ mode: "yaml11" }), // YAML 1.1 compatibility
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that the YAML 1.1/1.2 selection option would be better placed under languageOptions rather than mode.

export type YAMLLanguageOptions = {
  parserOptions?: {
    defaultYAMLVersion?: "1.1" | "1.2";
  };
};

eslint-plugin-yml already implements it this way. However, there can be different opinions on it, so I’d like to raise it for further discussion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add it directly to languageOptions similar to ecmaVersion for JavaScript:

export type YAMLLanguageOptions = {
	yamlVersion?: "1.1" | "1.2"
}

Copy link
Author

Choose a reason for hiding this comment

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

The current approach follows the same pattern as @eslint/json (json/json, json/jsonc, json/json5) and @eslint/markdown (commonmark, gfm), where mode is a constructor param and separate language entries let users target different file sets declaratively. Open to either approach if the team prefers otherwise.

Copy link
Author

Choose a reason for hiding this comment

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

Interesting parallel with ecmaVersion. The trade-off is declarative per-glob targeting (current approach) vs. a single language with config override. Happy to go with whatever the team prefers.

Copy link
Member

Choose a reason for hiding this comment

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

FYI, the YAML version can be changed using a directive in the YAML file:

%YAML 1.2
---

For this reason, I named it the defaultYAMLVersion option.

Copy link
Member

Choose a reason for hiding this comment

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

I'm reading in the YAML 1.2.2 spec (emphasis mine):

A version 1.2 YAML [processor] must also accept [documents] with an explicit
"%YAML 1.1" directive.
Note that version 1.2 is mostly a superset of version 1.1, defined for the
purpose of ensuring JSON compatibility.
Hence a version 1.2 [processor] should process version 1.1 [documents] as if
they were version 1.2, giving a warning on points of incompatibility
(handling
of [non-ASCII line breaks], as described [above]).

And in the YAML 1.1 spec:

Documents with a "YAML" directive specifying a higher minor version (e.g. "%YAML 1.2") should be processed with an appropriate warning.

That means, if I understand correctly, neither %YAML 1.1 nor %YAML 1.2 changes the way the document is parsed. It only instructs the parses to generate certain warnings?

@mdjermanovic mdjermanovic changed the title docs: add RFC for official @eslint/yaml language plugin feat: add official @eslint/yaml language plugin Feb 25, 2026
@mdjermanovic mdjermanovic added Initial Commenting This RFC is in the initial feedback stage and removed documentation labels Feb 25, 2026
andreahlert and others added 3 commits March 5, 2026 16:19
OK!

Co-authored-by: 루밀LuMir <rpfos@naver.com>
Co-authored-by: 루밀LuMir <rpfos@naver.com>
Co-authored-by: 루밀LuMir <rpfos@naver.com>
@andreahlert
Copy link
Author

@nzakas @mdjermanovic @alexzherdev any suggestions? I would like to start on this.

1. **Language modes:** Is `yaml/yaml` (1.2) + `yaml/yaml11` (1.1) the right split, or should there be a single mode with a version option in `languageOptions`?
2. **Parser choice:** Which YAML parser best balances maintainability, comment support, location accuracy, and license compatibility? (See parser comparison table above.)
3. **Initial rule set:** Are the proposed rules the right starting point? Should any be added or removed for v1?
4. **Collaboration model:** Should the team formally invite @ota-meshi or other community maintainers as collaborators on the new repo?
Copy link
Contributor

Choose a reason for hiding this comment

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

In ideal circumstances we should base the plugin on the work done by ota-meshi:
Move the parser and source code to the official plugin @eslint/yaml and eslint-plugin-yml keeps the stylistic rules.

Copy link
Author

Choose a reason for hiding this comment

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

Using yaml-eslint-parser as a dependency (rather than moving the code) seems like a good middle ground. It leverages the mature parser without the overhead of transferring repos between orgs. Collaboration with @ota-meshi is definitely welcome, and the door is open for deeper integration down the road.

Update parser table, add rules, and expand anchor handling design
based on review comments from @lumirlumir and @DMartens.
YAMLSequence — a sequence (array / list)
YAMLScalar — a scalar value (string, number, boolean, null)
YAMLAlias — an alias reference (*anchor); the anchor name is stored as a property
YAMLComment — a comment (# ...)
Copy link
Member

Choose a reason for hiding this comment

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

In ESLint languages, comments are generally not represented as AST nodes. Instead, they are stored sequentially in separate structures (e.g., a comments array or token list) for convenience. This holds true for each of the js, json, css and html languages provided by official (or semi-official) plugins (markdown AFAIK doesn't have real comments.)

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Because @ota-meshi has already implemented a YAML language in eslint-plugin-yml, I think it's worth asking if it's worth creating another plugin that will do something similar.

The goal of having official plugins is to ensure 1) a consistent level of quality and 2) guaranteed ongoing maintenance. If eslint-plugin-yml already provides both, then it may be a better choice to support and promote it rather than creating a new plugin from scratch.

I'm curious what @andreahlert and @ota-meshi think, and if there are any differences in way eslint-plugin-yml and this RFC are approaching the same problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Initial Commenting This RFC is in the initial feedback stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants