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

[feat/discussion] allow an option to get rule meta data for lintText #590

Closed
spence-s opened this issue Aug 11, 2021 · 4 comments
Closed

Comments

@spence-s
Copy link
Contributor

I was looking into making diagnostics in the vscode extension link to the rule documentation, if available, in the UI. This is accomplished via the engine.getRulesMetaForResults method and is most likely best done in the lintText/lintFiles methods.

After taking a look the simplest way to accomplish this for lintText may something like a very simple 1-2 liner:

if(inputOptions.meta)
	report.rulesMeta = engine.getRulesMetaForResults(report)

I didn't dig too deep into lintFiles, it looks like it'd be more complex, but I'm not sure if it's something we'd even want from the CLI perspective. For my use case here, I would only need it on lintText results.

@sindresorhus
Copy link
Member

Alternatively, we could just expose getRulesMetaForResults as a method on XO and you could pass the result from lintText?

@spence-s
Copy link
Contributor Author

We could...the only issue with that is that it is less efficient, in that to do that you'd need to gather up the options 2x and instantiate eslint again separate from the eslint instance that creates the report. I think cosmic config caches everything so it shouldn't be much overhead? That would be my only worry.

@sindresorhus If you let me know which method you'd prefer. I'd be glad to submit a PR for this when I get the time.

@sindresorhus
Copy link
Member

Let's go with what you proposed. Sounds better.

@spence-s
Copy link
Contributor Author

decided that there isn't an explicit need for this in xo, since xo generates links with this package, via the pretty formatter. https://www.npmjs.com/package/eslint-rule-docs - which I am also now using in the extension for the same purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants