Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add ESLint#getRulesMetaForResults() (refs #13654) #14716

Merged
merged 3 commits into from Jun 18, 2021
Merged

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Jun 16, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Added the ESLint#getRulesMetaForResults() method. This method was proposed as ESLint#getRulesMetaForReport() but that wording was incorrect in the RFC because it's CLIEngine that return a report while ESLint returns an array of results, so I updated the name to match that reality.,

I chose to return an object so that the rulesMeta passed to formatters is the same format rather than returning a map.

This part of the RFC is non-breaking, which is why I chose to create a separate PR for it.

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

Does this implementation match everyone's expectations?

@nzakas nzakas added enhancement This change enhances an existing feature of ESLint core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion labels Jun 16, 2021
@nzakas nzakas linked an issue Jun 17, 2021 that may be closed by this pull request
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM aside from the comments about the documentation.

Does this implementation match everyone's expectations?

I'd guess this covers all use cases where CLIEngine#getRules() was used, but can't be sure.

Assuming that it covers all use cases, I think it makes sense to require the results argument, as it clarifies this method and emphasizes that it should be called after ESLint#lintFiles()/ESLint#lintText().

@nzakas
Copy link
Member Author

nzakas commented Jun 18, 2021

Docs have been updated. I think between use-at-your-own-risk builtinRules and this method, we are covering the majority of cases. We can always look at adding more methods if we find a gap.

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

LGTM. Just one fix to the docs, and I'll commit that inline if you don't see it by the time I'm ready to do the release so it can go out today.

docs/developer-guide/nodejs-api.md Outdated Show resolved Hide resolved
Co-authored-by: Brandon Mills <btmills@users.noreply.github.com>
@btmills btmills merged commit c2cd7b4 into master Jun 18, 2021
@btmills btmills deleted the issue13654-b branch June 18, 2021 19:57
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 16, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking: define an exports field for our public API
3 participants