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

small changes in DocType of languages and formatting #4042

Open
wants to merge 97 commits into
base: main
Choose a base branch
from

Conversation

BhJaipal
Copy link

Changes

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

src/highlight.js Outdated
@@ -25,7 +25,7 @@ import HTMLInjectionError from "./lib/html_injection_error.js";
@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin
@typedef {import('highlight.js').PluginEvent} PluginEvent
@typedef {import('highlight.js').HLJSOptions} HLJSOptions
@typedef {import('highlight.js').LanguageFn} LanguageFn
@typedef {import('highlight.js').LanguageFn} {import("highlight.js").LanguageFn}
Copy link
Member

Choose a reason for hiding this comment

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

What makes LanguageFn different from all the other types listed here?

Copy link
Author

@BhJaipal BhJaipal Apr 24, 2024

Choose a reason for hiding this comment

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

LanguageFn is type of this function that takes HLJSApi type parameter and returns Language type output

But in DocCommets it wasn't used correctly

/** @type LanguageFn */

It doesn't assign the LanguageFn type to it

So, it should be changed to

/** 
 * @type {import("highlight.js").LanguageFn} 
 */

It will import all types from highlight.js and then we select LanguageFn type from it and assign it to function to assign type in DocComments, type must be put between {} after @type

Copy link
Author

Choose a reason for hiding this comment

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

What makes LanguageFn different from all the other types listed here?

It was his type
I didn't do anything more, I just correctly type assignment

Copy link
Member

Choose a reason for hiding this comment

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

The whole point of @typedef {import('highlight.js').LanguageFn} LanguageFn should be to allow us to use the short names later on in the file - otherwise what's the point in typedef?

Copy link
Author

Choose a reason for hiding this comment

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

Understood

Copy link
Author

Choose a reason for hiding this comment

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

The whole point of @typedef {import('highlight.js').LanguageFn} LanguageFn should be to allow us to use the short names later on in the file - otherwise what's the point in typedef?

I have updated everything as you asked

@@ -6,8 +6,8 @@ Category: syntax
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
/** @type {LanguageFn} */
Copy link
Member

Choose a reason for hiding this comment

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

I'll need to glance at the docs, but this looks much more acceptable. But please remove all your other linting changes.

Copy link
Author

Choose a reason for hiding this comment

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

I'll need to glance at the docs, but this looks much more acceptable. But please remove all your other linting changes.

Ok

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

Successfully merging this pull request may close these issues.

None yet

2 participants