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

fix: add type tests #305

Merged
merged 1 commit into from
Nov 25, 2024
Merged

fix: add type tests #305

merged 1 commit into from
Nov 25, 2024

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Nov 25, 2024

Because of type inference issues, only the languages property is currently included in the definitions for plugin:

/** @type {Plugin & { languages: Record<string,Language>}} */
declare const plugin: Plugin & {
    languages: Record<string, Language>;
};

from https://unpkg.com/@eslint/markdown@6.2.1/dist/esm/index.d.ts

This PR refactors the plugin definition to ensure that all relevant properties of language plugins are included in the types. I also added type tests similar to eslint/json#61.

};

// @ts-expect-error
recommendedPlugins.markdown = processorPlugins.markdown = plugin;
Copy link
Member Author

Choose a reason for hiding this comment

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

Using variables instead of plugin.configs.recommended[0] and plugin.configs.processor[0] so we don't have to care if the order/structure of those config arrays changes.

@fasttime fasttime marked this pull request as ready for review November 25, 2024 06:30
Copy link
Member

@nzakas nzakas 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.

@nzakas nzakas merged commit ea60127 into main Nov 25, 2024
15 checks passed
@nzakas nzakas deleted the test-types branch November 25, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants