Skip to content
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

Merged
merged 8 commits into from
Nov 10, 2021

Conversation

bzhang0
Copy link
Contributor

@bzhang0 bzhang0 commented Nov 9, 2021

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 ofsdk-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)

Let me know if there's anything I missed!

@ghost ghost added KeyVault eslint plugin customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Nov 9, 2021
@ghost
Copy link

ghost commented Nov 9, 2021

Thank you for your contribution bzhang0! We will review the pull request and get back to you soon.

Copy link
Member

@maorleger maorleger left a 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

Copy link
Member

@deyaaeldeen deyaaeldeen left a 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`"
Copy link
Member

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?

Suggested change
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.

@bzhang0
Copy link
Contributor Author

bzhang0 commented Nov 9, 2021

@maorleger @deyaaeldeen I'll have these changes done!

Copy link
Member

@jeremymeng jeremymeng left a 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)) {
Copy link
Member

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.

@maorleger maorleger merged commit 41018c3 into Azure:main Nov 10, 2021
danieljurek pushed a commit that referenced this pull request Nov 10, 2021
…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)
@bzhang0 bzhang0 deleted the issue-13214 branch November 18, 2021 00:27
maorleger added a commit that referenced this pull request Nov 22, 2021
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. eslint plugin KeyVault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ESLint plugin] Check if sdk-type exists in package.json
4 participants