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

feat: Type checking for all APIs and rules #103

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

feat: Type checking for all APIs and rules #103

wants to merge 7 commits into from

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Apr 2, 2025

Prerequisites checklist

What is the purpose of this pull request?

Enable type checking for the plugin.

What changes did you make? (Give an overview)

  • Added type definitions to match @eslint/json
  • Added type definitions for each rule
  • Updated @eslint/css-tree

Related Issues

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

Right now, Rollup is removing the type definitions for no-invalid-at-rules and no-invalid-properties. I can't quite figure out why that is. I could use some help with this.

@fasttime
Copy link
Member

fasttime commented Apr 3, 2025

Right now, Rollup is removing the type definitions for no-invalid-at-rules and no-invalid-properties. I can't quite figure out why that is. I could use some help with this.

Probably in both cases Rollup thinks that the JSDoc comments under "Type Definitions" are part of the next statement, i.e. import { isSyntaxMatchError } from "../util.js";, and since those statements are removed from the bundle, so the comments are also removed. One possible workaround is moving the "Type Definitions" section just above "RuleDefinition":

//-----------------------------------------------------------------------------
// Type Definitions
//-----------------------------------------------------------------------------

/**
 * @import { AtrulePlain } from "@eslint/css-tree"
 * @import { CSSRuleDefinition } from "../types.js"
 * @typedef {"unknownAtRule" | "invalidPrelude" | "unknownDescriptor" | "invalidDescriptor" | "invalidExtraPrelude" | "missingPrelude"} NoInvalidAtRulesMessageIds
 * @typedef {CSSRuleDefinition<{ RuleOptions: [], MessageIds: NoInvalidAtRulesMessageIds }>} NoInvalidAtRulesRuleDefinition
 */

//-----------------------------------------------------------------------------
// Rule Definition
//-----------------------------------------------------------------------------

@fasttime fasttime moved this from Needs Triage to Triaging in Triage Apr 3, 2025
@fasttime fasttime moved this from Triaging to Implementing in Triage Apr 3, 2025
@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 3, 2025
@nzakas
Copy link
Member Author

nzakas commented Apr 3, 2025

Ah, that is brilliant! Thanks!

@nzakas
Copy link
Member Author

nzakas commented Apr 3, 2025

Tests are failing due to this: eslint/csstree#27

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.

The CI build is now failing on the "Verify JSR Publish" job. It looks like "dist/esm/types.ts" is missing in the list of included files in jsr.json:

css/jsr.json

Lines 9 to 17 in 2519f4e

"include": [
"dist/esm/index.js",
"dist/esm/index.d.ts",
"dist/esm/syntax/index.js",
"dist/esm/syntax/index.d.ts",
"README.md",
"jsr.json",
"LICENSE"
]

@nzakas
Copy link
Member Author

nzakas commented Apr 9, 2025

Thanks!

@fasttime fasttime requested a review from Copilot April 10, 2025 12:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 17 out of 19 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • jsr.json: Language not supported
  • package.json: Language not supported
Comments suppressed due to low confidence (2)

src/rules/use-baseline.js:495

  • The repeated inline conversion of baselineAvailability.availability using String() suggests an underlying type mismatch. Consider revising the type of baselineAvailability.availability upstream so that it already has the expected string type.
availability: baselineAvailability.availability,

rollup.config.js:25

  • [nitpick] Please verify that using the ".cts" extension for the CommonJS type definitions aligns with project conventions and tooling expectations.
rename: "types.cts",

nzakas and others added 3 commits April 10, 2025 11:10
Co-authored-by: Francesco Trotta <[email protected]>
Co-authored-by: Francesco Trotta <[email protected]>
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! I would like another review.

@fasttime fasttime moved this from Implementing to Second Review Needed in Triage Apr 11, 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 feature
Projects
Status: Second Review Needed
Development

Successfully merging this pull request may close these issues.

2 participants