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

feat(config): disallow redefining dependencies already defined in the root #194

Open
midzdotdev opened this issue Jan 20, 2024 · 2 comments

Comments

@midzdotdev
Copy link

midzdotdev commented Jan 20, 2024

Description

I'd really like the ability to prevent having a dependency in a monorepo package that's already defined at the root.

Say I have jest defined in ./package.json, syncpack could be configured to disallow ./apps/my-app/package.json having that dependency too.

Suggested Solution

Honestly I have no idea how you'd want to configure this. I'm happy with something as simple as the above, but I'm sure others would love to customise it further for their own needs.

Help Needed

The ability to produce a sweet ass config interface.

@JamieMason
Copy link
Owner

JamieMason commented Feb 10, 2025

I missed this one @midzdotdev, slowwww reply here. It's a good idea, I'm not sure yet on what the config should be but I'll have a think.

EDIT: Maybe for something like this it's some kind of general lint rule rather than being a form of version group or something, not sure.

@JamieMason JamieMason changed the title Feature Request: Disallow redefining dependencies already defined in the root feat(config): disallow redefining dependencies already defined in the root Feb 10, 2025
@JamieMason
Copy link
Owner

It's very bespoke but one thing you could do today is this in a JS config file:

const rootPackage = require("./package.json");

module.exports = {
  versionGroups: [
    {
      // 1. whenever these dependencies from the root package are found
      dependencies: Object.keys({
        ...rootPackage.dependencies,
        ...rootPackage.devDependencies,
        // add more if you need to
      }),
      // 2. ...but they are NOT in the root package
      packages: [`!${rootPackage.name}`],
      // 3. ban them
      isBanned: true,
    },
  ],
};

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

No branches or pull requests

2 participants