Skip to content

chore: use workspace#16

Merged
HoikanChan merged 4 commits intoopenInula:masterfrom
HoikanChan:test
Mar 18, 2025
Merged

chore: use workspace#16
HoikanChan merged 4 commits intoopenInula:masterfrom
HoikanChan:test

Conversation

@HoikanChan
Copy link
Contributor

@HoikanChan HoikanChan commented Mar 18, 2025

  • chore: remove useless blank space
  • chore: use workspace

Summary by CodeRabbit

  • Chores
    • Updated package configuration for streamlined asset distribution.
    • Removed an outdated setting to improve workspace dependency handling.
  • New Features
    • Enhanced component type safety with explicit return types.
    • Expanded JSX support, offering improved element creation and validation.
    • Made the ProviderProps interface accessible for external use.
  • Style
    • Applied minor formatting adjustments for consistency.

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2025

⚠️ No Changeset found

Latest commit: 8873d89

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

This update removes the workspace linking configuration from the .npmrc file and makes a minor formatting change in the Babel configuration. The Link component now explicitly returns an InulaElement, enhancing type clarity. The package’s build structure has been revised in package.json by updating the main entry, type definitions, export paths, and adding a publish configuration. Additionally, the element creation API in the JSX module has been extended with a new overload for functional components and improved type-checking in the validation function.

Changes

File(s) Change Summary
.npmrc Removed the link-workspace-packages = false configuration setting.
packages/inula-router/babel.config.cjs Adjusted spacing in the module.exports declaration (cosmetic formatting change).
packages/inula-router/src/router/Link.tsx Updated function signature to explicitly return InulaElement for the Link component; modified import statement to include InulaElement.
packages/inula/package.json Updated main, types, and export paths to point to built files; added a new publishConfig field.
packages/inula/src/external/JSXElement.ts Added a new overload for createElement to accept functional components; broadened type support in createElement and refined the type check in isValidElement.
packages/inula/src/types.ts Changed ProviderProps interface from local to exported, enhancing accessibility.

Sequence Diagram(s)

sequenceDiagram
  participant Developer as Developer
  participant Creator as createElement()
  participant Builder as buildElement()
  participant Validator as isValidElement()

  Developer->>Creator: Call createElement with component type and props
  Creator->>Builder: Invoke buildElement with provided arguments
  Builder-->>Creator: Return constructed InulaElement
  Developer->>Validator: Validate the created element
  Validator-->>Developer: Return true/false based on validation
Loading

Poem

Hoppity-hop through files anew,
Settings and types now shine so true.
I trimmed the whitespace and set the pace,
With built paths lighting up the space.
In code meadows, I bound with delight—
A rabbit’s cheer in every byte! 🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/inula/src/external/JSXElement.ts (2)

179-185: Updated createElement signature with improved typing

The modified createElement signature now accepts a broader range of component types and has an improved return type, enhancing type safety throughout the application.

However, the ESLint static analysis indicates a potential issue with using {} as a type.

Consider replacing {} with a more specific type:

-export function createElement<P extends {}>(
+export function createElement<P extends Record<string, any>>(
  type: FunctionComponent<P> | ComponentClass<P> | string,
  props?: (Attributes & P) | null,
  ...children: InulaNode[]
): InulaElement<P> {
  return buildElement(false, type, props, children);
}
🧰 Tools
🪛 ESLint

[error] 179-179: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)


228-230: Type improvement for isValidElement function

The updated parameter type and implementation of isValidElement improve type checking, but there's a potential issue with using {} as a type parameter.

Consider replacing {} with a more specific type according to ESLint suggestions:

-export function isValidElement<P>(element: {} | null | undefined): element is InulaElement<P> {
+export function isValidElement<P>(element: unknown): element is InulaElement<P> {
  return typeof element === 'object' && element !== null && 'vtype' in element && element.vtype === TYPE_COMMON_ELEMENT;
}

Using unknown is more appropriate here as you're performing type checking on the parameter.

🧰 Tools
🪛 ESLint

[error] 228-228: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a39c0ec and cc24868.

📒 Files selected for processing (5)
  • .npmrc (0 hunks)
  • packages/inula-router/babel.config.cjs (1 hunks)
  • packages/inula-router/src/router/Link.tsx (1 hunks)
  • packages/inula/package.json (2 hunks)
  • packages/inula/src/external/JSXElement.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • .npmrc
🧰 Additional context used
🪛 ESLint
packages/inula/src/external/JSXElement.ts

[error] 179-179: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)


[error] 228-228: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)

🔇 Additional comments (4)
packages/inula-router/babel.config.cjs (1)

16-16: Whitespace Formatting Improvement.

The adjustment in spacing around the assignment operator in the module.exports declaration improves consistency and readability without affecting functionality.

packages/inula-router/src/router/Link.tsx (1)

39-39: Type safety improvement

Adding an explicit return type :JSX.Element to the Link component enhances type safety and makes the component's contract clearer, which is a good practice.

packages/inula/package.json (1)

11-11: Build structure improvements

The package configuration has been updated to use the workspace build system correctly. This change properly structures the package by:

  1. Pointing the main entry to the built files instead of source files
  2. Adding publishConfig to specify the build directory
  3. Updating type definitions path
  4. Correcting export paths to point to the built files

These changes will help with more consistent builds and deployments.

Also applies to: 16-18, 29-37

packages/inula/src/external/JSXElement.ts (1)

28-28: Enhanced support for functional components

Adding support for FunctionComponent<P> and creating a dedicated overload for it improves the type safety and clarity when working with functional components.

Also applies to: 160-165

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2025

Open in Stackblitz

create-inula

npm i https://pkg.pr.new/openInula/inula/create-inula@16

inula-cli

npm i https://pkg.pr.new/openInula/inula/inula-cli@16

openinula

npm i https://pkg.pr.new/openInula/inula/openinula@16

inula-intl

npm i https://pkg.pr.new/openInula/inula/inula-intl@16

inula-dev-tools

npm i https://pkg.pr.new/openInula/inula/inula-dev-tools@16

inula-request

npm i https://pkg.pr.new/openInula/inula/inula-request@16

inula-router

npm i https://pkg.pr.new/openInula/inula/inula-router@16

commit: 8873d89

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0b2f18 and 8873d89.

📒 Files selected for processing (2)
  • packages/inula-router/src/router/Link.tsx (2 hunks)
  • packages/inula/src/external/JSXElement.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/inula-router/src/router/Link.tsx
🧰 Additional context used
🪛 ESLint
packages/inula/src/external/JSXElement.ts

[error] 230-230: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)

🔇 Additional comments (4)
packages/inula/src/external/JSXElement.ts (4)

28-28: LGTM: Necessary import addition

Adding FunctionComponent to the import list is necessary to support the new function component overload.


160-164: Good addition: Enhances type safety for function components

Adding a specific overload for function components provides better type safety and IDE support when creating elements from functional components. This ensures the TypeScript compiler can select the most appropriate overload based on the arguments provided.


178-182: LGTM: Appropriate type updates

This update correctly expands the accepted types to include function components, class components, and string literals (for HTML tags), making the API more flexible while maintaining type safety.


231-231: LGTM: Implementation correctly checks element type

The implementation correctly verifies that the element is an object, is not null, and has the expected vtype property with the correct value.

// 检测结构体是否为合法的Element
export function isValidElement<P>(element: KVObject | null | undefined): element is InulaElement<P> {
return !!(element && element.vtype === TYPE_COMMON_ELEMENT);
export function isValidElement<P>(element: {} | null | undefined): element is InulaElement<P> {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid using {} as a type

The {} type actually means "any non-nullish value" rather than "any object" as is often assumed. This can lead to subtle type checking issues.

Consider replacing {} with one of the following alternatives:

  • Use object if you want to accept any object
  • Use Record<string, any> if you want an object with string keys and any values
  • Use unknown if you want to accept any value and perform type checking
-export function isValidElement<P>(element: {} | null | undefined): element is InulaElement<P> {
+export function isValidElement<P>(element: object | null | undefined): element is InulaElement<P> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function isValidElement<P>(element: {} | null | undefined): element is InulaElement<P> {
export function isValidElement<P>(element: object | null | undefined): element is InulaElement<P> {
🧰 Tools
🪛 ESLint

[error] 230-230: Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.

(@typescript-eslint/ban-types)

@HoikanChan HoikanChan merged commit b9b9182 into openInula:master Mar 18, 2025
5 checks passed
@HoikanChan HoikanChan deleted the test branch March 18, 2025 09:01
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