Skip to content

fix: remove redundant Comment member from CSSSyntaxElement union #119

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

Merged
merged 3 commits into from
Apr 28, 2025

Conversation

louis-young-slice
Copy link
Contributor

@louis-young-slice louis-young-slice commented Apr 25, 2025

Prerequisites checklist

What is the purpose of this pull request?

To resolve #118.

What changes did you make? (Give an overview)

  • Remove Comment from the CSSSyntaxElement union.
  • Explicitly specify the lib TypeScript compiler option.
    • Remove the default inherited type definitions from the project by aligning lib with target, making the type environment stricter, and verifying that the previous fix resolves the intended issue by surfacing related errors via the type tests. See: https://www.typescriptlang.org/tsconfig/#lib.

Related Issues

Fixes #118.

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

N/A.

Copy link

linux-foundation-easycla bot commented Apr 25, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Apr 25, 2025
@eslint-github-bot
Copy link

Hi @louis-young-slice!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

1 similar comment
@eslint-github-bot
Copy link

Hi @louis-young-slice!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@louis-young-slice louis-young-slice changed the title fix(types): add missing Comment type import fix: add missing Comment type import Apr 25, 2025
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Apr 25, 2025
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.

Thanks so much for tracking this down. Is there a way to can automate checking this?

We have types.test.ts for our type checking. Is there a way to modify that or the tsconfig in that directory to verify this fixes the problem?

@fasttime
Copy link
Member

We could probably exclude the DOM library in tsconfig.json in the project root, since that library is not used in this project. That would be adding "lib": ["ES2022"] to the TypeScript compiler options. The type tests (npx run test:types) will then fail if any DOM types are inadvertently used. We have a similar setting in eslint-visitor-keys.

@louis-young-slice
Copy link
Contributor Author

Thanks so much for tracking this down.

My pleasure. Thank you for creating and maintaining one of the most helpful tools in the ecosystem.

Is there a way to automate checking this? We have types.test.ts for our type checking. Is there a way to modify that or the tsconfig in that directory to verify this fixes the problem?

Absolutely; there's a simple way to update the project's TypeScript configuration to verify that this pull request resolves the issue.

Generally, it's best to expose as few global types as possible. As @fasttime said, updating the lib compiler option to only include type definitions for "ES2022" - matching the target JavaScript language version - will cause this error (and those of the same nature) to surface via the type tests.

Since the project uses a composite TypeScript configuration (multiple configurations extending a shared base configuration), and none of them currently override lib, setting lib in the root tsconfig.json will be sufficient to apply the change project-wide.

- Remove the default inherited type definitions from the project by aligning `lib` with `target`, making the type environment stricter, and verifying that the previous fix resolves the intended issue by surfacing related errors via the type tests. See: https://www.typescriptlang.org/tsconfig/#lib.
- The `CssNodePlain` type is a union that includes `Comment` as a member, making it redundant in the `CSSSyntaxElement` union.
@louis-young-slice
Copy link
Contributor Author

Now that I’m not rushing around at 6pm on a Friday evening, I’ve had another look and realised that CssNodePlain is a union that includes Comment as a member, making it redundant in the CSSSyntaxElement union. To resolve this, I’ve removed Comment from the CSSSyntaxElement union and left it as an alias for CssNodePlain.

@louis-young-slice louis-young-slice changed the title fix: add missing Comment type import fix: remove redundant Comment member from CSSSyntaxElement union Apr 26, 2025
@fasttime fasttime moved this from Needs Triage to Triaging in Triage Apr 27, 2025
@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 27, 2025
@fasttime fasttime moved this from Triaging to Implementing in Triage Apr 27, 2025
Copy link
Member

@fasttime fasttime 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! Leaving open for @nzakas to verify before merging.

@fasttime fasttime moved this from Implementing to Second Review Needed in Triage Apr 27, 2025
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.

Nice work catching that! LGTM. Thanks.

@nzakas nzakas merged commit 67f3d4e into eslint:main Apr 28, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug Something isn't working contributor pool
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Bug: Cannot find name 'Comment'.
3 participants