question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Add URL for a rule's documentation to the API

See original GitHub issue

The version of ESLint you are using.

4.12.1

The problem you want to solve

AtomLinter has a neat feature that links to the documentation for each rule.

Atom screenshot showing link

In order for that link to work in plugins, the plugin needs to be registered in AtomLinter.

Your take on the correct solution to problem

Instead of AtomLinter having to maintain a list of known plugins (and other clients having to duplicate the effort) it would be great if the API could allow a rule to specify where its documentation can be found.

It boils down to:

  1. Exposing a rule’s meta object via the API (which is a one-liner though several test fixtures are affected).
  2. Establishing an optional convention of putting the URL describing a rule in docs.uri / docs.url.
  3. Adding a URL to the meta for each of the built-in rules.

Original proposal which worked at the plugin level rather than the rule level.

module.exports = {
    rules: {
        ...
    },
    ...

    // New property
    getDocURI: function (ruleName) { 
       return `https://myplugin.com/docs/${ruleName}.md`
    }
};

The URL would be exposed to the Node API via the response from the verify() method.

{
    fatal: false,
    ruleId: "semi",
    severity: 2,
    line: 1,
    column: 23,
    message: "Expected a semicolon.",
    fix: {
        range: [1, 15],
        text: ";"
    },
    docURI:  "http://eslint.org/docs/rules/semi" // <-- New property
}

I’ve implemented the change in ESLint. I’m waiting for the proposal to be accepted so I can open a PR. If it’s accepted I’m happy to do the corresponding update for AtomLinter as well.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:49 (43 by maintainers)

github_iconTop GitHub Comments

4reactions
platinumazurecommented, Aug 14, 2017

Okay, I commented on this long ago and then never followed up- sorry.

I’m 👍 to using a property in rule metadata for this. If someone wanted to expose URLs in the plugin definition file, they could do so by requiring the rule and getting the URI from its metadata. So I withdraw any objection I might have raised earlier.

I think TSC needs to review a proposal before this can be accepted. I could write up a summary in a day or two, but if someone beats me to it, all the better.

4reactions
ilyavolodincommented, Jan 8, 2017

Meta object has been added to all core rules. We also now have API to retrieve metadata (and rules). I still think it would be nice to add metadata to the report object. So that would be the last thing that would need to be added. I can champion this proposal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rule Examples: API URLs | Platform
Description: Server URL must be lowercase. Format (Optional): oas3.x; Target: With the Stoplight Style Guide enabled, select API > Server> URL or add...
Read more >
How to Write API Documentation: Best Practices and ...
Today we will talk about how to foster positive developer experience in the API documentation. But first, we need to understand what makes ......
Read more >
How to Write Good API Documentation
Tutorials​​ This is the primary part of the documentation. It should include the different content formats you are using to explain the concept ......
Read more >
API documentation proposal · WebPlatform Docs
This proposal outlines a strategy for building out the API documentation, ... The API_Listing page has instructions for (or a link to the...
Read more >
Automation and MISP API
The documentation will include a default MISP URL in the examples. ... PyMISP allows you to fetch events, add or update events/attributes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found