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

Code Editor linting docs #2750

Open
wants to merge 20 commits into
base: zamoore/HDS-4361/CodeEditor-linting
Choose a base branch
from

Conversation

zamoore
Copy link
Contributor

@zamoore zamoore commented Mar 6, 2025

📌 Summary

If merged, this PR will add a section at the end of the Guidelines page for CodeEditor that describes the linting feature available to users only in the JSON language variant of the CodeEditor.

Also adds how-to-use code documentation.

🛠️ Detailed description

Brief description added. Questions for the team:

  1. Should there be images to allow designers to preview what the linting feature looks like?
  2. Is this the appropriate location for this information given its niche application in the component?

🔗 External links

Jira ticket: HDS4629
Figma file: Preview of linting

Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Mar 7, 2025 8:19pm
hds-website ✅ Ready (Inspect) Visit Preview Mar 7, 2025 8:19pm

@@ -32,6 +32,9 @@ This component uses [CodeMirror 6](https://codemirror.net/) under the hood.
<C.Property @name="hasLineWrapping" @type="boolean" @default="false">
Enables line wrapping within the editor.
</C.Property>
<C.Property @name="isLintingEnabled" @type="boolean" @default="false">
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add an example to the how to use section? Would be good to have a place where people can test it out/ and warn them again that it only works with JSON.

The Code Editor supports linting for JSON using [CodeMirror6](https://codemirror.net/examples/lint/). This feature highlights all errors with an underline and an icon next to the line number. Each icon has a tooltip explaining the error on the associated line. To view all alerts in the editor, users can open a dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).

!!! Info
This component is only available in Ember and is not supported in Figma.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This component is only available in Ember and is not supported in Figma.
Linting is only available in the Ember component and is not supported in Figma.

[Suggestion] Make banner more specific to linting so it's not taken out of context.


![](/assets/components/code-editor/codeeditor-linting-preview-tooltip.png)

When linting is enabled, the CodeEditor will have a minimum height set by default to avoid the alert dialog covering all the content within the editor when opened. The minimum height for the CodeEditor with linting is 160px. The linting alert dialog is always 80px in height.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When linting is enabled, the CodeEditor will have a minimum height set by default to avoid the alert dialog covering all the content within the editor when opened. The minimum height for the CodeEditor with linting is 160px. The linting alert dialog is always 80px in height.
When linting is enabled, the Code Editor will have a minimum height set by default to avoid the alert dialog covering all the content within the editor when opened. The minimum height for the Code Editor with linting is 160px. The linting alert dialog is always 80px in height.

[Nit] Align to how component is named elsewhere.

@@ -104,3 +104,22 @@ In **Figma** we provide a handful of example languages intended as visual exampl

If you wish to create custom examples using the Code Editor, we publish all of the relevant syntax highlighting variables in the [HDS Components v2.0](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?node-id=67166-37020&t=gWdKy44MzTP4cTRo-1) library. However, due to the number of languages supported by the component, the color variables use a generic naming schema (e.g., cyan, red, purple) to remain as agnostic as possible when being applied to different languages.
For more details around syntax, visit the [specifications](/components/code-editor?tab=specifications).

## Linting
The Code Editor supports linting for JSON using [CodeMirror6](https://codemirror.net/examples/lint/). This feature highlights all errors with an underline and an icon next to the line number. Each icon has a tooltip explaining the error on the associated line. To view all alerts in the editor, users can open a dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Code Editor supports linting for JSON using [CodeMirror6](https://codemirror.net/examples/lint/). This feature highlights all errors with an underline and an icon next to the line number. Each icon has a tooltip explaining the error on the associated line. To view all alerts in the editor, users can open a dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).
The Code Editor supports linting for JSON using [CodeMirror6](https://codemirror.net/examples/lint/). This feature highlights all errors with an underline and an icon next to the line number. Each icon has a tooltip explaining the error on the associated line. To view all alerts in the editor, open the alert dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).

[Nit] Use more active language


![](/assets/components/code-editor/codeeditor-linting-preview.png)

To view all alerts in the editor, users can open a dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To view all alerts in the editor, users can open a dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).
To view all alerts in the editor, open the alert dialog using Ctrl-Shift-m (Cmd-Shift-m on macOS).

[Nit] Use more active language


![Code Editor with linting errors. There is a dialog on top of the bottom half of the Code Editor with several alerts that can be dismissed. The dialog does not block the user from interacting with the Code Editor content.](/assets/components/code-editor/codeeditor-linting-preview-dialog.png)

If you require linting for addition languages [contact the HDS team](/about/support).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If you require linting for addition languages [contact the HDS team](/about/support).
If you require linting for additional languages, [contact the Design Systems Team](/about/support).

[Nit] Align to how we phrase this elsewhere

This component is only available in Ember and is not supported in Figma.
!!!

![](/assets/components/code-editor/codeeditor-linting-preview-tooltip.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![](/assets/components/code-editor/codeeditor-linting-preview-tooltip.png)
![Code editor with linting errors. On hover of an icon indicating an error on a line, a tooltip displays details on the linting error.](/assets/components/code-editor/codeeditor-linting-preview-tooltip.png)

[Issue] Add alt text


When linting is enabled, the CodeEditor will have a minimum height set by default to avoid the alert dialog covering all the content within the editor when opened. The minimum height for the CodeEditor with linting is 160px. The linting alert dialog is always 80px in height.

![](/assets/components/code-editor/codeeditor-linting-preview.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
![](/assets/components/code-editor/codeeditor-linting-preview.png)
![Code editor with linting errors. A red x icon is added to each line with errors, and the text of the line has a red underline.](/assets/components/code-editor/codeeditor-linting-preview.png)

[Issue] Add alt text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants