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

Add links to terminal output #5835

Merged
merged 7 commits into from Jan 22, 2022
Merged

Add links to terminal output #5835

merged 7 commits into from Jan 22, 2022

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Jan 14, 2022

Which issue, if any, is this issue related to?

Closes #3823

Is there anything in the PR that needs further explanation?

This change outputs links of files or rule URLs on terminal via the terminal-link package.
The string and verbose formatters are only supported.

Note that it is needed to install terminal-link@2 because terminal-link@3 is pure ESM:

npm i terminal-link@2

See also https://github.com/sindresorhus/terminal-link

Demo

On my local machine's terminal (macOS; iTerm2):

Screen.Recording.2022-01-15.at.3.43.39.mov

@ybiquitous ybiquitous marked this pull request as ready for review January 14, 2022 18:47
This change outputs links of files or rule URLs on terminal via the `terminal-link` package.
The `string` and `verbose` formatters are only supported.

Note that it is needed to install `terminal-link@2` because `terminal-link@3` is pure ESM:

```shell
npm i terminal-link@2
```

See also <https://github.com/sindresorhus/terminal-link>
// Plugin rules are unsupported.
if (rule.includes('/')) {
return rule;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] It is a bit disappointing not to support plugin rules.
We may need to add a rule’s metadata (rule doc URL etc.) in the future. 🤔
(but out of the scope of this PR)

See https://eslint.org/docs/developer-guide/working-with-rules#rule-basics

Copy link
Member Author

Choose a reason for hiding this comment

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

I've opened a new issue #5842 to discuss rule metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could use meta.url if #5845 would be merged.

@jeddy3 jeddy3 changed the title Output links on terminal Add links to terminal output Jan 17, 2022
@@ -0,0 +1,8 @@
declare module 'supports-hyperlinks' {
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] supports-hyperlinks doesn't have type definitions (even on @types/).

https://www.npmjs.com/package/supports-hyperlinks

Copy link
Member

Choose a reason for hiding this comment

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

Curious, is this something that would be helpful to contribute upstream? Looking at the package, it doesn't seem too complicated - maybe I can give it a shot?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mattxwang That would be great! 👍🏼

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good - I can try to take a crack at it next weekend; probably shouldn't prevent this PR from being merged!

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this may have been resolved with jamestalmage/supports-hyperlinks#21?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mattxwang Thanks for sharing the news! We can delete our custom type definitions with supports-hyperlinks@3.0.0.

@ybiquitous
Copy link
Member Author

Thanks for the feedback! Ready to review. 🙆🏼‍♂️

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Really good stuff!

I've requested a very minor formatting change.

lib/formatters/__tests__/verboseFormatter.test.js Outdated Show resolved Hide resolved
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jeddy3 jeddy3 mentioned this pull request Jan 20, 2022
6 tasks
@jeddy3 jeddy3 merged commit 8542097 into main Jan 22, 2022
@jeddy3 jeddy3 deleted the terminal-links branch January 22, 2022 11:12
@jeddy3
Copy link
Member

jeddy3 commented Jan 22, 2022

  • Added: hyperlinks to terminate output (#5835).

@ybiquitous
Copy link
Member Author

@jeddy3 This might be a typo? (Please ignore it if not a typo)

-to terminate output
+to terminal output

- Added: hyperlinks to terminate output ([#5835](https://github.com/stylelint/stylelint/pull/5835)).

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

Successfully merging this pull request may close these issues.

Add link to the online docs in formatter output
4 participants