Skip to content

fix: resolve yarn install warnings and synchronize dependencies #2262

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yslpn
Copy link

@yslpn yslpn commented Jun 14, 2025

Description

This PR resolves all yarn install warnings in the js-lingui monorepo and improves dependency management consistency across packages.

The main issues addressed:

  • Missing peer dependencies causing warnings during installation
  • Outdated eslint plugin versions incompatible with eslint 9
  • Complex @swc-node/register setup with peer dependency conflicts
  • TypeScript errors in detect-locale package
  • Inconsistent dependency versions across monorepo packages

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Documentation update (Jest configuration)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Examples update

Fixes yarn install warnings and improves developer experience

Changes Made

🔧 Dependency Management

  • Added missing peer dependencies: @babel/core to resolve babel preset warnings
  • Added eslint to React package: Required by eslint-plugin-react and eslint-plugin-react-hooks
  • Updated eslint plugins: Upgraded to versions compatible with eslint 9
    • eslint-plugin-react: ^7.32.2^7.37.5
    • eslint-plugin-react-hooks: ^4.6.0^5.2.0

🚀 TypeScript Execution Modernization

  • Replaced @swc-node/register with tsx: Eliminates peer dependency conflicts and provides better compatibility
    • Removed complex @swc/core and @swc/types dependency chain
    • Updated verdaccio:release script to use tsx directly
    • Modern, actively maintained alternative with no configuration required

🔍 Monorepo Consistency

  • Added sherif to CI workflow: Automated detection of dependency version mismatches
  • Synchronized dependency versions: Used npx sherif to align versions across all packages
  • Added "Lint monorepo" step: Runs in main-suite.yml for continuous validation

🐛 Type Safety Improvements

  • Fixed getCookie function: Corrected return type from string to string | undefined
  • Added detect-locale to Jest configuration: Moved to web environment for DOM API access
  • Improved error handling: Fixed early return behavior

🧪 Test Configuration

  • Updated Jest projects: Added detect-locale package to web environment for proper DOM testing
  • Maintained test compatibility: Pinned pseudolocale version to prevent test failures from upstream changes

🔧 ESLint Configuration Cleanup

  • Removed legacy .eslintrc files: Cleaned up old configuration files in favor of flat config
  • Eliminated duplication: Removed redundant configurations and dependencies
js-lingui/
├── eslint.config.mjs                   # One Flat config for the whole project (packages/*/**)
├── examples/
│   ├── remix-vite-babel/.eslintrc.cjs  # Own configuration
│   └── react-native/.eslintrc.js       # Own configuration
└── packages/
    └── react/                          # Delete own configuration (use root config)

Why tsx over @swc-node/register?

  1. Simpler setup: No complex peer dependency management required
  2. Better compatibility: Actively maintained with regular updates
  3. Faster execution: Uses esbuild for very fast TypeScript compilation
  4. No configuration: Works out of the box without setup
  5. Modern tooling: Supports latest Node.js and TypeScript features

Why sherif?

Sherif is a monorepo dependency linter that ensures:

  • All packages use consistent dependency versions
  • No duplicate or conflicting versions exist
  • Better installation performance through deduplication
  • Prevents version drift in large monorepos

Testing

  • yarn install runs without warnings
  • ✅ All existing tests pass
  • yarn lint:all passes
  • sherif reports no issues
  • ✅ TypeScript compilation succeeds
  • ✅ CI workflow includes sherif validation

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

- Add missing peer dependencies (@babel/core, eslint)
- Update eslint plugins to versions compatible with eslint 9
- Replace @swc-node/register with tsx for better compatibility
- Add detect-locale package to Jest web configuration
- Fix getCookie return type and early return handling
- Add sherif monorepo linting to CI workflow
- Update Jest snapshot for fromUrl error test

Resolves yarn install warnings and improves monorepo consistency.
Copy link

vercel bot commented Jun 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview Jun 16, 2025 5:39pm

Copy link

github-actions bot commented Jun 14, 2025

size-limit report 📦

Path Size
packages/core/dist/index.mjs 2.91 KB (0%)
packages/detect-locale/dist/index.mjs 618 B (0%)
packages/react/dist/index.mjs 1.35 KB (0%)

@yslpn yslpn marked this pull request as draft June 14, 2025 22:07
@yslpn yslpn marked this pull request as ready for review June 15, 2025 11:08
Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko left a comment

Choose a reason for hiding this comment

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

There is a better way to sync incosistent version of dependencies across the packages in monorepo. The previous constraints were defined with a caret symbol ^ means minor/patch is allowed. That mean that real versions installed for the project local development is specified in the lock file.

Instead of changing the constraints which was OK, you need to update versions in the lockfile. You can use yarn up -r command to update a specific dependencies or it's transitive dependnecies.

Comment on lines +84 to +86
"@babel/core": "^7.21.0",
"@babel/runtime": "^7.21.0",
"@babel/types": "^7.21.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The dependency constraint should not be bumped for a package if no incompatible changes was applied in the sourcecode of the package.

In other words, if babel-plugin-lingui-macro works perfectly with bael@7.21.0 why we need artificitially bump a version and narrow the constraint (possible bringing incompatibility) for a consumers

Copy link
Author

Choose a reason for hiding this comment

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

I understand your concerns, but first I want to explain my intentions. I was trying to do something that yarn will add in the next major version: sync constraints in a monorepo.

More details here (first thing I found):
https://blog.datamole.ai/yarn-constraints-have-your-monorepo-under-control-12937a720f63

What yarn up -R does is sync installed versions, but it doesn't sync constraints.

So I want to ask if this PR should be finished somehow or closed?

@@ -79,7 +79,7 @@
"pathe": "^1.1.0",
"pkg-up": "^3.1.0",
"pofile": "^1.1.4",
"pseudolocale": "^2.0.0",
"pseudolocale": "2.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why changing the constraint?

Copy link
Author

Choose a reason for hiding this comment

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

A new version was installed, which resulted in changes in pseudo-localization tests (new symbols), so I decided to fix the version instead of fixing a lot of tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not a valid approach for the opensource library. Previously this package was with a wider constraint and consumers might already have a newer version of this installed which is satisfying constraint. This will restrict consumers to only this version even if the other version (with potential fixes) may work

@yslpn yslpn marked this pull request as draft June 16, 2025 13:26
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.

2 participants