-
Notifications
You must be signed in to change notification settings - Fork 28
🚀 Feature: add restrict dependency ranges rule #959
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
Comments
@JoshuaKGoldberg would love your thoughts on this when you the time. |
Ah thanks - super interesting. I like it. I also think we can iterate on the old restrict-ranges rules options in a few ways.
Seems to me that having both is a bit cluttered. Why have both? How about merging the two into
What if someone wants to allow 2 of 3, not just 1 of 3? Example: a team might be moving from one to the other, so those two are allowed, but the third has never been allowed and is still not. Proposal: maybe additionally allow an array of literals?
This seems overly specific to me. The Instead of this one specific behavior, how about a more general solution for targeting specific ranges? Maybe a type RangeType = "caret" | "tilde" | "pin";
interface RangeRestriction {
forPackages?: string | string[];
forVersions?: string | string[];
rangeType: RangeType | RangeType[];
version?: string;
} "restrict-ranges": ["error", {
ranges: [
// Pre-1.0 packages should be pinned to be careful
{
forPackages: '@example\/.*',
forVersions: '<1',
rangeType: 'pin'
},
// Once we hit 1.0, allow more permissive carets
{
forPackages: '@example\/.*',
forVersions: '>=1',
rangeType: 'caret'
},
// Also, don't upgrade (arbitrary packages for example) to 3.x
{
forPackages: ['@example-1\/.+', 'example-2'],
version: '<3',
}
]
}] |
I do like the direction you're going with this, and particularly the What i'm not quite clear on is what the intent of And minor critique, I don't think |
My thinking there was that they could just add another options object for that, but that could add unnecessary cruft. Seems reasonable to have it built in to support an array. 👍 |
Updated the proposal in the original post |
Yeah, you're right. Agreed. It was confusing & unnecessary. Good call 😄. I really like the updated proposal. 👍 from me! |
Great. I'll start looking at it this weekend. 🚀 |
@all-contributors please add @michaelfaith for ideas.
|
I've put up a pull request to add @michaelfaith! 🎉 |
Adds @michaelfaith as a contributor for ideas. This was requested by JoshuaKGoldberg [in this comment](#959 (comment)) --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
🎉 This is included in version v0.30.0 🎉 The release is available on: Cheers! 📦🚀 |
Bug Report Checklist
main
branch of the repository.Overview
This is a subset of the feature request in #54, specifically for introducing a rule to allow for restricting dependency ranges, similar to restrict-ranges from
eslint-plugin-json-files
.Proposing a rule named
restrict-dependency-ranges
with the following options (or an array of these options):forDependencyTypes: ('dependencies' | 'devDependencies' | 'optionalDependences' | 'peerDependencies')[]
- Apply these options to a specific type of dependenciesforPackages: string[]
- Specific packages or regex patterns to apply these options to.forVersions: string
- Semver range to apply these options to (e.g.<1
)rangeType: 'caret' | 'tilde' | 'pin' | ('caret' | 'tilde' | 'pin)[]
(required) - Specifies the type of range you want to enforce (^, ~, or no range) on the matched dependenciesThe text was updated successfully, but these errors were encountered: