-
-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: selector() API implement #236
#246
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@mincho-js/css": minor | ||
| --- | ||
|
|
||
| **css** | ||
|
|
||
| ### New | ||
| - Add `selector()` utility for computed property names |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| --- | ||
| "@mincho-js/css": patch | ||
| "@mincho-js/css": minor | ||
| --- | ||
|
|
||
| **rules** | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -238,6 +238,11 @@ function processMultiple<T>( | |||||||||||||||||||||||
| export function mincho$<T>(block: () => T) { | ||||||||||||||||||||||||
| return block(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export function selector(selector: string): `&` { | ||||||||||||||||||||||||
|
Comment on lines
+241
to
+242
|
||||||||||||||||||||||||
| export function selector(selector: string): `&` { | |
| /** | |
| * Accepts a selector string that must contain '&' and returns it as a template literal type. | |
| * Throws an error if the selector does not contain '&'. | |
| */ | |
| export function selector(selector: string): `&` { | |
| if (!selector.includes('&')) { | |
| throw new Error("Selector must contain '&'. Received: " + selector); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add JSDoc documentation for public API.
The selector() function is part of the public API but lacks documentation explaining its purpose, usage, and expected input format.
Add documentation like:
+/**
+ * Type utility that marks a selector string for use as a computed property name.
+ * Enables proper TypeScript inference when using selectors as object keys.
+ *
+ * @param selector - A CSS selector string (e.g., ".otherClass &", "&:hover")
+ * @returns The selector string, typed as `&` for TypeScript inference
+ *
+ * @example
+ * ```ts
+ * css({
+ * [selector(".otherClass &")]: {
+ * color: "red"
+ * }
+ * });
+ * ```
+ */
export function selector(selector: string): `&` {
return selector as `&`;
}🤖 Prompt for AI Agents
In packages/css/src/css/index.ts around lines 242 to 244, the public API
function selector lacks JSDoc; add a concise JSDoc block immediately above the
function that explains its purpose (marks a string as a nested selector
reference `&` for use in css() objects), describes the expected input format (a
selector string that contains `&`, e.g. ".otherClass &"), documents the
parameter and return type, and includes a short usage example showing css({
[selector(".otherClass &")]: { color: "red" } }); so consumers understand how to
use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
selectorfunction lacks JSDoc documentation. Consider adding documentation to explain its purpose, expected input format, and usage example as shown in the PR description.