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

Migrating from eslintrc.json to eslint.config.js #2660

Merged

Conversation

Suyash878
Copy link
Contributor

@Suyash878 Suyash878 commented Dec 14, 2024

What kind of change does this PR introduce?

Feature

Issue Number:

Fixes #2645

Did you add tests for your changes?

Not required.

Snapshots/Videos:

None.

If relevant, did you update the documentation?

Not required.

Summary

Successfully migrating from the deprecated .eslintrc.json to the newly supported eslint.config.js configuration.

Does this PR introduce a breaking change?

No.

Other information

None.

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • Configuration Updates

    • Updated ESLint configuration to use new flat config system.
    • Added new dependencies for ESLint and compatibility.
    • Expanded test file recognition in Vitest configuration.
  • Removed Configuration Files

    • Deleted .eslintignore and .eslintrc.json files.
  • GraphQL Queries

    • Added new fund-related GraphQL queries for retrieving campaign and pledge information.
  • Testing Improvements

    • Refined test cases in various components.
    • Simplified test assertions and mocking approaches.
  • Component Updates

    • Enhanced error handling in Organization Dashboard.
    • Simplified tag template structure.

Copy link
Contributor

coderabbitai bot commented Dec 14, 2024

Warning

Rate limit exceeded

@Suyash878 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6669192 and b264fa3.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)

Walkthrough

This pull request focuses on migrating the ESLint configuration from the traditional .eslintrc.json to the new eslint.config.mjs format. The changes involve updating the project's linting infrastructure, removing the old configuration files, and introducing a more modern, comprehensive ESLint setup. The modification includes adding new dependencies, updating package configurations, and implementing a more flexible and extensible linting approach across the project.

Changes

File Change Summary
eslint.config.mjs New ESLint configuration file with comprehensive plugin support and rule definitions
package.json Updated dependencies, added ESLint-related packages, removed old eslintConfig section
.eslintignore Deleted
.eslintrc.json Deleted
vitest.config.ts Added .mjs file extension to test inclusion pattern
src/GraphQl/Queries/fundQueries.ts Added new GraphQL fund-related queries
src/components/CheckIn/tagTemplate.ts Simplified tag template schema structure

Assessment against linked issues

Objective Addressed Explanation
Migrate from .eslintrc.json to eslint.config.mjs [#2645]
Maintain existing linting rules
Ensure compatibility with new ESLint configuration

Possibly related PRs

  • Plugin and advertisement screen revamp #2006: The changes in the main PR regarding ESLint configuration may relate to the updates in the package.json file, which includes the addition of ESLint-related dependencies and the removal of the eslintConfig section, indicating a shift in how ESLint is managed in the project.
  • feat!: Migrate Testing Framework from Jest to Vitest #2457: The migration from Jest to Vitest in the testing framework is relevant as it aligns with the changes in the main PR that enhance the ESLint configuration, potentially affecting how tests are structured and linted.
  • Refactor: src/screens/BlockUser from Jest to Vitest  #2606: The transition from Jest to Vitest in the BlockUser component tests is related to the main PR's focus on improving code quality and consistency, which includes ESLint configurations that may impact test files.
  • Refactor from jest to vitest #2483 #3140: The refactor from Jest to Vitest in the AddPeopleToTag component tests is relevant as it reflects the broader effort to standardize testing practices, which may also be influenced by the ESLint configurations introduced in the main PR.

Suggested reviewers

  • palisadoes
  • AVtheking

Poem

🐰 Eslint's dance, a config so bright,
From JSON to modern, taking flight!
Rules aligned, with rabbit-like grace,
Cleaning code at a linting pace!
Hop, hop, hooray for clean code delight! 🎉


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.

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

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

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: 1

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

7-9: Simplify plugin import by removing 'fixupPluginRules'.

The use of fixupPluginRules from @eslint/compat may not be necessary in the Flat Configuration. You can import eslint-plugin-import directly and reference it in the plugins section without wrapping it.

Apply this diff to simplify the import:

- import _import from "eslint-plugin-import";
- import { fixupPluginRules } from "@eslint/compat";
+ import importPlugin from "eslint-plugin-import";

  ...

  plugins: {
      react,
      "@typescript-eslint": typescriptEslint,
      jest,
-     import: fixupPluginRules(_import),
+     import: importPlugin,
      tsdoc,
      prettier,
  },

61-62: Update 'ecmaVersion' to the latest version.

The ecmaVersion is set to 2018. Consider updating it to the latest version (e.g., 2023) to support the newest ECMAScript features.

Apply this diff to update the ecmaVersion:

  parser: tsParser,
- ecmaVersion: 2018,
+ ecmaVersion: "latest",
  sourceType: "module",
package.json (1)

Line range hint 97-101: Remove the redundant 'eslintConfig' field from 'package.json'.

Since the ESLint configuration has moved to eslint.config.mjs, the eslintConfig field in package.json is no longer needed and can be removed to prevent confusion.

Apply this diff to remove the redundant configuration:

  },
- "eslintConfig": {
-     "extends": [
-         "react-app",
-         "react-app/jest"
-     ]
- },
  "browserslist": {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4aafd7 and b29d1a4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .eslintignore (0 hunks)
  • .eslintrc.json (0 hunks)
  • eslint.config.mjs (1 hunks)
  • package.json (2 hunks)
  • src/GraphQl/Queries/fundQueries.ts (0 hunks)
  • src/screens/OrganizationDashboard/OrganizationDashboard.tsx (0 hunks)
💤 Files with no reviewable changes (4)
  • .eslintignore
  • .eslintrc.json
  • src/screens/OrganizationDashboard/OrganizationDashboard.tsx
  • src/GraphQl/Queries/fundQueries.ts
🔇 Additional comments (2)
eslint.config.mjs (1)

24-33: Verify that all necessary files are properly ignored.

With the migration from .eslintignore to the ignores array, ensure that all files and patterns that should be excluded from linting are included. This includes any files previously specified in .eslintignore.

Review the ignores array to confirm it reflects all the necessary ignore patterns from your previous configuration.

package.json (1)

119-121: Re-evaluate the necessity of '@eslint/compat' and '@eslint/eslintrc'.

The packages @eslint/compat and @eslint/eslintrc are typically used for compatibility purposes when migrating configurations. Since you're adopting the new Flat Configuration format, these may not be required.

Consider removing these dependencies if they are not essential to your setup.

eslint.config.mjs Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 1

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

51-68: Consider updating ECMAScript version.

The current configuration uses ECMAScript 2018. Consider updating to a more recent version (e.g., 2022) to take advantage of newer language features.

-        ecmaVersion: 2018,
+        ecmaVersion: 2022,

112-116: Consider relaxing interface naming conventions.

The current configuration requires all interfaces to have either "Interface" or "TestInterface" prefix, which might lead to verbose and less readable code. Consider removing the prefix requirement while keeping the PascalCase format.

         "@typescript-eslint/naming-convention": ["error", {
             selector: "interface",
             format: ["PascalCase"],
-            prefix: ["Interface", "TestInterface"],
         }, {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b29d1a4 and d56b259.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🔇 Additional comments (6)
eslint.config.mjs (6)

1-14: LGTM: Import statements are well-organized and complete.

All necessary ESLint plugins and utilities are properly imported.


15-21: LGTM: Configuration setup follows ESLint flat config best practices.

Proper initialization of FlatCompat with correct base directory and ESM compatibility.


34-41: Remove redundant Prettier configuration.

Having both 'plugin:prettier/recommended' and 'prettier' in the extends array is redundant.


42-49: LGTM: Plugin configurations are properly set up.

All plugins are correctly registered and the use of fixupPluginRules for the import plugin is appropriate.


70-74: LGTM: React settings are properly configured.

Using "detect" for React version is the recommended approach.


23-33: Verify the necessity of ignoring specific files.

While the general ignore patterns for CSS/SCSS/JSON files are standard, let's verify if ignoring specific files like src/components/CheckIn/tagTemplate.ts is still necessary.

✅ Verification successful

Let me gather more information about the tagTemplate.ts file to understand why it might need to be ignored.


Based on the results, I can now generate the final response:

The specific file ignores are still necessary and valid

The specifically ignored file src/components/CheckIn/tagTemplate.ts exists and contains a PDF template definition used for tag generation. The file contains base64-encoded PDF data and specific layout configurations, which should be excluded from linting to avoid unnecessary processing of generated/binary content.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the specific ignored files exist and their content
echo "Checking for existence of specifically ignored files..."
for file in "src/components/CheckIn/tagTemplate.ts" "tsconfig.json"
do
  if [ -f "$file" ]; then
    echo "Found $file:"
    head -n 5 "$file"
  else
    echo "$file not found"
  fi
done

Length of output: 798


Script:

#!/bin/bash
# Check the content and usage of tagTemplate.ts
echo "Content of tagTemplate.ts:"
cat src/components/CheckIn/tagTemplate.ts

echo -e "\nChecking for references to tagTemplate:"
rg "tagTemplate" --type ts -C 2

Length of output: 65728

eslint.config.mjs Outdated Show resolved Hide resolved
@Suyash878 Suyash878 changed the title Issue#2645 Migrating from eslintrc.json to eslint.config.js Dec 14, 2024
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: 2

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

1-14: LGTM! Consider organizing imports for better maintainability.

The imports are comprehensive and include all necessary plugins. Consider organizing them into groups:

  • Node.js built-ins
  • ESLint core/compat
  • ESLint plugins
  • Parsers and utilities
+ // Node.js built-ins
 import path from 'node:path';
 import { fileURLToPath } from 'node:url';
+
+ // ESLint core/compat
 import js from '@eslint/js';
 import { FlatCompat } from '@eslint/eslintrc';
 import { fixupPluginRules } from '@eslint/compat';
 import globals from 'globals';
+
+ // ESLint plugins
 import react from 'eslint-plugin-react';
 import typescriptEslint from '@typescript-eslint/eslint-plugin';
 import jest from 'eslint-plugin-jest';
 import _import from 'eslint-plugin-import';
 import tsdoc from 'eslint-plugin-tsdoc';
 import prettier from 'eslint-plugin-prettier';
+
+ // Parsers and utilities
 import tsParser from '@typescript-eslint/parser';

25-34: Consider adding common build and test directories to ignores.

The ignore patterns cover most file types but could be enhanced with common build and test output directories.

 ignores: [
   '**/*.css',
   '**/*.scss',
   '**/*.less',
   '**/*.json',
   'src/components/CheckIn/tagTemplate.ts',
   '**/package.json',
   '**/package-lock.json',
   '**/tsconfig.json',
+  'build/**',
+  'dist/**',
+  'coverage/**',
+  'node_modules/**',
 ],

167-191: Consider adjusting React rule severity levels.

Some React rules might be too restrictive or inconsistent in their severity levels:

  • jsx-equals-spacing is set to "warn" while most other rules are "error"
  • function-component-definition is effectively disabled (0) but includes configuration
- 'react/jsx-equals-spacing': ['warn', 'never'],
+ 'react/jsx-equals-spacing': ['error', 'never'],

- 'react/function-component-definition': [
-   0,
-   {
-     namedComponents: 'function-declaration',
-   },
- ],
+ 'react/function-component-definition': ['error', {
+   namedComponents: ['function-declaration', 'arrow-function'],
+   unnamedComponents: 'arrow-function'
+ }],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf1714d and d089b64.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🔇 Additional comments (2)
eslint.config.mjs (2)

36-43: Remove 'prettier' from the extends array to prevent conflicts.

Using both 'plugin:prettier/recommended' and 'prettier' in the extends array is redundant as 'plugin:prettier/recommended' already includes prettier's recommended configuration.

 ...compat.extends(
   'plugin:react/recommended',
   'eslint:recommended',
   'plugin:jest/recommended',
   'plugin:prettier/recommended',
   'plugin:@typescript-eslint/recommended',
-  'prettier',
 ),

81-113: Strict TypeScript rules need adjustments before enabling

The enabled TypeScript rules are quite strict and may cause numerous errors in the existing codebase. Consider a gradual approach to enabling these rules.

#!/bin/bash
# Verify impact of strict TypeScript rules
echo "Checking TypeScript files for potential violations..."

# Check for explicit any usage
echo "Files with 'any' type usage:"
rg ":\s*any\b" --type=typescript

# Check for non-null assertions
echo "Files with non-null assertions:"
rg "[!]\." --type=typescript

# Check for type assertions
echo "Files with type assertions:"
rg "as\s+\w+" --type=typescript

eslint.config.mjs Show resolved Hide resolved
eslint.config.mjs Show resolved Hide resolved
@palisadoes
Copy link
Contributor

Please make sure that coderabbit.ai approves your changes

@palisadoes
Copy link
Contributor

Please fix the failing tests and ensure CodeRabbit.ai approves your changes

@Suyash878
Copy link
Contributor Author

Suyash878 commented Dec 17, 2024

@palisadoes

  • The sensitive files have been deleted test is failing since my migration involves removing the redundant eslintrc.json and eslintignore files, It will therefore need the ignore sensitive files tag.
  • The Testing application test is failing for other contributors as well, so I think it needs fixing or it is something not directly related to the made changes.
  • Introspection test does not have any particular relations to the changes I made.

Suyash878 and others added 2 commits December 17, 2024 10:31
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 1

🧹 Nitpick comments (4)
eslint.config.mjs (4)

17-21: Consider caching FlatCompat configuration

The FlatCompat instance creates new configurations on every run. Consider moving this to a separate configuration file and caching the result for better performance.

+// eslintCompatConfig.mjs
 const compat = new FlatCompat({
   baseDirectory: dirName,
   recommendedConfig: js.configs.recommended,
   allConfig: js.configs.all,
 });
+export default compat;

25-34: Group ignore patterns by type

Consider grouping ignore patterns by their type for better maintainability:

 ignores: [
+  // Style files
   '**/*.css',
   '**/*.scss',
   '**/*.less',
+  // Config files
   '**/*.json',
-  'src/components/CheckIn/tagTemplate.ts',
   '**/package.json',
   '**/package-lock.json',
   '**/tsconfig.json',
+  // Special cases
+  'src/components/CheckIn/tagTemplate.ts',
 ],

124-164: Simplify naming conventions

The current naming conventions are quite restrictive. Consider:

  1. Removing the strict PascalCase requirement for interfaces
  2. Allowing more flexibility in variable naming
  3. Reconsidering the mandatory underscore prefix for private members
 '@typescript-eslint/naming-convention': [
   'error',
   {
     selector: 'interface',
-    format: ['PascalCase'],
+    format: ['PascalCase', 'StrictPascalCase'],
   },
   // ... other rules ...
   {
     selector: 'memberLike',
     modifiers: ['private'],
     format: ['camelCase'],
-    leadingUnderscore: 'require',
+    leadingUnderscore: 'allow',
   },
 ],

174-190: Standardize React rule severity levels

The React rules mix different severity levels ('error', 'warn', 0). Consider standardizing them:

-'react/jsx-equals-spacing': ['warn', 'never'],
+'react/jsx-equals-spacing': ['error', 'never'],
 'react/no-this-in-sfc': 'error',
-'jest/expect-expect': 0,
+'jest/expect-expect': 'error',
-'react/function-component-definition': [0,
+'react/function-component-definition': ['error',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d089b64 and 6adc55d.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🔇 Additional comments (2)
eslint.config.mjs (2)

36-43: Remove redundant prettier configuration

The configuration includes both 'plugin:prettier/recommended' and 'prettier', which is redundant.


81-81: ⚠️ Potential issue

Consider gradual adoption of strict TypeScript rules

The configuration enables several strict TypeScript rules that might cause numerous errors in the existing codebase. Consider:

  1. Enabling these rules gradually
  2. Starting with 'warn' instead of 'error'
  3. Creating a migration plan for existing code

Particularly challenging rules include:

  • @typescript-eslint/explicit-module-boundary-types
  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/no-non-null-assertion

Also applies to: 99-113

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

@Suyash878 Please fix the failed tests and address coderabbit's comments.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 18, 2024
@Suyash878
Copy link
Contributor Author

Suyash878 commented Dec 21, 2024

This PR will need the ignore-sensitive-files tag, since as one of the necessary steps of the migration involves-
removing the deprecated eslintrc.json and .eslintignore

Copy link

codecov bot commented Dec 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 88.80%. Comparing base (1bc3c5e) to head (b7281f4).
Report is 2 commits behind head on develop-postgres.

Files with missing lines Patch % Lines
src/eslint.config.spec.mjs 0.00% 10 Missing ⚠️
eslint.config.mjs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           develop-postgres    #2660       +/-   ##
=====================================================
+ Coverage             26.46%   88.80%   +62.33%     
=====================================================
  Files                   300      323       +23     
  Lines                  7568     8422      +854     
  Branches               1652     1836      +184     
=====================================================
+ Hits                   2003     7479     +5476     
+ Misses                 5434      701     -4733     
- Partials                131      242      +111     

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

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

🧹 Nitpick comments (3)
eslint.config.mjs (3)

16-16: Remove trailing spaces

There are trailing spaces at the end of these lines that should be removed.

-const fileName = fileURLToPath(import.meta.url);  
+const fileName = fileURLToPath(import.meta.url);
-const dirName = path.dirname(fileName);  
+const dirName = path.dirname(fileName);

Also applies to: 18-18

🧰 Tools
🪛 eslint

[error] 16-16: Delete ··

(prettier/prettier)

🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch

[failure] 16-16:
Delete ··


32-32: Document reason for ignoring tagTemplate.ts

Consider adding a comment explaining why this specific file needs to be ignored from linting.


126-166: Consider simplifying naming convention rules

The naming convention rules are quite complex. Consider simplifying them by:

  1. Combining similar selectors
  2. Using more permissive formats where appropriate
  '@typescript-eslint/naming-convention': [
    'error',
    {
      selector: ['interface', 'typeAlias', 'typeLike', 'enum'],
      format: ['PascalCase'],
    },
-   {
-     selector: ['typeAlias', 'typeLike', 'enum'],
-     format: ['PascalCase'],
-   },
    {
      selector: 'typeParameter',
      format: ['PascalCase'],
      prefix: ['T'],
    },
    {
-     selector: 'variable',
-     format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
-     leadingUnderscore: 'allow',
-   },
-   {
      selector: ['variable', 'parameter'],
      format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
      leadingUnderscore: 'allow',
    },
    {
-     selector: 'parameter',
-     format: ['camelCase'],
-     leadingUnderscore: 'allow',
-   },
-   {
      selector: ['function', 'memberLike'],
      format: ['camelCase', 'PascalCase'],
    },
    {
      selector: 'memberLike',
      modifiers: ['private'],
      format: ['camelCase'],
      leadingUnderscore: 'require',
    },
    {
      selector: 'variable',
      modifiers: ['exported'],
      format: null,
    },
  ],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6adc55d and a4d770e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🧰 Additional context used
🪛 eslint
eslint.config.mjs

[error] 16-16: Delete ··

(prettier/prettier)


[error] 18-18: Delete ··

(prettier/prettier)

🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
eslint.config.mjs

[failure] 16-16:
Delete ··


[failure] 18-18:
Delete ··

🔇 Additional comments (4)
eslint.config.mjs (4)

47-54: LGTM!

The plugin configuration is well-structured and correctly uses fixupPluginRules for the import plugin.


56-74: LGTM!

The language options are well-configured for a modern TypeScript/React project with appropriate globals and parser settings.


75-80: LGTM!

Using 'detect' for React version is the recommended approach.


42-44: 🛠️ Refactor suggestion

Remove redundant prettier configuration

Having both 'plugin:prettier/recommended' and 'prettier' is redundant as 'plugin:prettier/recommended' already includes prettier's recommended configuration.

  ...compat.extends(
    'plugin:react/recommended',
    'eslint:recommended',
    'plugin:jest/recommended',
    'plugin:prettier/recommended',
    'plugin:@typescript-eslint/recommended',
-   'prettier',
  ),

Likely invalid or redundant comment.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 21, 2024
@palisadoes
Copy link
Contributor

Please fix the failing tests. Our test code coverage system will fail if any of these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. The code does not comply with our linting check or other related formatting requirements

Here are some steps to take:

  1. Click on the Details link for the tests to get an explanation of the cause(s)
  2. You may have to fix a test that is not related to this PR as in some rare cases we merge faulty test code. If this is the case, fix the test in this PR. Do not open another issue.

We do this to ensure the overall reliability of the code base is maintained. This is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Additional notes:

  1. Ensure that CodeRabbit.ai approves your work
  2. Please fix any conflicting files

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc1e02 and af0adba.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
eslint.config.mjs

[error] File not found. ESLint could not find the specified configuration file.

🔇 Additional comments (4)
eslint.config.mjs (4)

1-14: LGTM! All necessary ESLint plugins are imported.

The imports are well-organized and include all required plugins for React, TypeScript, Jest, and other necessary functionalities.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


47-55: Remove redundant prettier configurations.

Using both 'eslint-config-prettier' and 'prettier' in the extends array is redundant as you're already using 'plugin:prettier/recommended'.

  ...compat.extends(
    'plugin:react/recommended',
    'eslint:recommended',
    'plugin:jest/recommended',
    'plugin:prettier/recommended',
-   'eslint-config-prettier',
-   'prettier',
  ),
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


74-76: Update ECMAVersion to support modern JavaScript features.

The current ECMAVersion (2018) is outdated. Consider updating to a more recent version.

  parser: tsParser,
- ecmaVersion: 2018,
+ ecmaVersion: 2022,
  sourceType: 'module',
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


136-142: Reconsider restrictive interface naming convention.

The current configuration requires interfaces to be prefixed with either 'Interface' or 'TestInterface', which deviates from common TypeScript practices.

 {
   selector: 'interface',
   format: ['PascalCase'],
-  prefix: ['Interface', 'TestInterface'],
 },
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.

Comment on lines 29 to 45
ignores: [
'**/*.css',
'**/*.scss',
'**/*.less',
'**/*.json',
'**/*.svg',
'docs/docusaurus.config.ts',
'docs/sidebars.ts',
'docs/src/**/*',
'docs/blog/**/*',
'src/components/CheckIn/tagTemplate.ts',
'**/package.json',
'**/package-lock.json',
'**/tsconfig.json',
'docs/**/*',
'eslint.config.mjs'
],
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove eslint.config.mjs from ignores.

The ESLint configuration file should follow the same code quality standards. Instead of ignoring it completely, use specific rule overrides as suggested in the previous comment.

  ignores: [
    // ... other ignores
-   'eslint.config.mjs'
  ],
📝 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
ignores: [
'**/*.css',
'**/*.scss',
'**/*.less',
'**/*.json',
'**/*.svg',
'docs/docusaurus.config.ts',
'docs/sidebars.ts',
'docs/src/**/*',
'docs/blog/**/*',
'src/components/CheckIn/tagTemplate.ts',
'**/package.json',
'**/package-lock.json',
'**/tsconfig.json',
'docs/**/*',
'eslint.config.mjs'
],
ignores: [
'**/*.css',
'**/*.scss',
'**/*.less',
'**/*.json',
'**/*.svg',
'docs/docusaurus.config.ts',
'docs/sidebars.ts',
'docs/src/**/*',
'docs/blog/**/*',
'src/components/CheckIn/tagTemplate.ts',
'**/package.json',
'**/package-lock.json',
'**/tsconfig.json',
'docs/**/*'
],
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.

Comment on lines 15 to 24
export function createESLintCompat(){
const _filename = fileURLToPath(import.meta.url);
const _dirname = path.dirname(_filename);

return new FlatCompat({
baseDirectory: _dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Disable return type rule for this file.

Since this is an .mjs file and TypeScript syntax isn't directly available, consider disabling the return type rule specifically for this file by adding it to the ignores section.

  ignores: [
    // ... other ignores
-   'eslint.config.mjs'
  ],

And add a new configuration object specifically for this file:

  // ... other configs
+ {
+   files: ['eslint.config.mjs'],
+   rules: {
+     '@typescript-eslint/explicit-function-return-type': 'off',
+     '@typescript-eslint/explicit-module-boundary-types': 'off'
+   }
+ },
  {
    plugins: {

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

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.

eslint.config.mjs Outdated Show resolved Hide resolved
@Suyash878
Copy link
Contributor Author

Changes made in the recent commit-

  1. Added eslint.config.mjs to ignores section.
  2. Ensured eslintrc.json and eslintignore are still in pull-request.yml.
    image

@palisadoes
Copy link
Contributor

  1. Can this be merged?
  2. If so, you'll need to create a PR immediately afterwards to test linting

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

🧹 Nitpick comments (2)
eslint.config.mjs (2)

1-14: Consider organizing imports by type for better maintainability.

Group imports into categories:

  1. ESLint core and compatibility
  2. ESLint plugins
  3. Node.js built-ins
  4. TypeScript related
+ // ESLint core and compatibility
 import { fixupPluginRules } from '@eslint/compat';
 import { FlatCompat } from '@eslint/eslintrc';
 import js from '@eslint/js';
+
+ // ESLint plugins
 import react from 'eslint-plugin-react';
 import jest from 'eslint-plugin-jest';
 import _import from 'eslint-plugin-import';
 import tsdoc from 'eslint-plugin-tsdoc';
 import prettier from 'eslint-plugin-prettier';
+
+ // Node.js built-ins
 import path from 'node:path';
 import { fileURLToPath } from 'node:url';
 import globals from 'globals';
+
+ // TypeScript related
 import typescriptEslint from '@typescript-eslint/eslint-plugin';
 import tsParser from '@typescript-eslint/parser';
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


29-45: Remove commented code.

The commented line for ignoring 'eslint.config.mjs' should be removed as it's handled by the override configuration in lines 209-214.

      'docs/**/*',
-     // 'eslint.config.mjs'
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af0adba and 75b3cd3.

📒 Files selected for processing (2)
  • eslint.config.mjs (1 hunks)
  • package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
eslint.config.mjs

[error] File not found. ESLint could not find the specified configuration file.

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

15-24: Implementation looks good!

The function correctly:

  • Resolves the base directory using import.meta.url
  • Initializes FlatCompat with proper configuration
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


47-55: 🛠️ Refactor suggestion

Remove redundant prettier configurations.

The configuration includes multiple prettier-related extends that are redundant:

  • 'plugin:prettier/recommended' already includes prettier configuration
  • 'eslint-config-prettier' and 'prettier' are not needed when using 'plugin:prettier/recommended'
  ...compat.extends(
    'plugin:react/recommended',
    'eslint:recommended',
    'plugin:jest/recommended',
    'plugin:prettier/recommended',
    'plugin:@typescript-eslint/recommended',
-   'eslint-config-prettier',
-   'prettier',
  ),

Likely invalid or redundant comment.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


136-142: 🛠️ Refactor suggestion

Reconsider restrictive interface naming convention.

The current configuration requires interfaces to be prefixed with either 'Interface' or 'TestInterface', which:

  1. Deviates from common TypeScript practices
  2. Makes the code unnecessarily verbose
  {
    selector: 'interface',
    format: ['PascalCase'],
-   prefix: ['Interface', 'TestInterface'],
  },

Likely invalid or redundant comment.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


74-76: 🛠️ Refactor suggestion

Update ECMAVersion to support modern JavaScript features.

The current ECMAVersion (2018) is outdated. Consider updating to a more recent version (2022) to support modern JavaScript features.

  parser: tsParser,
- ecmaVersion: 2018,
+ ecmaVersion: 2022,
  sourceType: 'module',

Likely invalid or redundant comment.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.


1-215: ⚠️ Potential issue

Fix ESLint configuration to resolve pipeline failure.

The pipeline failure indicates that ESLint cannot find the configuration file. This could be due to:

  1. Dual ESLint configurations (both in package.json and eslint.config.mjs)
  2. Build process not handling .mjs files correctly

To resolve this:

  1. Remove the eslintConfig field from package.json
  2. Ensure the build process is configured to handle .mjs files
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] File not found. ESLint could not find the specified configuration file.

@palisadoes
Copy link
Contributor

  1. Please fix the failing test.
  2. We'll need them to do pass before merging

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: 1

♻️ Duplicate comments (2)
eslint.config.mjs (2)

45-53: 🛠️ Refactor suggestion

Remove redundant prettier configurations.

Having both 'eslint-config-prettier' and 'prettier' in the extends array is redundant since you're already using 'plugin:prettier/recommended'. This could potentially cause conflicts.

Apply this diff to fix the issue:

   ...compat.extends(
     'plugin:react/recommended',
     'eslint:recommended',
     'plugin:jest/recommended',
     'plugin:prettier/recommended',
-    'eslint-config-prettier',
-    'prettier',
   ),
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] 45-45: ReferenceError: compat is not defined. ESLint configuration error due to undefined 'compat' variable.


72-74: 🛠️ Refactor suggestion

Update ECMAVersion to support modern JavaScript features.

The current ECMAVersion (2018) is outdated. Consider updating to a more recent version to support modern JavaScript features.

Apply this diff to fix the issue:

   parser: tsParser,
-  ecmaVersion: 2018,
+  ecmaVersion: 2022,
   sourceType: 'module',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75b3cd3 and 5b47969.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
eslint.config.mjs

[error] 45-45: ReferenceError: compat is not defined. ESLint configuration error due to undefined 'compat' variable.

🔇 Additional comments (3)
eslint.config.mjs (3)

1-14: LGTM! All necessary imports are present.

The imports section is well-organized and includes all required ESLint plugins and utilities.


207-212: LGTM! Good solution for type annotations.

The configuration correctly disables TypeScript return type rules for this .mjs file, which is a good solution to the type annotation discussion from previous reviews.


134-140: Reconsider restrictive interface naming convention.

The current configuration requires interfaces to be prefixed with either 'Interface' or 'TestInterface', which deviates from common TypeScript practices and may make the code more verbose.

Apply this diff to make the naming convention more flexible:

 {
   selector: 'interface',
   format: ['PascalCase'],
-  prefix: ['Interface', 'TestInterface'],
 },

eslint.config.mjs Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Suyash878
Copy link
Contributor Author

I have made the changes, please review. And let me know the next course of action

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: 1

🧹 Nitpick comments (3)
eslint.config.mjs (3)

76-78: Update ECMAVersion for modern JavaScript features

The current ECMAVersion (2018) is outdated and may not support modern JavaScript features used in the project.

Apply this diff to update to a more recent version:

    parser: tsParser,
-   ecmaVersion: 2018,
+   ecmaVersion: 2022,
    sourceType: 'module',
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.


138-144: Reconsider restrictive interface naming convention

The current configuration requires interfaces to be prefixed with either 'Interface' or 'TestInterface', which deviates from common TypeScript practices and may make the code more verbose.

Apply this diff to simplify the naming convention:

    {
      selector: 'interface',
      format: ['PascalCase'],
-     prefix: ['Interface', 'TestInterface'],
    },
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.


32-47: Consider using .gitignore patterns for ignored files

The ignores array contains many patterns that might already be covered by .gitignore. ESLint can be configured to read from .gitignore to avoid duplication.

Consider adding this configuration to use .gitignore patterns:

  {
    ignores: [
+     // Read from .gitignore
+     ...compat.extends('eslint:recommended').ignores,
      // Keep only specific overrides not in .gitignore
      'docs/docusaurus.config.ts',
      'docs/sidebars.ts',
      'src/components/CheckIn/tagTemplate.ts',
    ],
  },
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b47969 and 6669192.

📒 Files selected for processing (1)
  • eslint.config.mjs (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
eslint.config.mjs

[error] 29-30: Expected a property, an expression, or a method but instead found 'export default'.

Expected a property, an expression, or a method here.

(parse)


[error] 30-30: expected , but instead found [

Remove [

(parse)


[error] 217-217: expected , but instead found ;

Remove ;

(parse)


[error] 217-217: expected ] but instead the file ends

the file ends here

(parse)

🪛 GitHub Actions: PR Workflow
eslint.config.mjs

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.

🔇 Additional comments (3)
eslint.config.mjs (3)

211-216: LGTM: Appropriate rule overrides for config file

The configuration correctly disables TypeScript return type rules for the ESLint config file itself, which is appropriate since it's an .mjs file.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.


54-56: 🛠️ Refactor suggestion

Remove redundant ESLint configurations

The configuration includes both 'plugin:prettier/recommended' and 'eslint-config-prettier', which is redundant and may cause conflicts.

Apply this diff to remove the redundant configuration:

    'plugin:jest/recommended',
    'plugin:prettier/recommended',
    'plugin:@typescript-eslint/recommended',
-   'eslint-config-prettier',
    'prettier',

Likely invalid or redundant comment.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.


93-208: Verify impact of strict TypeScript rules

The configuration enables several strict TypeScript rules that might impact the existing codebase:

  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/explicit-function-return-type
  • @typescript-eslint/no-non-null-assertion

Run this script to assess the impact:

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] SyntaxError: Unexpected token 'export'. ESLint configuration file contains invalid syntax.

eslint.config.mjs Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Cioppolo14
Copy link
Contributor

@Suyash878 It looks like some tests are still failing.

@Suyash878
Copy link
Contributor Author

Suyash878 commented Jan 5, 2025

the linting test(failing test) is a false positive so it can be ignored for the scope of this PR as discussed with @palisadoes

@palisadoes
Copy link
Contributor

Can I merge this then?

@palisadoes
Copy link
Contributor

You'll need to create another PR immediately afterwards to test

@palisadoes palisadoes merged commit 1104967 into PalisadoesFoundation:develop-postgres Jan 5, 2025
15 of 16 checks passed
@palisadoes
Copy link
Contributor

Please open another PR immediately to test. We can't have this breaking our workflows

@palisadoes
Copy link
Contributor

Merged

@palisadoes
Copy link
Contributor

Please open another PR immediately to test. We can't have this breaking our workflows

@Suyash878
Copy link
Contributor Author

Suyash878 commented Jan 5, 2025

image
Apology for the inconvenience:
In eslint.config.mjs I think during adding suggestions from coderabbitai this line "export default [" was added, it just needs to be removed. So that the checks run on the test branch.

@palisadoes
Copy link
Contributor

  1. Add it to your new PR
  2. We need this fixed quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants