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

Resolve 14.1.1 incompatibility with eslint & make sure that spec/dummy is linted by eslint #1693

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Judahmeek
Copy link
Contributor

@Judahmeek Judahmeek commented Jan 30, 2025

See title.

Summary

Remove this paragraph and provide a general description of the code changes in your pull
request... were there any bugs you had fixed? If so, mention them. If
these bugs have open GitHub issues, be sure to tag them here as well,
to keep the conversation linked together.

Pull Request checklist

Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by ~.

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file
    Add the CHANGELOG entry at the top of the file.

Other Information

Remove this paragraph and mention any other important and relevant information such as benchmarks.


This change is Reviewable

Summary by CodeRabbit

  • Bug Fixes

    • Fixed ESLint configuration to improve linting and module resolution
    • Updated Webpack configuration for better compatibility
  • Chores

    • Updated package dependencies
    • Refined project configuration files
    • Improved code organization and import statements
  • Documentation

    • Updated changelog with version 14.1.1 fix details
  • Refactor

    • Simplified component structures
    • Added PropTypes for improved type checking
    • Streamlined import and export statements

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request introduces a series of configuration and code modifications across multiple files in the project. The changes primarily focus on ESLint configurations, component prop type validations, and minor structural adjustments in React components. The updates aim to improve code quality, type safety, and project structure, with specific attention to linting rules, import statements, and component prop handling.

Changes

File Change Summary
.eslintignore Updated ignore paths, added spec/dummy/.yalc, spec/dummy/public, spec/dummy/vendor, etc.
.eslintrc Added new rules, updated import resolver settings, added alias configuration
CHANGELOG.md Added entry for version 14.1.1 fix related to ESLint compatibility
package.json Added main entry, added eslint-import-resolver-alias dev dependency
spec/dummy/babel.config.js Updated function name and import path
spec/dummy/client/.eslintignore File deleted
spec/dummy/client/.eslintrc Configuration file removed
Multiple component files Added PropTypes, modified component structures, updated export methods

Suggested reviewers

  • justin808

Possibly related PRs

Poem

🐰 Linting rabbits hop with glee,
Config files dancing, wild and free!
PropTypes validated, imports aligned,
Code quality polished, perfectly designed
A bunny's code review, crisp and bright! 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

🧹 Nitpick comments (4)
spec/dummy/client/app/startup/HelloWorldHooksContext.jsx (2)

Line range hint 9-23: Consider extracting Result component to a separate file.

While the restructuring improves hooks usage, the inner Result component could be moved to its own file to improve maintainability and reusability.


25-29: PropTypes should be moved with the Result component.

If the Result component is extracted, ensure the PropTypes validation moves with it.

spec/dummy/client/app/startup/HelloWorldProps.jsx (1)

Line range hint 11-14: Consider simplifying the delayed value implementation.

The current implementation using state and useEffect could be simplified since delayedValue is only set once and never updated.

-  const [delayedValue, setDelayedValue] = useState(null);
-
-  useEffect(() => {
-    setDelayedValue(props.modificationTarget);
-  }, []);
+  const delayedValue = React.useMemo(() => props.modificationTarget, []);
.eslintrc (1)

49-50: Consider documenting the rationale for disabled rules.

While disabling these rules might be necessary for your use case, it would be helpful to document why these specific rules are disabled:

  • react/forbid-prop-types
  • jsx-a11y/anchor-is-valid
-  react/forbid-prop-types: 0
-  jsx-a11y/anchor-is-valid: 0
+  # Disabled because we use compound prop types in legacy components
+  react/forbid-prop-types: 0
+  # Disabled because we handle anchor clicks via custom handlers
+  jsx-a11y/anchor-is-valid: 0
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 90033e7 and 07e1665.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (20)
  • .eslintignore (1 hunks)
  • .eslintrc (1 hunks)
  • CHANGELOG.md (1 hunks)
  • package.json (3 hunks)
  • spec/dummy/babel.config.js (1 hunks)
  • spec/dummy/client/.eslintignore (0 hunks)
  • spec/dummy/client/.eslintrc (0 hunks)
  • spec/dummy/client/app/components/RouterLayout.jsx (1 hunks)
  • spec/dummy/client/app/packs/rescript-components.js (1 hunks)
  • spec/dummy/client/app/packs/server-bundle.js (1 hunks)
  • spec/dummy/client/app/startup/ContextFunctionReturnInvalidJSX.jsx (2 hunks)
  • spec/dummy/client/app/startup/HelloTurboStream.jsx (1 hunks)
  • spec/dummy/client/app/startup/HelloWorldHooks.jsx (2 hunks)
  • spec/dummy/client/app/startup/HelloWorldHooksContext.jsx (2 hunks)
  • spec/dummy/client/app/startup/HelloWorldProps.jsx (2 hunks)
  • spec/dummy/client/app/startup/ImageExample.jsx (1 hunks)
  • spec/dummy/client/app/startup/RouterApp.server.jsx (1 hunks)
  • spec/dummy/config/webpack/commonWebpackConfig.js (2 hunks)
  • spec/dummy/config/webpack/serverWebpackConfig.js (4 hunks)
  • spec/dummy/config/webpack/webpack.config.js (1 hunks)
💤 Files with no reviewable changes (2)
  • spec/dummy/client/.eslintignore
  • spec/dummy/client/.eslintrc
✅ Files skipped from review due to trivial changes (4)
  • spec/dummy/client/app/packs/server-bundle.js
  • spec/dummy/client/app/startup/HelloTurboStream.jsx
  • spec/dummy/client/app/startup/RouterApp.server.jsx
  • spec/dummy/config/webpack/commonWebpackConfig.js
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build-dummy-app-webpack-test-bundles (newest)
  • GitHub Check: examples (newest)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: examples (oldest)
  • GitHub Check: build-dummy-app-webpack-test-bundles (oldest)
  • GitHub Check: build
  • GitHub Check: rspec-package-tests (oldest)
🔇 Additional comments (19)
spec/dummy/client/app/packs/rescript-components.js (1)

7-7: Verify all import statements for HelloWorldReScript component.

The change from named export to default export requires updating all import statements from import { HelloWorldReScript } to import HelloWorldReScript.

✅ Verification successful

Export change is compatible with existing imports

All existing imports of HelloWorldReScript are already using the default import syntax, so no updates are required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining destructured imports of HelloWorldReScript
rg "import \{ .*HelloWorldReScript.* \}" spec/dummy/

Length of output: 54


Script:

#!/bin/bash
# Search for any imports containing HelloWorldReScript
echo "=== Searching for all HelloWorldReScript imports ==="
rg "import.*HelloWorldReScript" -A 2

# Search for any usage of HelloWorldReScript in JSX/TSX files
echo -e "\n=== Searching for HelloWorldReScript usage in components ==="
rg "<HelloWorldReScript" -A 2

Length of output: 857

spec/dummy/client/app/startup/HelloWorldHooks.jsx (1)

6-6: Address the TODO comment.

The comment "TODO: make more like the HelloWorld.jsx" should be addressed or removed if no longer applicable.

Would you like me to help implement the changes to make this component more similar to HelloWorld.jsx?

spec/dummy/client/app/components/RouterLayout.jsx (1)

6-6: LGTM! Clean refactor removing unused children prop.

The removal of the unused children prop and its PropTypes definition improves code clarity. The router implementation remains correct and follows React Router best practices.

spec/dummy/babel.config.js (2)

1-1: LGTM! Import path updated to follow ESLint conventions.

The removal of the .js extension aligns with common ESLint import rules.


3-3: LGTM! Named function improves code clarity.

Replacing the anonymous function with createBabelConfig enhances debugging and stack traces.

spec/dummy/client/app/startup/ContextFunctionReturnInvalidJSX.jsx (2)

15-19: LGTM! Added PropTypes validation.

The addition of PropTypes improves type checking and aligns with ESLint best practices.


Line range hint 6-13: Verify if this incorrect implementation is intentional.

The component's implementation takes two parameters but doesn't wrap them correctly as noted in the comments below. If this is meant to be a test case for invalid implementations, please add a comment at the top of the file explaining this purpose.

✅ Verification successful

Implementation is intentionally incorrect as a test case

The file contains explicit comments indicating this is an example of incorrect implementation:

  • Top comment states: "Example of incorrectly taking two params and returning JSX"
  • Detailed comments explain the correct implementation that would use a wrapped function
  • Located in spec/dummy directory alongside other test cases
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test files or documentation referencing this component
rg -l "ContextFunctionReturnInvalidJSX" --type=test

Length of output: 80


Script:

#!/bin/bash
# Check the content of the file for comments
echo "=== File content ==="
cat spec/dummy/client/app/startup/ContextFunctionReturnInvalidJSX.jsx

echo -e "\n=== Similar files in directory ==="
ls -1 spec/dummy/client/app/startup/

echo -e "\n=== References in JS/JSX files ==="
rg "ContextFunctionReturnInvalidJSX" -t js -t jsx

Length of output: 2161

spec/dummy/client/app/startup/HelloWorldProps.jsx (1)

28-33: LGTM! Added comprehensive PropTypes validation.

The addition of PropTypes for both helloWorldData and modificationTarget improves type safety.

spec/dummy/client/app/startup/ImageExample.jsx (2)

7-10: LGTM! Import statements are now properly organized.

The imports are now logically grouped and placed at the top of the file, improving code organization.


12-12: Good cleanup: Removed unused props parameter.

Removing the unused _props parameter improves code clarity since the component doesn't use any props.

spec/dummy/config/webpack/serverWebpackConfig.js (3)

31-33: LGTM! Properly documented ESLint rule exception.

The ESLint disable comment is correctly scoped to the specific line where parameter reassignment is necessary.


Line range hint 72-81: LGTM! Well-structured CSS loader filtering logic.

The code properly filters out mini-css-extract-plugin and style-loader while maintaining clear logic flow.


98-99: LGTM! Properly documented ESLint rule exception for SSR file handling.

The ESLint disable comment is correctly scoped to the specific line where parameter reassignment is needed for SSR file handling.

.eslintignore (1)

4-10: LGTM! Well-structured ESLint ignore patterns.

The changes properly:

  • Remove the broad spec/dummy ignore to enable linting
  • Add specific ignore patterns for build artifacts, vendor files, and generated code
  • Maintain proper linting coverage while excluding appropriate files

This aligns well with the PR objective to ensure spec/dummy is linted by ESLint.

.eslintrc (2)

44-44: LGTM! Proper extension handling configuration.

The import/extensions rule is properly configured to handle both JS and JSX files.


56-58: LGTM! Good configuration for module resolution.

The changes:

  • Add proper alias for Assets directory
  • Include .jsx in the extensions list for proper module resolution
package.json (2)

30-30: LGTM: ESLint import resolver addition

The addition of eslint-import-resolver-alias is appropriate for resolving the ESLint compatibility issues mentioned in the PR objectives.


Line range hint 42-43: Verify React version compatibility

The package.json specifies React version ^19.0.0, but React 19 has not been officially released yet. This could lead to compatibility issues.

CHANGELOG.md (1)

21-24: LGTM: Well-formatted changelog entry

The changelog entry is properly formatted, accurately describes the changes, and provides appropriate attribution to the contributor.

Comment on lines +10 to +13
// eslint-disable-next-line import/no-dynamic-require, global-require
return require(path);
} else {
return generateWebpackConfig();
}
return generateWebpackConfig();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review the control flow logic.

The current implementation might have unintended behavior:

  1. If the environment-specific config file exists, it's required but the result isn't used
  2. generateWebpackConfig() is always called regardless of existsSync result

Consider this fix:

 const envSpecificConfig = () => {
   const path = resolve(__dirname, `${env.nodeEnv}.js`);
   if (existsSync(path)) {
     console.log(`Loading ENV specific webpack configuration file ${path}`);
     // eslint-disable-next-line import/no-dynamic-require, global-require
-    return require(path);
+    const envConfig = require(path);
+    return envConfig || generateWebpackConfig();
   }
   return generateWebpackConfig();
 };
📝 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
// eslint-disable-next-line import/no-dynamic-require, global-require
return require(path);
} else {
return generateWebpackConfig();
}
return generateWebpackConfig();
const envSpecificConfig = () => {
const path = resolve(__dirname, `${env.nodeEnv}.js`);
if (existsSync(path)) {
console.log(`Loading ENV specific webpack configuration file ${path}`);
// eslint-disable-next-line import/no-dynamic-require, global-require
const envConfig = require(path);
return envConfig || generateWebpackConfig();
}
return generateWebpackConfig();
};

Comment on lines +20 to +24
HelloWorldHooks.propTypes = {
helloWorldData: PropTypes.shape({
name: PropTypes.string,
}).isRequired,
}
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

Strengthen PropTypes validation.

The name property should be marked as required since it's used directly in the component.

 HelloWorldHooks.propTypes = {
   helloWorldData: PropTypes.shape({
-      name: PropTypes.string,
+      name: PropTypes.string.isRequired,
    }).isRequired,
 }
📝 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
HelloWorldHooks.propTypes = {
helloWorldData: PropTypes.shape({
name: PropTypes.string,
}).isRequired,
}
HelloWorldHooks.propTypes = {
helloWorldData: PropTypes.shape({
name: PropTypes.string.isRequired,
}).isRequired,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant