Skip to content

Cleanup ESLint packages/react #1027

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

Merged
merged 4 commits into from
Jul 28, 2025

Conversation

jaesoekjjang
Copy link
Contributor

@jaesoekjjang jaesoekjjang commented Jul 16, 2025

What this PR does / why we need it?

Scope: packages/react

  • Add Linting script
  • Fix eslint errors

Any background context you want to provide?

What are the relevant tickets?

Follows #1016

Linting

before fixing
스크린샷 2025-07-16 오후 9 50 22
fixed
스크린샷 2025-07-16 오후 9 54 15

Checklist

  • Added relevant tests or not required
  • Addressed and resolved all CodeRabbit review comments
  • Didn't break anything

Summary by CodeRabbit

  • Documentation

    • Added JSDoc comments to clarify the behavior of certain internal functions in provider hooks.
    • Improved type annotation style consistency in context types and hooks.
    • Added ESLint disable comment for a specific TypeScript linting rule.
  • Chores

    • Introduced a new npm script for linting TypeScript files with automatic fixing and strict warning enforcement.
    • Minor update to npm scripts formatting for consistency.

Following functions were missing jsdoc
- `attachDocument`(DocumentProvider.tsx)
- `activateClient`(YorkieProvider.tsx)
Suppress the `@typescript-eslint/ban-types` rule for initial context value
Copy link

coderabbitai bot commented Jul 16, 2025

Walkthrough

This update adds a "lint" script to the package.json for the React package, refines type annotations, and introduces JSDoc comments in the DocumentProvider and YorkieProvider source files. There are no changes to logic or exported APIs—only documentation, type style, and configuration are updated.

Changes

File(s) Summary
packages/react/package.json Added a "lint" npm script and updated the "preview" script formatting.
packages/react/src/DocumentProvider.tsx Added JSDoc for attachDocument, changed type annotation style for presences, and added ESLint comment.
packages/react/src/YorkieProvider.tsx Added JSDoc for activateClient function.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • blurfx

Poem

In the garden of code where the carrots grow bright,
A rabbit hopped in and set type styles right.
With linting now handy and docs shining through,
The code feels much fresher—just like morning dew!
🥕✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/react/src/YorkieProvider.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/react/src/DocumentProvider.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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 (5)
packages/react/src/YorkieProvider.tsx (1)

60-63: Move the JSDoc block above activateClient for clearer intent

Placing the /** … */ immediately before the async function activateClient line (rather than between hooks and variables) keeps the declaration & its documentation visually contiguous, which improves scan-ability.

packages/react/src/DocumentProvider.tsx (3)

98-101: JSDoc is helpful but would read better directly atop the function

Same nit as in YorkieProvider: put the docblock right above async function attachDocument to avoid the visual gap.


55-57: Prefer a single, project-wide array-type style for consistency

You changed three spots from T[] to Array<T>. Either style is fine, but mixing both within the same file can annoy ESLint’s @typescript-eslint/array-type rule (depends on config). Consider standardising on one form.

Also applies to: 160-164, 231-232


170-171: Avoid any and remove the ban-types disable

Using any defeats the safety of the context. A safer default keeps the linter happy and removes the need for the rule-disable:

-// eslint-disable-next-line @typescript-eslint/ban-types
-const DocumentContext = createContext<DocumentContextType<any, any> | null>(null);
+const DocumentContext = createContext<DocumentContextType<unknown, unknown> | null>(
+  null,
+);
packages/react/package.json (1)

18-20: Add ESLint cache for faster local runs

eslint --cache stores results and speeds up subsequent invocations on unchanged files.

-"lint": "eslint . --fix --max-warnings=0 --ext .ts,.tsx"
+"lint": "eslint . --cache --fix --max-warnings=0 --ext .ts,.tsx"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d59c8c and 5bc2d23.

📒 Files selected for processing (3)
  • packages/react/package.json (1 hunks)
  • packages/react/src/DocumentProvider.tsx (3 hunks)
  • packages/react/src/YorkieProvider.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: hackerwins
PR: yorkie-team/yorkie-js-sdk#954
File: examples/react-flow/src/main.tsx:44-59
Timestamp: 2025-03-17T07:16:43.740Z
Learning: In the react-flow example for yorkie-js-sdk, using a date-based document key (`react-flow-YYYYMMDD`) is an intentional design pattern to create a new document each day.
packages/react/src/YorkieProvider.tsx (1)
Learnt from: hackerwins
PR: yorkie-team/yorkie-js-sdk#954
File: examples/react-flow/src/main.tsx:44-59
Timestamp: 2025-03-17T07:16:43.740Z
Learning: In the react-flow example for yorkie-js-sdk, using a date-based document key (`react-flow-YYYYMMDD`) is an intentional design pattern to create a new document each day.
packages/react/src/DocumentProvider.tsx (1)
Learnt from: hackerwins
PR: yorkie-team/yorkie-js-sdk#954
File: examples/react-flow/src/main.tsx:44-59
Timestamp: 2025-03-17T07:16:43.740Z
Learning: In the react-flow example for yorkie-js-sdk, using a date-based document key (`react-flow-YYYYMMDD`) is an intentional design pattern to create a new document each day.

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.17%. Comparing base (6d59c8c) to head (5bc2d23).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1027      +/-   ##
==========================================
+ Coverage   78.10%   78.17%   +0.06%     
==========================================
  Files          66       66              
  Lines        5764     5764              
  Branches     1043     1043              
==========================================
+ Hits         4502     4506       +4     
+ Misses        951      950       -1     
+ Partials      311      308       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaesoekjjang jaesoekjjang changed the title Cleanup ESLint packages/sdk Cleanup ESLint packages/react Jul 16, 2025
@pengooseDev pengooseDev added enhancement 🌟 New feature or request cleanup 🧹 Paying off technical debt labels Jul 17, 2025
@pengooseDev pengooseDev marked this pull request as draft July 17, 2025 03:16
@pengooseDev
Copy link
Member

Having identified the root cause of the ESLint issue in the related PR, I’m marking this PR as ready for review again.

@pengooseDev pengooseDev marked this pull request as ready for review July 17, 2025 08:05
@hackerwins hackerwins force-pushed the main branch 4 times, most recently from 3f1f084 to 0d6a2da Compare July 28, 2025 01:47
@hackerwins hackerwins self-requested a review July 28, 2025 05:51
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins merged commit 7d29e0e into yorkie-team:main Jul 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup 🧹 Paying off technical debt enhancement 🌟 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants