-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Linter] Update linter rule to check if sdk-type exists in package.json #18597
Conversation
Thank you for your contribution bzhang0! We will review the pull request and get back to you soon. |
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.
🚀 this looks fine to me. For the README update I think 3.1.0 is fine, this is the latest version we used when adding ts-no-window
and this isn't actually released to npm anymore
Thanks for helping out!
@bzhang0 I can merge this after the README is updated
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 great!
if (!["client", "mgmt"].includes(strValue)) { | ||
context.report({ | ||
node: node.value, | ||
message: "sdk-type is not set to `client` or `mgmt`" |
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.
Perhaps it could be useful to print the unrecognized value too?
message: "sdk-type is not set to `client` or `mgmt`" | |
message: `unrecognized sdk-type value: ${strValue}. Expected `client` or `mgmt` instead.` |
Please note the error messages in the tests will need to be updated too.
@maorleger @deyaaeldeen I'll have these changes done! |
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 good! just one comment
|
||
const strValue = stripPath(value.value); | ||
|
||
if (!["client", "mgmt"].includes(strValue)) { |
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.
Please add "utility"
into the allowed list. It was just added earlier in #18402.
…on (#18597) This fixes #13214. This PR is an update from a past PR, #18565. What's new? - I updated ```ts-package-json-sdktype.ts``` to enforce the existence of```sdk-type``` and that it is either ```client``` or ```mgmt```. If it does not, then the linter will throw an error. - I added/updated appropriate tests and verified the entire repository using ```rush lint``` - I also put the rules in the correct files (```src/configs/index.ts, src/rules/index.ts```, and ```tests/plugin.ts```) - I have written a docs file to put in ```docs/rules``` which are now included in the commit! - I do need to still update the actual ```README.md``` file, but I'm not sure what the actual version is (hopefully this isn't too much trouble)
It looks like ts-package-json-sdktype rule entry was duplicated in #18597 - which causes the "number of rules should match the expected value" to report an error. This PR fixes the issue by removing the duplicated entry. I also went ahead and sorted the entries to make these things easier to spot in the future (although there is no guarantee sort will be preserved).
This fixes #13214. This PR is an update from a past PR, #18565.
What's new?
ts-package-json-sdktype.ts
to enforce the existence ofsdk-type
and that it is eitherclient
ormgmt
. If it does not, then the linter will throw an error.rush lint
src/configs/index.ts, src/rules/index.ts
, andtests/plugin.ts
)docs/rules
which are now included in the commit!README.md
file, but I'm not sure what the actual version is (hopefully this isn't too much trouble)Let me know if there's anything I missed!