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

adds index.d.ts file next to index.cjs file #27

Conversation

DaveMBush
Copy link
Owner

@DaveMBush DaveMBush commented Dec 28, 2024

Issue Number: #26

Body

Adds in missing d.ts file

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated build configuration for the eslint-plugin-rxjs package
    • Improved module export and TypeScript compatibility
  • New Features

    • Enhanced package module resolution settings
    • Added linting scripts for improved code quality
  • Refactor

    • Migrated from CommonJS to ES Module export syntax
    • Updated build and project configuration scripts

@DaveMBush DaveMBush linked an issue Dec 28, 2024 that may be closed by this pull request
Copy link

coderabbitai bot commented Dec 28, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces modifications to the @eslint-plugin-rxjs package, focusing on enhancing the build process and module compatibility. Changes include the addition of linting scripts in package.json, updates to the package's dependencies and export configurations, renaming and restructuring of build targets in the project configuration, transitioning from CommonJS to ES Module exports, and adjustments to TypeScript compiler options for improved module resolution.

Changes

File Change Summary
package.json Added linting scripts: "lint": "nx affected:lint" and "lint:fix": "nx affected:lint --fix"
packages/eslint-plugin-rxjs/package.json Added types and exports fields; added dependency @angular-eslint/test-utils version 19.0.2
packages/eslint-plugin-rxjs/project.json Renamed "build" to "build-lib", added new "build" target, updated outputs to array syntax
packages/eslint-plugin-rxjs/src/index.ts Switched from CommonJS to ES Module export syntax
packages/eslint-plugin-rxjs/tsconfig.lib.json Added module and moduleResolution set to "NodeNext"

Poem

🐰 Hop, skip, and build with glee,
Linting scripts for you and me!
Exports shine, and types align,
A plugin's path, so clear, divine.
With every change, we leap and bound,
In CodeRabbit's world, joy is found! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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

nx-cloud bot commented Dec 28, 2024

View your CI Pipeline Execution ↗ for commit 154144c.

Command Status Duration Result
nx affected -t lint test build ✅ Succeeded 1m 32s View ↗

☁️ Nx Cloud last updated this comment at 2024-12-28 22:07:43 UTC

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/eslint-plugin-rxjs/project.json (2)

28-35: Simplify and strengthen the build command

While the command achieves the goal of placing index.d.ts next to index.cjs, it could be more robust.

Consider this improved command:

-        "command": "echo 'Copying types...' && cp dist/packages/eslint-plugin-rxjs/src/index.d.ts dist/packages/eslint-plugin-rxjs"
+        "command": "cp -f dist/packages/eslint-plugin-rxjs/src/index.d.ts dist/packages/eslint-plugin-rxjs/"

The -f flag ensures the command won't fail if the file already exists, and removing the echo makes the command more concise.


48-50: Consider expanding lint patterns for TypeScript files

The current lint patterns only include package.json, but for a TypeScript project, you might want to include .ts and .d.ts files as well.

Consider expanding the patterns:

         "lintFilePatterns": [
-          "packages/eslint-plugin-rxjs/package.json"
+          "packages/eslint-plugin-rxjs/package.json",
+          "packages/eslint-plugin-rxjs/**/*.ts",
+          "packages/eslint-plugin-rxjs/**/*.d.ts"
         ]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 065f679 and 1f3c914.

📒 Files selected for processing (5)
  • package.json (1 hunks)
  • packages/eslint-plugin-rxjs/package.json (1 hunks)
  • packages/eslint-plugin-rxjs/project.json (2 hunks)
  • packages/eslint-plugin-rxjs/src/index.ts (1 hunks)
  • packages/eslint-plugin-rxjs/tsconfig.lib.json (1 hunks)
🔇 Additional comments (6)
packages/eslint-plugin-rxjs/src/index.ts (1)

119-119: Confirm ES module usage consistency.

Switching to export default plugin; transitions the file to ES modules. Verify that all consumers still import the plugin correctly and that this aligns with the type: "commonjs" setting in the package.json. If your consumers use require(), they might need an interop flag or a different import style.

packages/eslint-plugin-rxjs/tsconfig.lib.json (1)

6-8: Validate NodeNext configuration compatibility.

Setting "module": "NodeNext" and "moduleResolution": "NodeNext" properly enables ES module support in Node.js environments. Confirm that downstream tooling and Node versions used in your build and runtime environments are compatible with NodeNext. Older Node versions might not fully support this approach.

packages/eslint-plugin-rxjs/package.json (1)

28-35: Ensure exports object meets all module consumer needs.

You have a "main" pointing to "./index.cjs" and an "exports" field with "require" and "types". Consider whether ESM users should also have an "import" entry or if a single CJS export is the intended usage. Verify this covers the consumption patterns you expect for your library, especially since index.ts is now using ES module syntax internally.

package.json (1)

6-6: Evaluate skipping Nx cache.

Using --skip-nx-cache may prevent using incremental builds and affect performance. Verify that skipping the cache is desired, as it can lead to slower build times. If the skip is only necessary under certain circumstances, consider restricting it to those scenarios instead of making it the default behavior.

packages/eslint-plugin-rxjs/project.json (2)

Line range hint 7-57: Verify the complete build pipeline for TypeScript declarations

The configuration looks correct for generating and placing TypeScript declarations. Let's verify the complete setup:

✅ Verification successful

TypeScript declarations setup is properly configured

The verification confirms that the build pipeline for TypeScript declarations is correctly set up:

  • The package.json has proper TypeScript configuration:
    • "types": "./index.d.ts" is correctly specified
    • exports field properly maps types via "types": "./index.d.ts"
  • The source index.ts exists and exports the necessary components
  • The build configuration in project.json correctly:
    • Generates declarations with "dts": true
    • Copies the generated declarations to the right location
    • Bundles with proper format "cjs"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the complete TypeScript declaration setup

# Check if package.json has proper type definitions configured
echo "Checking package.json type definitions configuration..."
cat packages/eslint-plugin-rxjs/package.json | jq 'select(.types, .typings, .exports.".")'

# Ensure source index.ts exists and exports properly
echo "Checking source index.ts exports..."
if [ -f "packages/eslint-plugin-rxjs/src/index.ts" ]; then
    head -n 10 packages/eslint-plugin-rxjs/src/index.ts
fi

Length of output: 2371


7-27: Build configuration looks good and aligns with TypeScript declaration goals!

The build-lib target is well configured with:

  • TypeScript declarations enabled via dts: true
  • Proper bundling setup for distribution
  • Correct CJS format specification

Let's verify the TypeScript configuration aligns with these build settings:

✅ Verification successful

Build and TypeScript configuration are properly aligned for declaration generation

The build configuration in project.json with dts: true is correctly supported by the TypeScript configuration in tsconfig.lib.json which has:

  • "declaration": true enabled for generating .d.ts files
  • Proper module settings with "module": "NodeNext"
  • Correct includes/excludes to process only the source files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if tsconfig.lib.json has proper declaration settings
cat packages/eslint-plugin-rxjs/tsconfig.lib.json | jq '.compilerOptions | select(.declaration == true and .declarationMap == true)'

Length of output: 134


Script:

#!/bin/bash
# Let's check the actual content of tsconfig.lib.json first
cat packages/eslint-plugin-rxjs/tsconfig.lib.json

Length of output: 387

@DaveMBush DaveMBush merged commit bf30a04 into main Dec 28, 2024
3 checks passed
@DaveMBush DaveMBush deleted the dmb/missing-typescript-declaration-file-for-smarttoolseslint-plugin-rxjs/26 branch December 28, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Missing TypeScript declaration file for @smarttools/eslint-plugin-rxjs
1 participant