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

Eslint upgrade to v9 #9344

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

amjithtitus09
Copy link
Contributor

@amjithtitus09 amjithtitus09 commented Dec 9, 2024

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Introduced a new ESLint configuration file to enhance linting for JavaScript and TypeScript projects.
    • Added support for internationalization and MDX linting.
  • Bug Fixes

    • Removed outdated ESLint configuration to streamline the linting process.
  • Chores

    • Updated and added various dependencies related to ESLint and TypeScript for improved code quality and consistency.
    • Improved the clarity and maintainability of the AssetCreate component without altering its core functionality.

@amjithtitus09 amjithtitus09 requested a review from a team as a code owner December 9, 2024 18:48
Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Walkthrough

The changes in this pull request involve the removal of the .eslintrc.json file and the addition of a new ESLint configuration file, eslint.config.mjs. The new configuration consolidates and updates the linting setup for JavaScript and TypeScript projects, incorporating various plugins and rules. Additionally, the package.json file has been modified to include new dependencies and update existing ones, particularly those related to ESLint and its plugins, ensuring compatibility with the latest version.

Changes

File Change Summary
.eslintrc.json Deleted; contained previous ESLint configuration settings.
eslint.config.mjs Added; new ESLint configuration with comprehensive rules for JavaScript, TypeScript, React, and MDX.
package.json Updated dependencies and devDependencies; added new packages and updated versions of existing ones.

Assessment against linked issues

Objective Addressed Explanation
Upgrade eslint to v9 (9050)
Ensure plugins are compatible with eslint v9 (9050)
Update the eslint config to newest version (9050)

Possibly related PRs

Suggested labels

needs review, good to merge

Suggested reviewers

  • sainak
  • rithviknishad

🐰 In the code we hop and play,
New ESLint rules lead the way.
With packages fresh and bright,
Our code will shine, oh what a sight!
Let's lint and code, all day long,
In harmony, we all belong! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95c49ad and ebffe86.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (2 hunks)
  • src/components/Facility/AssetCreate.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Facility/AssetCreate.tsx
  • package.json

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. (Experiment)
  • @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

netlify bot commented Dec 9, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit ebffe86
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675bec17e675b60008081c1b
😎 Deploy Preview https://deploy-preview-9344--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@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: 3

🧹 Outside diff range and nitpick comments (1)
eslint.config.mjs (1)

15-26: Consider adding common directories to the ignore list

The current ignores list excludes several directories and file types. To further optimize linting performance, consider adding node_modules, .cache, and coverage directories to the ignore list.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0f58adc and 9e6a401.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .eslintrc.json (0 hunks)
  • eslint.config.mjs (1 hunks)
  • package.json (4 hunks)
💤 Files with no reviewable changes (1)
  • .eslintrc.json
🔇 Additional comments (4)
eslint.config.mjs (2)

66-67: Verify the parserOptions.project path

Ensure that the project path in parserOptions ("./tsconfig.json") correctly references your TypeScript configuration file. An incorrect path can lead to linting errors or reduced performance.


139-139: ⚠️ Potential issue

Verify the spread operator usage in MDX configuration

Using the spread operator with mdxPlugin.configs.recommended may not work as expected. Confirm that this syntax is supported in the ESLint flat config. If issues arise, consider importing and extending the recommended configuration.

package.json (2)

63-63: Addition of @radix-ui/react-icons is appropriate

The new dependency @radix-ui/react-icons has been added. Ensure it's used in the project to justify its inclusion.


108-110: ESLint and related packages updated successfully

The updates to ESLint and its plugins align with the upgrade to ESLint v9. The inclusion of new packages like @eslint/compat, @eslint/eslintrc, and globals supports the new configuration.

Also applies to: 128-129, 136-136, 138-138, 142-142, 144-144

eslint.config.mjs Show resolved Hide resolved
eslint.config.mjs Show resolved Hide resolved
package.json Outdated
@@ -81,6 +81,7 @@
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
"echarts-for-react": "^3.0.2",
"eslint-plugin-markdown": "^5.1.0",
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 9, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move eslint-plugin-markdown to devDependencies

eslint-plugin-markdown is a development tool and should be listed under devDependencies to prevent it from being included in the production build.

Apply this diff to fix the issue:

  "dependencies": {
-   "eslint-plugin-markdown": "^5.1.0",
  },
  "devDependencies": {
+   "eslint-plugin-markdown": "^5.1.0",

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member

Choose a reason for hiding this comment

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

@amjithtitus09 this package is not required

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

eslint.config.mjs Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
eslint.config.mjs (2)

26-50: Consider adding TypeScript-specific compiler options

While the global settings are well-configured, consider adding TypeScript compiler options for better type checking:

 languageOptions: {
   ecmaVersion: 12,
   sourceType: "module",
+  parserOptions: {
+    project: "./tsconfig.json",
+    tsconfigRootDir: ".",
+  },
   globals: {
     ...globals.browser,
     ...globals.node,
   },
   parserOptions: {
     ecmaFeatures: {
       jsx: true,
     },
   },
 },

116-117: Simplify Prettier configuration

The Prettier plugin automatically sets up both the plugin and config when using eslint-plugin-prettier/recommended.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 489e7df and 00663e2.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • eslint.config.mjs (1 hunks)
  • package.json (4 hunks)
  • src/components/Facility/AssetCreate.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🪛 eslint
eslint.config.mjs

[error] 10-11: Delete

(prettier/prettier)


[error] 118-118: Insert

(prettier/prettier)

🔇 Additional comments (5)
eslint.config.mjs (2)

1-24: LGTM! Base configuration follows ESLint v9 best practices

The imports and base configuration are well-structured, following the new flat config format introduced in ESLint v9.

🧰 Tools
🪛 eslint

[error] 10-11: Delete

(prettier/prettier)


65-66: Avoid spreading recommended rules directly

Spreading tseslint.configs.recommended.rules and plugin rules can cause conflicts or unexpected behavior.

Also applies to: 86-87

src/components/Facility/AssetCreate.tsx (3)

163-169: LGTM! Improved readability of section visibility logic

The refactored implementation using direct conditional statements is clearer and maintains the same functionality.


196-207: LGTM! Enhanced null safety in asset data handling

The addition of null checks before setting state values improves type safety and prevents potential runtime errors.


499-499: LGTM! Improved className handling

The use of template literals for dynamic class assignments improves code readability and maintainability.

@amjithtitus09
Copy link
Contributor Author

Hey @sainak, I've made the requested changes

package.json Outdated
@@ -81,6 +81,7 @@
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
"echarts-for-react": "^3.0.2",
"eslint-plugin-markdown": "^5.1.0",
Copy link
Member

Choose a reason for hiding this comment

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

@amjithtitus09 this package is not required

src/components/Facility/AssetCreate.tsx Outdated Show resolved Hide resolved
@sainak sainak requested a review from rithviknishad December 13, 2024 08:06
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.

Upgrade eslint to v9
2 participants