Skip to content

feat: new restrict-dependency-ranges rule #998

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

Merged
merged 11 commits into from
Apr 22, 2025

Conversation

michaelfaith
Copy link
Collaborator

PR Checklist

Overview

This change adds a new rule that allows you to restrict usage of semver ranges on dependencies using any of the following matching options:

  • by dependency name or regex pattern
  • by version
  • by dependency type

Closes #959

Copy link

codecov bot commented Apr 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (966e175) to head (618bafd).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #998      +/-   ##
==========================================
+ Coverage   99.50%   99.58%   +0.07%     
==========================================
  Files          19       20       +1     
  Lines        1223     1451     +228     
  Branches      142      193      +51     
==========================================
+ Hits         1217     1445     +228     
  Misses          6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@michaelfaith michaelfaith force-pushed the feat/restrict-dependency-range branch 4 times, most recently from 0ecb0f7 to 7269e63 Compare April 6, 2025 22:31
@michaelfaith michaelfaith marked this pull request as ready for review April 7, 2025 18:16
Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

🚀 The core logic seems very reasonable and good to me, really nice job! I think it makes sense to go in order like this and check the first (last, reversed) matching dependency.

Mainly requesting changes on:

  • Docs: adding some more examples to make usage more clear
  • Testing: some of the lines don't fail any tests for me when removed locally
  • Some suggestions around refactors

WDYT?

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Apr 7, 2025
@michaelfaith michaelfaith force-pushed the feat/restrict-dependency-range branch from 1332d62 to 92325bc Compare April 17, 2025 17:26
This change adds a new rule that allows you to restrict usage of semver ranges on dependencies using any of the following matching options:
- by dependency name or regex pattern
- by version
- by dependency type
@michaelfaith michaelfaith force-pushed the feat/restrict-dependency-range branch from 201916f to 65306ee Compare April 17, 2025 17:31
@michaelfaith
Copy link
Collaborator Author

michaelfaith commented Apr 17, 2025

From the "Lint Markdown" step: Each sentence should be on its own line
Really? That seems super heavy-handed...

@JoshuaKGoldberg not directly related to this change, but the first time I'm seeing this error (I think it came in with the CTA update since I just rebased with main). How strongly do you feel about this rule? I'm personally not a fan, but if it's something you feel strongly about, I'll work around it.

@JoshuaKGoldberg
Copy link
Owner

😄 I do feel strongly in favor about it, I think it's really nice to have a 1:1 of "line that can be diffed in Git" to sentences. But also if you end up hating it enough to send a PR that removes it from this repo, I'll approve it.

ACK that it's kind of inconvenient to not have it be integrated into ESLint; I'm hoping that later this year as @eslint/markdown gets fleshed out I can switch from Markdownlint to ESLint altogether...

@michaelfaith
Copy link
Collaborator Author

ACK that it's kind of inconvenient to not have it be integrated into ESLint

That actually touches on the second reason i'm not a fan of the rule haha.

I have two main issues with it. For the first, i think we can generally agree on the following three statements?

  1. Documentation is extremely valuable, but also not something that people always think to do (unless you maintain a project or are long in the tooth like me, it's often an afterthought). So it's something we should generally incentivise contributors to do, by making it as easy as possible to create high quality documentation.
  2. Writing good documentation is an art and not a science. Explaining something in a way that's easy for others to consume, understand, and relate to requires a fair amount of empathy and creative thinking.
  3. Writing prose one sentence per line does not come natural, and would not be how anyone would naturally write documentation unless they happen to know (and remember) this rule was in place.

Those three things tell a story of us believing that something is truly valuable, but then creating friction around contributing it. More often than not, people contributing new code will hit up against that, and get frustrated (like i did 😆). That, then discourages people from even bothering. And all of that could be ok, if we believe the benefits outweigh the cost. And i just don't see that being the case. If i think about the kinds of changes people might make to existing documentation, i don't really see what value having them one sentence per line brings in terms of diff review. Certainly not enough to outweigh the cost. For something like the dangling comma formatting rule (which promises a similar value proposition), that calculus is much more in favor of the rule, since it's something we interact with way more.

And that brings me to the second point of grief: like dangling commas, this is a formatting concern. And i think we generally agree that formatting is the domain of prettier, not lint. This isn't something that feels like it should belong in any lint tool, whether it be markdownlint or eslint. In my mind, if it should exist at all, it should go in prettier.

Happy to be convinced otherwise, if i'm missing something, or not looking at this correctly. 😊

@JoshuaKGoldberg
Copy link
Owner

You make a lot of good points! Agreed, getting folks to write docs in the first place >>> nitpicking the formatting of those docs 😄. Filed JoshuaKGoldberg/create-typescript-app#2216.

Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

💯 solid!

@JoshuaKGoldberg JoshuaKGoldberg merged commit f2d1070 into main Apr 22, 2025
14 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the feat/restrict-dependency-range branch April 22, 2025 14:34
Copy link

🎉 This is included in version v0.30.0 🎉

The release is available on:

Cheers! 📦🚀

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.

🚀 Feature: add restrict dependency ranges rule
2 participants