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: make types usable in CommonJS #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: make types usable in CommonJS #44

wants to merge 1 commit into from

Conversation

fasttime
Copy link
Member

Prerequisites checklist

What is the purpose of this pull request?

Similar to eslint/rewrite#143 and eslint/json#77, this PR ensures that the @eslint/css types can be imported from a CommonJS module when moduleResolution is one of 'node16' or 'nodenext'. This is currently not possible because of an issue with the types in @eslint/plugin-kit that has been fixed in the latest version v0.2.5.

What changes did you make? (Give an overview)

  • Updated dependency @eslint/plugin-kit to version spec "^0.2.5".
  • Made @eslint/core a runtime dependency of this package.
  • Added @types/css-tree as a runtime dependency.
  • Added tests to ensure that @eslint/css can be imported from a .cts file.

Related Issues

refs eslint/rewrite#143, refs eslint/json#77.

Is there anything you'd like reviewers to focus on?

"@eslint/plugin-kit": "^0.2.3",
"@eslint/core": "^0.10.0",
"@eslint/plugin-kit": "^0.2.5",
"@types/css-tree": "^2.3.10",
Copy link
Member Author

Choose a reason for hiding this comment

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

The generated dist files dist/cjs/index.d.cts and dist/esm/index.d.ts contain type imports from css-tree, for example:

export type CssNode = import("css-tree").CssNode;

css-tree does not contain built-in types, so it seems good to add a dependency on the types package. If we don't want to add a runtime dependency I think we should at least keep @types/css-tree in the devDependencies so that the types test can validate our own types against the css-tree types.

@fasttime fasttime marked this pull request as ready for review January 14, 2025 18:03
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.

1 participant