Skip to content

feat: Type checking for all APIs and rules#103

Merged
mdjermanovic merged 7 commits into
mainfrom
types
Apr 13, 2025
Merged

feat: Type checking for all APIs and rules#103
mdjermanovic merged 7 commits into
mainfrom
types

Conversation

@nzakas

@nzakas nzakas commented Apr 2, 2025

Copy link
Copy Markdown
Member

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

fasttime commented Apr 3, 2025

Copy link
Copy Markdown
Member

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

nzakas commented Apr 3, 2025

Copy link
Copy Markdown
Member Author

Ah, that is brilliant! Thanks!

@nzakas

nzakas commented Apr 3, 2025

Copy link
Copy Markdown
Member Author

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

@fasttime fasttime left a comment

Copy link
Copy Markdown
Member

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

nzakas commented Apr 9, 2025

Copy link
Copy Markdown
Member Author

Thanks!

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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",

Comment thread tests/types/cjs-import.test.cts
Comment thread tests/types/types.test.ts
Comment thread src/types.ts Outdated
Comment thread src/types.ts Outdated
nzakas and others added 3 commits April 10, 2025 11:10
Co-authored-by: Francesco Trotta <github@fasttime.org>
Co-authored-by: Francesco Trotta <github@fasttime.org>

@fasttime fasttime left a comment

Copy link
Copy Markdown
Member

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

@mdjermanovic mdjermanovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 809ea4c into main Apr 13, 2025
@mdjermanovic mdjermanovic deleted the types branch April 13, 2025 09:50
@github-project-automation github-project-automation Bot moved this from Second Review Needed to Complete in Triage Apr 13, 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: Complete

Development

Successfully merging this pull request may close these issues.

4 participants