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

fix: browser compatibility checks #5288

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mshojaei-txfusion
Copy link
Collaborator

@mshojaei-txfusion mshojaei-txfusion commented Jan 24, 2025

Description

This PR enhances the ESLint configuration to restrict the usage of Node.js built-in modules across the codebase. This is particularly important for the SDK package which needs to maintain browser compatibility for frontend integrations.

Key changes:

  • Added comprehensive ESLint rules to prevent usage of Node.js specific modules (fs, path, crypto, etc.)
  • Updated error messages to guide developers towards environment-agnostic alternatives. (alternatives can be mentioned later on)
  • Created a separate ESLint config for the Solidity package
  • Excluded test files and AWS-related code from these restrictions

Drive-by changes

  • Added ESLint dependency to solidity/package.json
  • Removed redundant eslint-disable comments from test files
  • Updated lint script in solidity/package.json to use the new config

Related issues

#5277

Backward compatibility

Yes. These changes only affect development-time linting and do not impact runtime behavior.

Testing

Manual testing:

  • Verified ESLint rules correctly flag Node.js built-in module imports
  • Confirmed test files in excluded directories are not affected
  • Validated lint commands work as expected in both root and solidity packages

Copy link

changeset-bot bot commented Jan 24, 2025

🦋 Changeset detected

Latest commit: ffda2ff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@hyperlane-xyz/sdk Patch
@hyperlane-xyz/core Patch
@hyperlane-xyz/cli Patch
@hyperlane-xyz/helloworld Patch
@hyperlane-xyz/infra Patch
@hyperlane-xyz/widgets Patch
@hyperlane-xyz/ccip-server Patch
@hyperlane-xyz/github-proxy Patch
@hyperlane-xyz/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (af84574) to head (ffda2ff).
Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5288   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-imports */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have the rule not apply to test files (which are not bundled I have to assume?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I already did this, that is why I removed eslint disable from test files

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes ofc sorry read it wrong

...MonorepoDefaults,
{
ignores: [
'**/test/**/*',
Copy link
Collaborator

@ljankovic-txfusion ljankovic-txfusion Jan 28, 2025

Choose a reason for hiding this comment

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

Why are you ignoring **/test/... why not ./test/**/*?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, thanks

Copy link
Collaborator

@ljankovic-txfusion ljankovic-txfusion left a comment

Choose a reason for hiding this comment

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

I'd rather put these changes in a 1# ZKSync PR, because there we introduce .ts in solidity

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-imports */
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes ofc sorry read it wrong

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

Successfully merging this pull request may close these issues.

4 participants