-
Notifications
You must be signed in to change notification settings - Fork 26
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: add the "valid-license" rule #786
base: main
Are you sure you want to change the base?
feat: add the "valid-license" rule #786
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending this! This was a good prod to close out the conversation in #51 about how we want to approach all these requirements. I posted #51 (comment).
Left a couple of initial review comments here in case you feel motivated to work on this before we're certain this is the direction for the package. Cheers!
src/plugin.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of unexpected changes in this file - could you please revert them?
https://www.joshuakgoldberg.com/blog/split-out-unrelated-changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there was some confusion around tabs vs spaces between Prettier and editorconfig (they seem to specify different settings) so all the tabs in plugin.ts got nuked. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the rule and rule test files aren't named consistently with the rule itself requires-license
vs require-license
d97ae03
to
3b6a152
Compare
Rookie error, fixed. |
3b6a152
to
7019c1b
Compare
Thanks for your patience as we worked out the long-term strategy for the rules in this plugin. What we landed on in #51 is that we want to have separate rules for requiring a property and for validating the correctness of that property (if it exists). That way people can use one or the other, or both. So for |
Actually, on second though, why don't we convert this one into the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #786 +/- ##
==========================================
+ Coverage 98.71% 98.78% +0.07%
==========================================
Files 19 20 +1
Lines 1163 1234 +71
Branches 139 146 +7
==========================================
+ Hits 1148 1219 +71
Misses 15 15 ☔ View full report in Codecov by Sentry. |
No problem, can rework this rule to check for validity.
|
Actually that went back and forth a couple of times (my bad 😅). Where we landed is that |
I already put up a PR that lays the groundwork for our approach to |
Just working on this now, looks like the changes would be essentially cosmetic to match what was discussed. The rule currently has a check that if the property is present that it also must be a string. I don't think there is anything in the current discussion about where type checking of the value should live in |
The require- rules won't do any checking of the value. It'll just simply check whether the property is presentor not. |
- Added extra valid test case for missing property - Fix documentation - Fix linting errors
bfa389f
to
84289f4
Compare
PR Checklist
status: accepting prs
Overview
Adds a new rule that enforces the 'licence' value in the package.json to be a specific value, or one of a selection of values.
Proposing this as a new rule to eliminate my usage of npm-package-json-lint, since this was the only feature I needed from it.
I did have this as a custom rule in my own ESLint plugin, but I found out it's very difficult to apply multiple plugins to the same file and I am already using this plugin.
This rule could expand in scope to allow for any value to be validated in the same way.