feat: link rule IDs to docs URLs in stylish formatter - #151
Conversation
There was a problem hiding this comment.
Thanks for the RFC @Norbiros. Can you clarify what happens when FORCE_HYPERLINK=1 is set and stdout is not a TTY terminal?
| - `json` and `json-with-metadata` are machine-readable; `json-with-metadata` already exposes rule metadata. | ||
| - `html` already links rule IDs using anchors. | ||
|
|
||
| Nothing in this design prevents a follow-up from applying the same helper to another formatter, and the support-detection helper should be written so it can be reused. |
There was a problem hiding this comment.
The helper is internal. That means only other built-in formatters will be able to reuse it?
|
|
||
| Hyperlink support is decided once per formatter invocation. `FORCE_HYPERLINK` takes precedence: `0` and `false` disable links, while any other value enables them, including for piped or redirected output. The name and semantics follow `supports-hyperlinks`, `terminal-link`, and the established `FORCE_COLOR` convention. | ||
|
|
||
| Without the environment variable, hyperlinks are disabled in v10. In v11, the CLI enables them only when stdout is a TTY and `--output-file` is not set. It passes this decision to the formatter through an internal context field so the formatter does not mistake a file for terminal output. Programmatic formatter use remains default-off because ESLint cannot know where the returned string will be written; consumers can opt in with `FORCE_HYPERLINK`. |
There was a problem hiding this comment.
I think the discussion would be easier if you could clearly separate the v10 changes from the changes planned for v11, and use a separate section to note the similarities and differences.
nzakas
left a comment
There was a problem hiding this comment.
This RFC reads like it was written by AI. Can you clarify if it was?
| - In ESLint v10, hyperlinks are opt-in and are emitted only when the `FORCE_HYPERLINK` env variable is set. | ||
| - In ESLint v11, hyperlinks are emitted by default when ESLint is writing to a terminal, and users can opt out with `FORCE_HYPERLINK=0`. |
There was a problem hiding this comment.
It seems like we should use a feature flag for this?
https://eslint.org/docs/latest/flags/
|
@Norbiros are you still working on this? There are several review suggestions, could you take a look? |
Summary
This RFC proposes adding clickable rule documentation links to ESLint’s stylish formatter using OSC 8 terminal hyperlinks. Links are opt-in via
FORCE_HYPERLINKin ESLint v10 and enabled by default for terminal output in v11, with an option to disable them. The visible output remains unchanged.Related Issues
eslint/eslint#21073