[Linter] Add a linter rule to check if sdk-type exists in package.json#18565
[Linter] Add a linter rule to check if sdk-type exists in package.json#18565bzhang0 wants to merge 4 commits intoAzure:mainfrom bzhang0:main
sdk-type exists in package.json#18565Conversation
|
Thank you for your contribution bzhang0! We will review the pull request and get back to you soon. |
|
Hi @bzhang0 - welcome and thank you for your contribution! ❤️ What you have here makes sense to me; however, I have a few thoughts:
I agree with you, I believe these should be merged - would you want to give that a shot? I would expect ts-package-json-sdktype to have the following rules:
Thank you for writing tests for these - I believe your tests will work for the existing rule as well. I would recommend the following:
I don't think that's intentional, might be an overzealous gitignore rule. ( |
|
Hi @maorleger! Super excited to join and help out! I can definitely merge the two rules together - it's pretty clear that if sdk-type can be checked, then it must exist. I will also rename/fix relevant files appropriately, and add the docs to a new commit (I left a message on the other PR I made, #18567, about potentially making a new fork and being more consistent with my branching). I will also follow through with your recommendations, but I had a question about 4:
Does this mean checking to see if the linter actually catches the error? I actually ran into this since I ran |
I just meant having a test case for it. I think you already have it tested indirectly👍 I'm not sure if there's a test file for Hope that makes sense! |
|
Understood! I'll definitely be updating the test cases after merging the two rules together :) |
|
I will be closing this PR to re fork and make my changes in separate branches. Be back soon! :) |
…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)
This fixes #13214. Let me know if there is anything I missed! This is my first time contributing to a big project (or an open source project in general)!
A couple comments + what I did:
ts-package-json-sdktype-exists.tsthat simply checks ifsdk-typeexists in package.json files. If it does not, then the linter will throw an error.rush lintsrc/configs/index.ts,src/rules/index.ts, andtests/plugin.ts)ts-package-json-sdktype.ts, as they seem to have the same combined functionality (one checks if it exists, the other checks if it has the proper fields)docs/rulesbut it seems that these directories are in the.gitignore. Let me know if this is intentional, but regardless I have the appropriate docs ready if needed.Hopefully this is alright, thanks for your time!